|
This is a blog of mcr at sandelman.ca |
Wed, 30 Apr 2008testing with authenticated resources So, you add new code to authenticate various access, and your functional tests stop working.. You need to authenticate! Add this to your test_helper.rb:
def user1_login_details
'Basic ' + Base64.encode64('user1'+':'+'user1pw')
end
def user1_login
@request.env['HTTP_AUTHORIZATION'] = user1_login_details
end
(the details are split out because we used them in other places too) then add a call to "user1_login" to your functional tests, or if all of them need it, to the "def setup". Remember to write tests for not being logged in, and for situations where the logged in user should not have access to some protected resource. posted at: 23:49 | path: /ruby-on-rails | permanent link to this entry
|
|
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||