Integration tests should work with the login method
Actual Behavior
All tests work under Rails 5.4.
Under Rails 6.0 , tests that inherit from ActionController::TestCase work just fine.
However, tests that inherit from ActionDispatch::IntegrationTest do not work. The result is Filter chain halted as :require_login rendered or redirected
Steps to Reproduce
Here's a test example:
require 'test_helper'
class ImportAliyotTest < ActionDispatch::IntegrationTest
include Sorcery::TestHelpers::Rails::Integration
include Sorcery::TestHelpers::Rails::Controller
setup do
user = users(:one)
authenticate_user(user)
@current_user = user
@cutid = user.tenant.id
end
And here's the test_helper
require File.expand_path('../../config/environment', __FILE__)
require 'rails/test_help'
require 'capybara/rails'
class ActiveSupport::TestCase
include Sorcery::TestHelpers::Rails::Integration
include Sorcery::TestHelpers::Rails::Controller
# Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
fixtures :all
Capybara.server = :puma # Until your setup is working
Capybara.default_driver = :selenium_chrome
# Add more helper methods to be used by all tests here...
def login_user(user)
# post the login and follow through
post "/sessions", params: {
email: user.email,
password: user.password
}
puts user.inspect
follow_redirect!
end
def authenticate_user(user = users(:one))
post sessions_url, params: {
email: user.email,
password: "hac56wsn"
}
assert_equal session[:user_id].to_i, user.id
end
end
@legacy370 Based on the information provided, it seems difficult to identify the cause of the issue. Could you provide complete, unabridged code that reproduces the problem?
Configuration
Expected Behavior
Integration tests should work with the login method
Actual Behavior
All tests work under Rails 5.4. Under Rails 6.0 , tests that inherit from ActionController::TestCase work just fine. However, tests that inherit from ActionDispatch::IntegrationTest do not work. The result is Filter chain halted as :require_login rendered or redirected
Steps to Reproduce
And here's the test_helper