Invoke callbacks using the correct API

This commit is contained in:
José Valim 2010-12-25 11:41:14 +01:00
parent e95eb93eb7
commit b34f456096
3 changed files with 17 additions and 9 deletions

View File

@ -5,6 +5,7 @@
* Fix an issue causing infinite redirects in production
* rails g destroy works properly with devise generators (by github.com/andmej)
* 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
* Deprecated anybody_signed_in? in favor of signed_in? (by github.com/gavinhughes)

View File

@ -44,7 +44,7 @@ module Devise
env = @controller.request.env
env["PATH_INFO"] = "/#{result[:action]}"
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
@controller.send :render, :status => status, :text => body,

View File

@ -81,15 +81,22 @@ class TestHelpersTest < ActionController::TestCase
Warden::Manager._before_logout.pop
end
end
test "before_failer call should work" do
Warden::Manager.before_failure do |env,opts|
# Do nothing
end
user = create_user
user.confirm!
sign_in user
test "before_failure call should work" do
begin
executed = false
Warden::Manager.before_failure do |env,opts|
executed = true
end
user = create_user
sign_in user
get :index
assert executed
ensure
Warden::Manager._before_failure.pop
end
end
test "allows to sign in with different users" do