Hi,
I am having trouble mocking authlogic from shoulda.
I have the following test fixture:
class HomeControllerTest < ActionController::TestCase
context "on GET to index" do
setup do
activate_authlogic
UserSession.stubs(:current_user).returns( user_session )
get :index
end
should respond_with :success
end
def user_session
@user_session.stubs(:user).returns(Factory.build(:user))
@user_session.stubs(:record)
@user_session
end
end
The problem is that the require_user method in ApplicationController is still not getting a current_user.
def current_user
puts "#{defined?(@current_user)}"
return @current_user if defined?(@current_user)
@current_user = current_user_session && current_user_session.record
end
def require_user
unless current_user
store_location
flash[:notice] = "You must be logged in to access this page"
redirect_to login_url
return false
end
end
Can anyone see what is wrong?
Cheers
Paul