I have a controller which makes a test:
@first_login = (@user.sign_in_count == 1)
And I need to set it up with devise in the rspec spec:
I have tried the four ideas: In all of them user is created like: user = Factory(:member)
[see below for factory]
user.stubs(:sign_in_count).returns(1)
sign_in user
get 'index'
user.sign_in_count = 1
sign_in user # here user.sign_in_count == 1
get 'index' # here user.sign_in_count == 1
sign_in user
sign_in user
get 'index'
sign_in user
user.sign_in_count = 1
get 'index'
But every time in the controller, the devise specific user properties are zeroed/nil-ed out.
reset_password_token: nil, reset_password_sent_at: nil,
remember_created_at: nil, sign_in_count: 0, current_sign_in_at: nil,
last_sign_in_at: nil, current_sign_in_ip: nil, last_sign_in_ip: nil
Any ideas why?
[specs/factories.rb - factory_girl]
Factory.define :member, :class => User do |c|
c.password "a123456h"
c.first_name "Jack"
c.last_name "Lee"
c.email "[email protected]"
c.address_street "123 Main"
c.address_city "Anytown"
c.address_state "NV"
c.address_zip "40455"
c.address_country "USA"
c.when_account_created 2.days.ago
c.change_password_count 3
c.forgot_password_count 2
c.created_at 2.days.ago
c.updated_at 10.hours.ago
end