Skip to content
This repository
Browse code

Allow instances to disable record_timestamps

  • Loading branch information...
commit 0d0176c4ffe5c58fd1002efbd8f7bd45a8872e33 1 parent a89d16b
Pratik authored October 26, 2011
2  activerecord/lib/active_record/timestamp.rb
@@ -33,7 +33,7 @@ module Timestamp
33 33
     extend ActiveSupport::Concern
34 34
 
35 35
     included do
36  
-      class_attribute :record_timestamps, :instance_writer => false
  36
+      class_attribute :record_timestamps
37 37
       self.record_timestamps = true
38 38
     end
39 39
 
10  activerecord/test/cases/timestamp_test.rb
@@ -60,6 +60,16 @@ def test_saving_when_record_timestamps_is_false_doesnt_update_its_timestamp
60 60
     Developer.record_timestamps = true
61 61
   end
62 62
 
  63
+  def test_saving_when_instance_record_timestamps_is_false_doesnt_update_its_timestamp
  64
+    @developer.record_timestamps = false
  65
+    assert Developer.record_timestamps
  66
+
  67
+    @developer.name = "John Smith"
  68
+    @developer.save!
  69
+
  70
+    assert_equal @previously_updated_at, @developer.updated_at
  71
+  end
  72
+
63 73
   def test_touching_an_attribute_updates_timestamp
64 74
     previously_created_at = @developer.created_at
65 75
     @developer.touch(:created_at)

1 note on commit 0d0176c

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