Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Do not use default_scope in ActiveRecord::Persistence#touch.

  • Loading branch information...
commit 7c1f73c843310a3dd0cee179f56ffdc7c859eaa0 1 parent 050d6ef
@dmitriy-kiriyenko dmitriy-kiriyenko authored jonleighton committed
View
2  activerecord/lib/active_record/persistence.rb
@@ -279,7 +279,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
View
9 activerecord/test/cases/timestamp_test.rb
@@ -40,6 +40,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"
Please sign in to comment.
Something went wrong with that request. Please try again.