diff options
author | Dmitriy Kiriyenko <dmitriy.kiriyenko@gmail.com> | 2011-06-06 10:30:05 +0300 |
---|---|---|
committer | Jon Leighton <j@jonathanleighton.com> | 2011-06-07 18:42:40 +0100 |
commit | 7c1f73c843310a3dd0cee179f56ffdc7c859eaa0 (patch) | |
tree | eac2cb33112b2a5f02172b138481dc3817f7e3cd | |
parent | 050d6ef060464427ae4ea559224c7040da268d5b (diff) | |
download | rails-7c1f73c843310a3dd0cee179f56ffdc7c859eaa0.tar.gz rails-7c1f73c843310a3dd0cee179f56ffdc7c859eaa0.tar.bz2 rails-7c1f73c843310a3dd0cee179f56ffdc7c859eaa0.zip |
Do not use default_scope in ActiveRecord::Persistence#touch.
-rw-r--r-- | activerecord/lib/active_record/persistence.rb | 2 | ||||
-rw-r--r-- | activerecord/test/cases/timestamp_test.rb | 9 |
2 files changed, 10 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/persistence.rb b/activerecord/lib/active_record/persistence.rb index 4ec0431b8c..367a1be4d9 100644 --- a/activerecord/lib/active_record/persistence.rb +++ b/activerecord/lib/active_record/persistence.rb @@ -279,7 +279,7 @@ module ActiveRecord @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 diff --git a/activerecord/test/cases/timestamp_test.rb b/activerecord/test/cases/timestamp_test.rb index ceb1452afd..c0f1b5895e 100644 --- a/activerecord/test/cases/timestamp_test.rb +++ b/activerecord/test/cases/timestamp_test.rb @@ -40,6 +40,15 @@ class TimestampTest < ActiveRecord::TestCase 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" |