diff options
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/cases/timestamp_test.rb | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/activerecord/test/cases/timestamp_test.rb b/activerecord/test/cases/timestamp_test.rb index 24b237a72b..6c3596347d 100644 --- a/activerecord/test/cases/timestamp_test.rb +++ b/activerecord/test/cases/timestamp_test.rb @@ -30,6 +30,24 @@ class TimestampTest < ActiveRecord::TestCase assert @previously_updated_at != @developer.updated_at end + def test_touching_a_record_updates_its_timestamp_even_if_object_instance_is_invalid + @developer.name = nil + @developer.touch + + assert @previously_updated_at != @developer.updated_at + end + + def test_touch_bang_a_record_updates_its_timestamp + @developer.touch! + + assert @previously_updated_at != @developer.updated_at + end + + def test_touch_banging_a_record_fails_if_object_instance_is_invalid + @developer.name = nil + assert_raise(ActiveRecord::RecordInvalid) { @developer.touch! } + end + def test_touching_a_different_attribute previously_created_at = @developer.created_at @developer.touch(:created_at) @@ -37,6 +55,13 @@ class TimestampTest < ActiveRecord::TestCase assert previously_created_at != @developer.created_at end + def test_touch_banging_a_different_attribute + previously_created_at = @developer.created_at + @developer.touch!(:created_at) + + assert previously_created_at != @developer.created_at + end + def test_saving_a_record_with_a_belongs_to_that_specifies_touching_the_parent_should_update_the_parent_updated_at pet = Pet.first owner = pet.owner |