diff options
author | Eileen M. Uchitelle <eileencodes@gmail.com> | 2015-02-18 17:54:18 -0500 |
---|---|---|
committer | Eileen M. Uchitelle <eileencodes@gmail.com> | 2015-02-18 17:54:18 -0500 |
commit | 83be86933d7faf43ff1717f4258d54fc72d3193c (patch) | |
tree | 42233473445bcde4274fa842dc104f4a98383431 /activerecord/test | |
parent | d0303d03a94994b7653c629f3cf1578c82a3eccf (diff) | |
parent | 219d71fb9049da677c9426c6d81bf9e74fae1977 (diff) | |
download | rails-83be86933d7faf43ff1717f4258d54fc72d3193c.tar.gz rails-83be86933d7faf43ff1717f4258d54fc72d3193c.tar.bz2 rails-83be86933d7faf43ff1717f4258d54fc72d3193c.zip |
Merge pull request #18956 from hjoo/time_option
Add `time` option to `#touch
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/cases/timestamp_test.rb | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/activerecord/test/cases/timestamp_test.rb b/activerecord/test/cases/timestamp_test.rb index db474c63a4..c0c62527df 100644 --- a/activerecord/test/cases/timestamp_test.rb +++ b/activerecord/test/cases/timestamp_test.rb @@ -73,6 +73,15 @@ class TimestampTest < ActiveRecord::TestCase assert_equal @previously_updated_at, @developer.updated_at end + def test_touching_updates_timestamp_with_given_time + previously_updated_at = @developer.updated_at + new_time = Time.utc(2015, 2, 16, 0, 0, 0) + @developer.touch(time: new_time) + + assert_not_equal previously_updated_at, @developer.updated_at + assert_equal new_time, @developer.updated_at + end + def test_touching_an_attribute_updates_timestamp previously_created_at = @developer.created_at @developer.touch(:created_at) @@ -91,6 +100,18 @@ class TimestampTest < ActiveRecord::TestCase assert_in_delta Time.now, task.ending, 1 end + def test_touching_an_attribute_updates_timestamp_with_given_time + previously_updated_at = @developer.updated_at + previously_created_at = @developer.created_at + new_time = Time.utc(2015, 2, 16, 4, 54, 0) + @developer.touch(:created_at, time: new_time) + + assert_not_equal previously_created_at, @developer.created_at + assert_not_equal previously_updated_at, @developer.updated_at + assert_equal new_time, @developer.created_at + assert_equal new_time, @developer.updated_at + end + def test_touching_many_attributes_updates_them task = Task.first previous_starting = task.starting |