test_helper.rb 757 B

123456789101112131415161718192021222324252627
  1. require File.expand_path('../../config/environment', __FILE__)
  2. require 'rails/test_help'
  3. class ActiveSupport::TestCase
  4. # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
  5. fixtures :all
  6. # Returns true if a test user is logged in.
  7. def is_logged_in?
  8. !session[:user_id].nil?
  9. end
  10. # Log in as a particular user.
  11. def log_in_as(user)
  12. session[:user_id] = user.id
  13. end
  14. end
  15. class ActionDispatch::IntegrationTest
  16. # Log in as a particular user.
  17. def log_in_as(user, password: 'password', remember_me: '1')
  18. post login_path, params: { session: { login: user.login,
  19. password: password,
  20. remember_me: remember_me } }
  21. end
  22. end