diff options
author | Lucas Mazza <lucastmazza@gmail.com> | 2014-04-22 23:37:13 -0500 |
---|---|---|
committer | Lucas Mazza <lucastmazza@gmail.com> | 2014-04-23 13:07:14 -0500 |
commit | 4866399054c9facf11bc743c0e0969e6c81f6c31 (patch) | |
tree | cd72a19b3b5f18894086e179461ecdadd0527d19 /activerecord | |
parent | d10e2ca9f199105849444b39f55d4922339d9c8d (diff) | |
download | rails-4866399054c9facf11bc743c0e0969e6c81f6c31.tar.gz rails-4866399054c9facf11bc743c0e0969e6c81f6c31.tar.bz2 rails-4866399054c9facf11bc743c0e0969e6c81f6c31.zip |
`ActiveRecord::Base.no_touching` no longer triggers callbacks or start empty transactions.
Closes #14841.
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/CHANGELOG.md | 6 | ||||
-rw-r--r-- | activerecord/lib/active_record/base.rb | 2 | ||||
-rw-r--r-- | activerecord/test/cases/timestamp_test.rb | 21 |
3 files changed, 27 insertions, 2 deletions
diff --git a/activerecord/CHANGELOG.md b/activerecord/CHANGELOG.md index cd47d0bbb4..da07633b03 100644 --- a/activerecord/CHANGELOG.md +++ b/activerecord/CHANGELOG.md @@ -1,3 +1,9 @@ +* `ActiveRecord::Base.no_touching` no longer triggers callbacks or start empty transactions. + + Fixes #14841. + + *Lucas Mazza* + * Fix name collision with `Array#select!` with `Relation#select!`. Fixes #14752. diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb index 1d47cba234..db4d5f0129 100644 --- a/activerecord/lib/active_record/base.rb +++ b/activerecord/lib/active_record/base.rb @@ -296,7 +296,6 @@ module ActiveRecord #:nodoc: include Core include Persistence - include NoTouching include ReadonlyAttributes include ModelSchema include Inheritance @@ -318,6 +317,7 @@ module ActiveRecord #:nodoc: include NestedAttributes include Aggregations include Transactions + include NoTouching include Reflection include Serialization include Store diff --git a/activerecord/test/cases/timestamp_test.rb b/activerecord/test/cases/timestamp_test.rb index 594b4fb07b..77ab427be0 100644 --- a/activerecord/test/cases/timestamp_test.rb +++ b/activerecord/test/cases/timestamp_test.rb @@ -112,7 +112,7 @@ class TimestampTest < ActiveRecord::TestCase previous_starting = task.starting previous_ending = task.ending task.touch(:starting, :ending) - + assert_not_equal previous_starting, task.starting assert_not_equal previous_ending, task.ending assert_in_delta Time.now, task.starting, 1 @@ -170,6 +170,25 @@ class TimestampTest < ActiveRecord::TestCase assert !@developer.no_touching? end + def test_no_touching_with_callbacks + klass = Class.new(ActiveRecord::Base) do + self.table_name = "developers" + + attr_accessor :after_touch_called + + after_touch do |user| + user.after_touch_called = true + end + end + + developer = klass.first + + klass.no_touching do + developer.touch + assert_not developer.after_touch_called + end + end + def test_saving_a_record_with_a_belongs_to_that_specifies_touching_the_parent_should_update_the_parent_updated_at pet = Pet.first owner = pet.owner |