scope_signed_in? helpers now simply delegate to current_scope to improve performance.

This commit is contained in:
José Valim 2010-07-19 14:06:48 +02:00
parent a36cb6e758
commit fefbf51c79
2 changed files with 5 additions and 5 deletions

View File

@ -42,7 +42,7 @@ module Devise
end
def #{mapping}_signed_in?
warden.authenticate?(:scope => :#{mapping})
!!current_#{mapping}
end
def current_#{mapping}

View File

@ -46,13 +46,13 @@ class ControllerAuthenticableTest < ActionController::TestCase
end
test 'proxy user_signed_in? to authenticate? with user scope' do
@mock_warden.expects(:authenticate?).with(:scope => :user)
@controller.user_signed_in?
@mock_warden.expects(:authenticate).with(:scope => :user).returns("user")
assert @controller.user_signed_in?
end
test 'proxy admin_signed_in? to authenticate? with admin scope' do
@mock_warden.expects(:authenticate?).with(:scope => :admin)
@controller.admin_signed_in?
@mock_warden.expects(:authenticate).with(:scope => :admin)
assert_not @controller.admin_signed_in?
end
test 'proxy user_session to session scope in warden' do