mirror of
https://github.com/heartcombo/devise.git
synced 2022-11-09 12:18:31 -05:00
Create an anonymous class to test the failure app
No need to have a named class inside the test.
This commit is contained in:
parent
9938a5e933
commit
2e8aecdac2
1 changed files with 4 additions and 8 deletions
|
@ -146,25 +146,21 @@ class TestHelpersTest < ActionController::TestCase
|
||||||
assert_match /User ##{second_user.id}/, @response.body
|
assert_match /User ##{second_user.id}/, @response.body
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "passes given headers from the failure app to the response" do
|
||||||
test "passes given headers from the failure app to the response" do
|
|
||||||
|
|
||||||
begin
|
begin
|
||||||
old_failure_app = Devise.warden_config[:failure_app]
|
old_failure_app = Devise.warden_config[:failure_app]
|
||||||
class CustomTestFailureApp < Devise::FailureApp
|
Devise.warden_config[:failure_app] = Class.new(Devise::FailureApp) do
|
||||||
def respond
|
def respond
|
||||||
self.status = 401
|
self.status = 401
|
||||||
self.response.headers["CUSTOMHEADER"] = 1
|
self.response.headers["CUSTOMHEADER"] = 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
Devise.warden_config[:failure_app] = CustomTestFailureApp
|
|
||||||
user = create_user
|
sign_in create_user
|
||||||
sign_in user
|
|
||||||
get :index
|
get :index
|
||||||
assert_equal 1, @response.headers["CUSTOMHEADER"]
|
assert_equal 1, @response.headers["CUSTOMHEADER"]
|
||||||
ensure
|
ensure
|
||||||
Devise.warden_config[:failure_app] = old_failure_app
|
Devise.warden_config[:failure_app] = old_failure_app
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue