diff --git a/test/integration/rememberable_test.rb b/test/integration/rememberable_test.rb index b5a227db..cb686649 100644 --- a/test/integration/rememberable_test.rb +++ b/test/integration/rememberable_test.rb @@ -10,7 +10,13 @@ class RememberMeTest < Devise::IntegrationTest end def generate_signed_cookie(raw_cookie) - request = Devise.rails5? ? ActionDispatch::TestRequest.create : ActionDispatch::TestRequest.new + request = if Devise.rails51? + ActionController::TestRequest.create(Class.new) # needs a "controller class" + elsif Devise.rails5? + ActionController::TestRequest.create + else + ActionController::TestRequest.new + end request.cookie_jar.signed['raw_cookie'] = raw_cookie request.cookie_jar['raw_cookie'] end diff --git a/test/rails_app/config/boot.rb b/test/rails_app/config/boot.rb index fef72810..5831994a 100644 --- a/test/rails_app/config/boot.rb +++ b/test/rails_app/config/boot.rb @@ -3,7 +3,11 @@ unless defined?(DEVISE_ORM) end module Devise - # Detection for minor differences between Rails 4 and 5 in tests. + # Detection for minor differences between Rails 4 and 5, and 5.1 in tests. + def self.rails51? + Rails.version.start_with? '5.1' + end + def self.rails5? Rails.version.start_with? '5' end diff --git a/test/test/controller_helpers_test.rb b/test/test/controller_helpers_test.rb index dc0c2a2a..cfc37bbd 100644 --- a/test/test/controller_helpers_test.rb +++ b/test/test/controller_helpers_test.rb @@ -163,7 +163,15 @@ class TestControllerHelpersTest < Devise::ControllerTestCase test "creates a new warden proxy if the request object has changed" do old_warden_proxy = warden - @request = Devise.rails5? ? ActionController::TestRequest.create : ActionController::TestRequest.new + + @request = if Devise.rails51? + ActionController::TestRequest.create(Class.new) # needs a "controller class" + elsif Devise.rails5? + ActionController::TestRequest.create + else + ActionController::TestRequest.new + end + new_warden_proxy = warden assert_not_equal old_warden_proxy, new_warden_proxy