提交 7c1f73c8 编写于 作者: D Dmitriy Kiriyenko 提交者: Jon Leighton

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

上级 050d6ef0
......@@ -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
......
......@@ -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"
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册