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:
parent
7113beac81
commit
fdf6a48a7e
2 changed files with 17 additions and 1 deletions
|
@ -46,7 +46,7 @@ module Devise
|
||||||
env["warden.options"] = result
|
env["warden.options"] = result
|
||||||
Warden::Manager._run_callbacks(:before_failure, env, 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,
|
@controller.send :render, :status => status, :text => body,
|
||||||
:content_type => headers["Content-Type"], :location => headers["Location"]
|
:content_type => headers["Content-Type"], :location => headers["Location"]
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,12 @@ class TestHelpersTest < ActionController::TestCase
|
||||||
tests UsersController
|
tests UsersController
|
||||||
include Devise::TestHelpers
|
include Devise::TestHelpers
|
||||||
|
|
||||||
|
class CustomFailureApp < Devise::FailureApp
|
||||||
|
def redirect
|
||||||
|
self.status = 306
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
test "redirects if attempting to access a page unauthenticated" do
|
test "redirects if attempting to access a page unauthenticated" do
|
||||||
get :index
|
get :index
|
||||||
assert_redirected_to new_user_session_path
|
assert_redirected_to new_user_session_path
|
||||||
|
@ -52,6 +58,16 @@ class TestHelpersTest < ActionController::TestCase
|
||||||
get :index
|
get :index
|
||||||
assert_redirected_to new_user_session_path
|
assert_redirected_to new_user_session_path
|
||||||
end
|
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
|
test "defined Warden after_authentication callback should not be called when sign_in is called" do
|
||||||
begin
|
begin
|
||||||
|
|
Loading…
Reference in a new issue