diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2014-03-27 16:10:17 -0500 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2014-03-27 18:18:45 -0300 |
commit | dd3ea17191e316aeebddaa7b176f6cfeee7a6365 (patch) | |
tree | 57fdbbafb1182664f4d2da8bb79e334b0a59bf9a /activerecord/test | |
parent | 5cf456a076034a03f645d7465e1ebd683bc06907 (diff) | |
download | rails-dd3ea17191e316aeebddaa7b176f6cfeee7a6365.tar.gz rails-dd3ea17191e316aeebddaa7b176f6cfeee7a6365.tar.bz2 rails-dd3ea17191e316aeebddaa7b176f6cfeee7a6365.zip |
Merge pull request #14469 from tiegz/timestamp_inheritance_fix
Swap Timestamp/Callbacks order in ActiveRecord::Base
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/cases/timestamp_test.rb | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/activerecord/test/cases/timestamp_test.rb b/activerecord/test/cases/timestamp_test.rb index 5308fa8808..594b4fb07b 100644 --- a/activerecord/test/cases/timestamp_test.rb +++ b/activerecord/test/cases/timestamp_test.rb @@ -71,6 +71,24 @@ class TimestampTest < ActiveRecord::TestCase assert_equal @previously_updated_at, @developer.updated_at end + def test_saving_when_callback_sets_record_timestamps_to_false_doesnt_update_its_timestamp + klass = Class.new(Developer) do + before_update :cancel_record_timestamps + def cancel_record_timestamps + self.record_timestamps = false + return true + end + end + + developer = klass.first + previously_updated_at = developer.updated_at + + developer.name = "New Name" + developer.save! + + assert_equal previously_updated_at, developer.updated_at + end + def test_touching_an_attribute_updates_timestamp previously_created_at = @developer.created_at @developer.touch(:created_at) |