1
0
Fork 0
mirror of https://github.com/heartcombo/devise.git synced 2022-11-09 12:18:31 -05:00

added test for update_tracked_fields method

This commit is contained in:
Kush Kella 2014-05-22 11:11:06 -07:00
parent 451be888cb
commit dd56dc7da6

View file

@ -10,4 +10,32 @@ class TrackableTest < ActiveSupport::TestCase
:sign_in_count :sign_in_count
] ]
end end
test 'update_tracked_fields should only set attributes but not save the record' do
user = create_user
request = mock
request.stubs(:remote_ip).returns("127.0.0.1")
assert_nil user.current_sign_in_ip
assert_nil user.last_sign_in_ip
assert_nil user.current_sign_in_at
assert_nil user.last_sign_in_at
assert_equal 0, user.sign_in_count
user.update_tracked_fields(request)
assert_equal "127.0.0.1", user.current_sign_in_ip
assert_equal "127.0.0.1", user.last_sign_in_ip
assert_not_nil user.current_sign_in_at
assert_not_nil user.last_sign_in_at
assert_equal 1, user.sign_in_count
user.reload
assert_nil user.current_sign_in_ip
assert_nil user.last_sign_in_ip
assert_nil user.current_sign_in_at
assert_nil user.last_sign_in_at
assert_equal 0, user.sign_in_count
end
end end