Module: AuthenticatedTestHelper
- Included in:
- ActiveSupport::TestCase
- Defined in:
- lib/branston/lib/authenticated_test_helper.rb
Instance Method Summary collapse
- #authorize_as(user) ⇒ Object
-
#login_as(user) ⇒ Object
Sets the current user in the session from the user fixtures.
Instance Method Details
#authorize_as(user) ⇒ Object
7 8 9 |
# File 'lib/branston/lib/authenticated_test_helper.rb', line 7 def (user) @request.env["HTTP_AUTHORIZATION"] = user ? ActionController::HttpAuthentication::Basic.encode_credentials(users(user).login, 'monkey') : nil end |
#login_as(user) ⇒ Object
Sets the current user in the session from the user fixtures.
3 4 5 |
# File 'lib/branston/lib/authenticated_test_helper.rb', line 3 def login_as(user) @request.session[:user_id] = user ? (user.is_a?(User) ? user.id : users(user).id) : nil end |