sign_out helper uses the new warden api

This commit is contained in:
Rodrigo Flores 2012-02-15 19:52:39 -02:00
parent 71f5a01b83
commit 9e7ab38bce
2 changed files with 5 additions and 5 deletions

View File

@ -136,7 +136,7 @@ module Devise
def sign_out(resource_or_scope=nil)
return sign_out_all_scopes unless resource_or_scope
scope = Devise::Mapping.find_scope!(resource_or_scope)
warden.user(scope) # Without loading user here, before_logout hook is not called
warden.user(:scope => scope, :run_callbacks => false) # Without loading user here, before_logout hook is not called
warden.raw_session.inspect # Without this inspect here. The session does not clear.
warden.logout(scope)
instance_variable_set(:"@current_#{scope}", nil)

View File

@ -141,7 +141,7 @@ class ControllerAuthenticatableTest < ActionController::TestCase
test 'sign out clears up any signed in user by scope' do
user = User.new
@mock_warden.expects(:user).with(:user).returns(user)
@mock_warden.expects(:user).with(:scope => :user, :run_callbacks => false).returns(user)
@mock_warden.expects(:logout).with(:user).returns(true)
@controller.instance_variable_set(:@current_user, user)
@controller.sign_out(:user)
@ -149,13 +149,13 @@ class ControllerAuthenticatableTest < ActionController::TestCase
end
test 'sign out proxy to logout on warden' do
@mock_warden.expects(:user).with(:user).returns(true)
@mock_warden.expects(:user).with(:scope => :user, :run_callbacks => false).returns(true)
@mock_warden.expects(:logout).with(:user).returns(true)
@controller.sign_out(:user)
end
test 'sign out accepts a resource as argument' do
@mock_warden.expects(:user).with(:user).returns(true)
@mock_warden.expects(:user).with(:scope => :user, :run_callbacks => false).returns(true)
@mock_warden.expects(:logout).with(:user).returns(true)
@controller.sign_out(User.new)
end
@ -230,7 +230,7 @@ class ControllerAuthenticatableTest < ActionController::TestCase
test 'sign out and redirect uses the configured after sign out path when signing out only the current scope' do
swap Devise, :sign_out_all_scopes => false do
@mock_warden.expects(:user).with(:admin).returns(true)
@mock_warden.expects(:user).with(:scope => :admin, :run_callbacks => false).returns(true)
@mock_warden.expects(:logout).with(:admin).returns(true)
@controller.expects(:redirect_to).with(admin_root_path)
@controller.instance_eval "def after_sign_out_path_for(resource); admin_root_path; end"