Reputation: 1032
I am using Devise with sentient_user Gem - https://github.com/bokmann/sentient_user. It works fine when I user the current_user in the model. The Problem is that my Rspec test are failing . In My Rspec test I have
describe MyModelWhereIUseCurrentUser do
include Devise::TestHelpers
before(:each) do
@user = Factory(:user)
sign_in @user
end
describe "current_user should work here" do
it "should do something" do
# Reference to MyModelWhereIUseCurrentUser and current_user is null there
end
end
end
Then in the describe block I called the model where I use current user. My Test Fails because current_user is nil. Did I not sign in the user correctly or the problem is in the sentient_user ?
Upvotes: 2
Views: 712
Reputation: 808
sentient_user adds a make_current
method, which can be called on User instance. Your problem can be fixed by adding @user.make_current
to before block.
Upvotes: 2