Permalink
Browse files

Smallish updates.

  • Loading branch information...
1 parent 2d2c4c6 commit b2496d1bc1006d916c170cb9d77f75e0151f218d @josevalim josevalim committed Nov 11, 2010
View
@@ -4,7 +4,7 @@ PATH
devise (1.2.rc)
bcrypt-ruby (~> 2.1.2)
orm_adapter (~> 0.0.2)
- warden (~> 1.0.0)
+ warden (~> 1.0.2)
GEM
remote: http://rubygems.org/
@@ -158,5 +158,5 @@ DEPENDENCIES
rails
ruby-debug (>= 0.10.3)
sqlite3-ruby
- warden (~> 1.0.0)
+ warden (~> 1.0.2)
webrat (= 0.7.1)
@@ -121,7 +121,8 @@ def sign_in(resource_or_scope, *args)
# sign_out :user # sign_out(scope)
# sign_out @user # sign_out(resource)
#
- def sign_out(resource_or_scope)
+ 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.raw_session.inspect # Without this inspect here. The session does not clear.
@@ -214,11 +215,7 @@ def redirect_for_sign_in(scope, resource) #:nodoc:
# after_sign_out_path_for.
def sign_out_and_redirect(resource_or_scope)
scope = Devise::Mapping.find_scope!(resource_or_scope)
- if Devise.sign_out_all_scopes
- sign_out_all_scopes
- else
- sign_out(scope)
- end
+ Devise.sign_out_all_scopes ? sign_out : sign_out(scope)
redirect_for_sign_out(scope)
end
@@ -54,7 +54,7 @@ def devise_controller?
# Checks whether it's a devise mapped resource or not.
def is_devise_resource? #:nodoc:
- unknown_action!("Could not find devise mapping for #{request.fullpath}.") unless devise_mapping
+ unknown_action!("Could not find devise mapping for path #{request.fullpath.inspect}") unless devise_mapping
end
def unknown_action!(msg)
View
@@ -37,12 +37,12 @@ def self.find_scope!(duck)
Devise.mappings.each_value { |m| return m.name if duck.is_a?(m.to) }
end
- raise "Could not find a valid mapping for #{duck}"
+ raise "Could not find a valid mapping for #{duck.inspect}"
end
def self.find_by_path!(path, path_type=:fullpath)
Devise.mappings.each_value { |m| return m if path.include?(m.send(path_type)) }
- raise "Could not find a valid mapping for path #{path}"
+ raise "Could not find a valid mapping for path #{path.inspect}"
end
def initialize(name, options) #:nodoc:
@@ -3,6 +3,7 @@ def request
@request ||= ActionDispatch::Request.new(env)
end
+ # This is called internally by Warden on logout
def reset_session!
request.reset_session
end
@@ -119,6 +119,11 @@ def setup
@controller.sign_out(User.new)
end
+ test 'sign out without args proxy to sign out all scopes' do
+ @mock_warden.expects(:logout).with().returns(true)
+ @controller.sign_out
+ end
+
test 'sign out everybody proxy to logout on warden' do
@mock_warden.expects(:logout).with().returns(true)
@controller.sign_out_all_scopes

0 comments on commit b2496d1

Please sign in to comment.