I have the following method:
def track(user)
user.last_login_from_ip_address = request.env['REMOTE_ADDR']
user.last_login_at = Time.zone.now
user
end
and in my controller, I do this
track(user).save!
I also have the following test to make sure that the user is being tracked correctly:
before do
@user = create(:user, password: 'P@ssw0rd1', email: 'right@email.com', activation_state: 'active')
@user.activate!
end
it 'should change the last login time' do
post :authenticate, params
expect(@user.reload.last_login_at).not_to be_nil
end
until now, it was passing perfectly.
Now, I had to change the timezone in application.rb
as follows:
config.active_record.default_timezone = 'Europe/Berlin'
after I added this line, this test is now failing. there is no last_login_at
anymore set.
I found this behaviour very weird, and I have no idea what could be causing it