Use sign_in and authenticate methods.

This commit is contained in:
José Valim
2009-10-18 15:01:56 -02:00
parent 9051d842c0
commit b0a2da72b5
7 changed files with 34 additions and 37 deletions

View File

@@ -54,12 +54,12 @@ class ControllerAuthenticableTest < ActionController::TestCase
test 'proxy user_authenticate! to authenticate with user scope' do
@mock_warden.expects(:authenticate!).with(:scope => :user)
@controller.sign_in_user!
@controller.authenticate_user!
end
test 'proxy admin_authenticate! to authenticate with admin scope' do
@mock_warden.expects(:authenticate!).with(:scope => :admin)
@controller.sign_in_admin!
@controller.authenticate_admin!
end
test 'proxy user_authenticated? to authenticate with user scope' do
@@ -90,8 +90,7 @@ class ControllerAuthenticableTest < ActionController::TestCase
end
test 'sign in automatically proxy to set user on warden' do
user = OpenStruct.new
@mock_warden.expects(:set_user).with(user, :scope => :user).returns(true)
@controller.sign_in_automatically(user, :user)
@mock_warden.expects(:set_user).with(user = mock, :scope => :user).returns(true)
@controller.sign_in(:user, user)
end
end

View File

@@ -1,5 +1,5 @@
class AdminsController < ApplicationController
before_filter :sign_in_admin!
before_filter :authenticate_admin!
def index
end

View File

@@ -1,5 +1,5 @@
class UsersController < ApplicationController
before_filter :sign_in_user!
before_filter :authenticate_user!
def index
user_session[:cart] = "Cart"