Skip to content

Commit

Permalink
Do not use default_scope in ActiveRecord::Persistence#touch.
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitriy-kiriyenko authored and jonleighton committed Sep 7, 2011
1 parent 3a3344a commit 4364157
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion activerecord/lib/active_record/persistence.rb
Expand Up @@ -242,7 +242,7 @@ def touch(name = nil)

@changed_attributes.except!(*changes.keys)
primary_key = self.class.primary_key
self.class.update_all(changes, { primary_key => self[primary_key] }) == 1
self.class.unscoped.update_all(changes, { primary_key => self[primary_key] }) == 1
end
end

Expand Down
9 changes: 9 additions & 0 deletions activerecord/test/cases/timestamp_test.rb
Expand Up @@ -66,6 +66,15 @@ def test_touching_a_record_updates_its_timestamp
assert_equal previous_salary, @developer.salary
end

def test_touching_a_record_with_default_scope_that_exludes_it_updates_its_timestamp
developer = @developer.becomes(DeveloperCalledJamis)

developer.touch
assert_not_equal @previously_updated_at, developer.updated_at
developer.reload
assert_not_equal @previously_updated_at, developer.updated_at
end

def test_saving_when_record_timestamps_is_false_doesnt_update_its_timestamp
Developer.record_timestamps = false
@developer.name = "John Smith"
Expand Down

0 comments on commit 4364157

Please sign in to comment.