Check for empty response body on redirect with Rails main (future 7.1)
Rails is no longer returning a message with the response body on redirects, just an empty body. https://github.com/rails/rails/pull/44554
This commit is contained in:
parent
875217d8c1
commit
e1c53d6580
|
@ -213,9 +213,13 @@ class FailureTest < ActiveSupport::TestCase
|
|||
|
||||
test 'set up a default message' do
|
||||
call_failure
|
||||
assert_match(/You are being/, @response.last.body)
|
||||
assert_match(/redirected/, @response.last.body)
|
||||
assert_match(/users\/sign_in/, @response.last.body)
|
||||
if Devise::Test.rails71_and_up?
|
||||
assert_empty @response.last.body
|
||||
else
|
||||
assert_match(/You are being/, @response.last.body)
|
||||
assert_match(/redirected/, @response.last.body)
|
||||
assert_match(/users\/sign_in/, @response.last.body)
|
||||
end
|
||||
end
|
||||
|
||||
test 'works for any navigational format' do
|
||||
|
|
|
@ -8,6 +8,10 @@ module Devise
|
|||
module Test
|
||||
# Detection for minor differences between Rails versions in tests.
|
||||
|
||||
def self.rails71_and_up?
|
||||
!rails70? && Rails::VERSION::MAJOR >= 7
|
||||
end
|
||||
|
||||
def self.rails70?
|
||||
Rails.version.start_with? '7.0'
|
||||
end
|
||||
|
|
|
@ -97,7 +97,12 @@ class TestControllerHelpersTest < Devise::ControllerTestCase
|
|||
|
||||
test "returns the body of a failure app" do
|
||||
get :index
|
||||
assert_equal "<html><body>You are being <a href=\"http://test.host/users/sign_in\">redirected</a>.</body></html>", response.body
|
||||
|
||||
if Devise::Test.rails71_and_up?
|
||||
assert_empty response.body
|
||||
else
|
||||
assert_equal "<html><body>You are being <a href=\"http://test.host/users/sign_in\">redirected</a>.</body></html>", response.body
|
||||
end
|
||||
end
|
||||
|
||||
test "returns the content type of a failure app" do
|
||||
|
@ -203,6 +208,11 @@ class TestControllerHelpersForStreamingControllerTest < Devise::ControllerTestCa
|
|||
|
||||
test "doesn't hang when sending an authentication error response body" do
|
||||
get :index
|
||||
assert_equal "<html><body>You are being <a href=\"http://test.host/users/sign_in\">redirected</a>.</body></html>", response.body
|
||||
|
||||
if Devise::Test.rails71_and_up?
|
||||
assert_empty response.body
|
||||
else
|
||||
assert_equal "<html><body>You are being <a href=\"http://test.host/users/sign_in\">redirected</a>.</body></html>", response.body
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue