Invoke callbacks using the correct API
This commit is contained in:
parent
e95eb93eb7
commit
b34f456096
|
@ -5,6 +5,7 @@
|
||||||
* Fix an issue causing infinite redirects in production
|
* Fix an issue causing infinite redirects in production
|
||||||
* rails g destroy works properly with devise generators (by github.com/andmej)
|
* rails g destroy works properly with devise generators (by github.com/andmej)
|
||||||
* recall options is now passed forward by hooks (by github.com/siong1987)
|
* recall options is now passed forward by hooks (by github.com/siong1987)
|
||||||
|
* before_failure callbacks should work on test helpers (by github.com/twinge)
|
||||||
|
|
||||||
* deprecations
|
* deprecations
|
||||||
* Deprecated anybody_signed_in? in favor of signed_in? (by github.com/gavinhughes)
|
* Deprecated anybody_signed_in? in favor of signed_in? (by github.com/gavinhughes)
|
||||||
|
|
|
@ -44,7 +44,7 @@ module Devise
|
||||||
env = @controller.request.env
|
env = @controller.request.env
|
||||||
env["PATH_INFO"] = "/#{result[:action]}"
|
env["PATH_INFO"] = "/#{result[:action]}"
|
||||||
env["warden.options"] = result
|
env["warden.options"] = result
|
||||||
Warden::Manager._before_failure.each{ |hook| hook.first.call(env, result) }
|
Warden::Manager._run_callbacks(:before_failure, env, result)
|
||||||
|
|
||||||
status, headers, body = Devise::FailureApp.call(env).to_a
|
status, headers, body = Devise::FailureApp.call(env).to_a
|
||||||
@controller.send :render, :status => status, :text => body,
|
@controller.send :render, :status => status, :text => body,
|
||||||
|
|
|
@ -82,14 +82,21 @@ class TestHelpersTest < ActionController::TestCase
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
test "before_failer call should work" do
|
test "before_failure call should work" do
|
||||||
Warden::Manager.before_failure do |env,opts|
|
begin
|
||||||
# Do nothing
|
executed = false
|
||||||
end
|
Warden::Manager.before_failure do |env,opts|
|
||||||
user = create_user
|
executed = true
|
||||||
user.confirm!
|
end
|
||||||
|
|
||||||
sign_in user
|
user = create_user
|
||||||
|
sign_in user
|
||||||
|
|
||||||
|
get :index
|
||||||
|
assert executed
|
||||||
|
ensure
|
||||||
|
Warden::Manager._before_failure.pop
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
test "allows to sign in with different users" do
|
test "allows to sign in with different users" do
|
||||||
|
|
Loading…
Reference in New Issue