Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Allow instances to disable record_timestamps

  • Loading branch information...
commit 0d0176c4ffe5c58fd1002efbd8f7bd45a8872e33 1 parent a89d16b
Pratik lifo authored
2  activerecord/lib/active_record/timestamp.rb
View
@@ -33,7 +33,7 @@ module Timestamp
extend ActiveSupport::Concern
included do
- class_attribute :record_timestamps, :instance_writer => false
+ class_attribute :record_timestamps
self.record_timestamps = true
end
10 activerecord/test/cases/timestamp_test.rb
View
@@ -60,6 +60,16 @@ def test_saving_when_record_timestamps_is_false_doesnt_update_its_timestamp
Developer.record_timestamps = true
end
+ def test_saving_when_instance_record_timestamps_is_false_doesnt_update_its_timestamp
+ @developer.record_timestamps = false
+ assert Developer.record_timestamps
+
+ @developer.name = "John Smith"
+ @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)

1 comment on commit 0d0176c

Please sign in to comment.
Something went wrong with that request. Please try again.