Permalink
Browse files

sign_out helper uses the new warden api

  • Loading branch information...
1 parent 71f5a01 commit 9e7ab38bcec5188eee9962acab3e4917936c2136 Rodrigo Flores committed Feb 15, 2012
Showing with 5 additions and 5 deletions.
  1. +1 −1 lib/devise/controllers/helpers.rb
  2. +4 −4 test/controllers/helpers_test.rb
View
2 lib/devise/controllers/helpers.rb
@@ -136,7 +136,7 @@ def sign_in(resource_or_scope, *args)
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
8 test/controllers/helpers_test.rb
@@ -141,21 +141,21 @@ def setup
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)
assert_equal nil, @controller.instance_variable_get(:@current_user)
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 @@ def setup
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"

0 comments on commit 9e7ab38

Please sign in to comment.