mirror of
https://github.com/heartcombo/devise.git
synced 2026-01-08 22:37:57 -05:00
Add explicit test for respecting the error_status responder config
While introducing this on turbo, looks like no specific test was added, so this at least covers that a bit. It needs some conditional checks since not all supported Rails + Responders version work with the customization, so there's one test for the hardcoded status version too, which can be removed in the future.
This commit is contained in:
@@ -371,6 +371,35 @@ class FailureTest < ActiveSupport::TestCase
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# TODO: remove conditional/else when supporting only responders 3.1+
|
||||
if ActionController::Responder.respond_to?(:error_status=)
|
||||
test 'respects the configured responder `error_status` for the status code' do
|
||||
swap Devise.responder, error_status: :unprocessable_entity do
|
||||
env = {
|
||||
"warden.options" => { recall: "devise/sessions#new", attempted_path: "/users/sign_in" },
|
||||
"devise.mapping" => Devise.mappings[:user],
|
||||
"warden" => stub_everything
|
||||
}
|
||||
call_failure(env)
|
||||
|
||||
assert_equal 422, @response.first
|
||||
assert_includes @response.third.body, 'Invalid Email or password.'
|
||||
end
|
||||
end
|
||||
else
|
||||
test 'uses default hardcoded responder `error_status` for the status code since responders version does not support configuring it' do
|
||||
env = {
|
||||
"warden.options" => { recall: "devise/sessions#new", attempted_path: "/users/sign_in" },
|
||||
"devise.mapping" => Devise.mappings[:user],
|
||||
"warden" => stub_everything
|
||||
}
|
||||
call_failure(env)
|
||||
|
||||
assert_equal 200, @response.first
|
||||
assert_includes @response.third.body, 'Invalid Email or password.'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "Lazy loading" do
|
||||
|
||||
Reference in New Issue
Block a user