1
0
Fork 0
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:
Carlos Antonio da Silva 2014-07-10 08:12:29 -03:00
parent 9938a5e933
commit 2e8aecdac2

View file

@ -146,25 +146,21 @@ class TestHelpersTest < ActionController::TestCase
assert_match /User ##{second_user.id}/, @response.body
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
old_failure_app = Devise.warden_config[:failure_app]
class CustomTestFailureApp < Devise::FailureApp
Devise.warden_config[:failure_app] = Class.new(Devise::FailureApp) do
def respond
self.status = 401
self.response.headers["CUSTOMHEADER"] = 1
end
end
Devise.warden_config[:failure_app] = CustomTestFailureApp
user = create_user
sign_in user
sign_in create_user
get :index
assert_equal 1, @response.headers["CUSTOMHEADER"]
ensure
Devise.warden_config[:failure_app] = old_failure_app
end
end
end