diff options
Diffstat (limited to 'activerecord/test/cases/timestamp_test.rb')
-rw-r--r-- | activerecord/test/cases/timestamp_test.rb | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/activerecord/test/cases/timestamp_test.rb b/activerecord/test/cases/timestamp_test.rb index fce27d8972..db7accfc40 100644 --- a/activerecord/test/cases/timestamp_test.rb +++ b/activerecord/test/cases/timestamp_test.rb @@ -3,13 +3,15 @@ require 'models/developer' require 'models/owner' require 'models/pet' require 'models/toy' +require 'models/car' class TimestampTest < ActiveRecord::TestCase - fixtures :developers, :owners, :pets, :toys + fixtures :developers, :owners, :pets, :toys, :cars def setup @developer = Developer.first @previously_updated_at = @developer.updated_at + @car = Car.first end def test_saving_a_changed_record_updates_its_timestamp @@ -38,6 +40,16 @@ class TimestampTest < ActiveRecord::TestCase assert_equal previous_salary, @developer.salary end + def test_saving_when_record_timestamps_is_false_doesnt_update_its_timestamp + Developer.record_timestamps = false + @developer.name = "John Smith" + @developer.save! + + assert_equal @previously_updated_at, @developer.updated_at + ensure + Developer.record_timestamps = true + end + def test_touching_a_different_attribute previously_created_at = @developer.created_at @developer.touch(:created_at) @@ -48,6 +60,10 @@ class TimestampTest < ActiveRecord::TestCase assert_not_equal @previously_updated_at, @developer.updated_at end + def test_touch_a_record_without_timestamps + assert_nothing_raised { @car.touch } + 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 |