Skip to content

Commit

Permalink
Allow instances to disable record_timestamps
Browse files Browse the repository at this point in the history
  • Loading branch information
lifo committed Oct 26, 2011
1 parent a89d16b commit 0d0176c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion activerecord/lib/active_record/timestamp.rb
Expand Up @@ -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

Expand Down
10 changes: 10 additions & 0 deletions activerecord/test/cases/timestamp_test.rb
Expand Up @@ -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)
Expand Down

1 comment on commit 0d0176c

@benpickles
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yey

Please sign in to comment.