1
0
Fork 0
mirror of https://github.com/heartcombo/devise.git synced 2022-11-09 12:18:31 -05:00

Custom failure apps no longer ignored in test mode.

This commit is contained in:
Joey Aghion 2011-02-18 15:03:55 +08:00 committed by José Valim
parent 7113beac81
commit fdf6a48a7e
2 changed files with 17 additions and 1 deletions

View file

@ -46,7 +46,7 @@ module Devise
env["warden.options"] = result
Warden::Manager._run_callbacks(:before_failure, env, result)
status, headers, body = Devise::FailureApp.call(env).to_a
status, headers, body = Devise.warden_config[:failure_app].call(env).to_a
@controller.send :render, :status => status, :text => body,
:content_type => headers["Content-Type"], :location => headers["Location"]

View file

@ -4,6 +4,12 @@ class TestHelpersTest < ActionController::TestCase
tests UsersController
include Devise::TestHelpers
class CustomFailureApp < Devise::FailureApp
def redirect
self.status = 306
end
end
test "redirects if attempting to access a page unauthenticated" do
get :index
assert_redirected_to new_user_session_path
@ -52,6 +58,16 @@ class TestHelpersTest < ActionController::TestCase
get :index
assert_redirected_to new_user_session_path
end
test "respects custom failure app" do
begin
Devise.warden_config.failure_app = CustomFailureApp
get :index
assert_response 306
ensure
Devise.warden_config.failure_app = Devise::FailureApp
end
end
test "defined Warden after_authentication callback should not be called when sign_in is called" do
begin