Adding warden scopes to helper methods.

This commit is contained in:
Carlos A. da Silva
2009-10-10 16:47:11 -03:00
parent 4e263b96c9
commit 561833e060
4 changed files with 25 additions and 16 deletions

View File

@@ -6,6 +6,10 @@ class MockController < ApplicationController
def request
self
end
def path
''
end
end
class ControllerAuthenticableTest < ActionController::TestCase
@@ -29,6 +33,11 @@ class ControllerAuthenticableTest < ActionController::TestCase
@controller.authenticated?
end
test 'run authenticate? with scope on warden' do
@mock_warden.expects(:authenticated?).with(:my_scope).returns(true)
@controller.authenticated?(:my_scope)
end
test 'proxy logged_in? to authenticated' do
@mock_warden.expects(:authenticated?).returns(true)
@controller.logged_in?

View File

@@ -16,7 +16,7 @@ class AuthenticationTest < ActionController::IntegrationTest
assert_response :success
assert_template 'sessions/new'
assert_contain 'Invalid email or password'
assert !warden.authenticated?
assert !warden.authenticated?(:user)
end
test 'signing in with invalid pasword should return to sign in form with error message' do
@@ -44,7 +44,7 @@ class AuthenticationTest < ActionController::IntegrationTest
assert_template 'home/index'
assert_contain 'Signed in successfully'
assert_not_contain 'Sign In'
assert warden.authenticated?
assert warden.authenticated?(:user)
end
test 'not authenticated user should not be able to sign out' do
@@ -52,16 +52,16 @@ class AuthenticationTest < ActionController::IntegrationTest
assert_response :redirect
assert_redirected_to new_user_session_path
assert !warden.authenticated?
assert !warden.authenticated?(:user)
end
test 'authenticated user should be able to sign out' do
sign_in
assert warden.authenticated?
assert warden.authenticated?(:user)
delete 'users/session'
assert_response :redirect
assert_redirected_to new_user_session_path
assert !warden.authenticated?
assert !warden.authenticated?(:user)
end
end

View File

@@ -22,7 +22,7 @@ class PasswordRecoveryTest < ActionController::IntegrationTest
assert_response :redirect
assert_redirected_to root_path
assert warden.authenticated?
assert warden.authenticated?(:user)
end
test 'not authenticated user should be able to visit forgot password page' do
@@ -30,7 +30,7 @@ class PasswordRecoveryTest < ActionController::IntegrationTest
assert_response :success
assert_template 'passwords/new'
assert !warden.authenticated?
assert !warden.authenticated?(:user)
end
test 'not authenticated user should be able to request a forgot password' do
@@ -62,7 +62,7 @@ class PasswordRecoveryTest < ActionController::IntegrationTest
assert_response :redirect
assert_redirected_to root_path
assert warden.authenticated?
assert warden.authenticated?(:user)
end
test 'not authenticated with invalid perishable token should not be able to change his password' do