diff --git a/lib/devise/controllers/helpers.rb b/lib/devise/controllers/helpers.rb index 8249fe05..b68870d6 100644 --- a/lib/devise/controllers/helpers.rb +++ b/lib/devise/controllers/helpers.rb @@ -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) diff --git a/test/controllers/helpers_test.rb b/test/controllers/helpers_test.rb index c05ccef9..7610b187 100644 --- a/test/controllers/helpers_test.rb +++ b/test/controllers/helpers_test.rb @@ -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"