Skip to content

Instantly share code, notes, and snippets.

@gbuesing
Created January 14, 2013 18:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gbuesing/4532326 to your computer and use it in GitHub Desktop.
Save gbuesing/4532326 to your computer and use it in GitHub Desktop.
Helper to set HTTP Basic Auth in functional/controller tests
# Helper to set HTTP Basic Auth in functional/controller tests
# Put this in test/test_helper.rb:
class ActionController::TestCase
def login_via_http_basic_auth username, password
@request.env['HTTP_AUTHORIZATION'] = ActionController::HttpAuthentication::Basic.encode_credentials(username, password)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment