Module: AuthenticatedTestHelper

Included in:
ActiveSupport::TestCase
Defined in:
lib/branston/lib/authenticated_test_helper.rb

Instance Method Summary collapse

Instance Method Details

#authorize_as(user) ⇒ Object



7
8
9
# File 'lib/branston/lib/authenticated_test_helper.rb', line 7

def authorize_as(user)
  @request.env["HTTP_AUTHORIZATION"] = user ? ActionController::HttpAuthentication::Basic.encode_credentials(users(user)., '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 (user)
  @request.session[:user_id] = user ? (user.is_a?(User) ? user.id : users(user).id) : nil
end