Permalink
Browse files

Merge pull request #14842 from lucasmazza/lm-no-touching-callbacks

Move `NoTouching` down the inheritance chain on AR::Base
Conflicts:
	activerecord/test/cases/timestamp_test.rb
  • Loading branch information...
1 parent fda3653 commit c20fe8004e3be336484e31748c13a854523c252c @senny senny committed Apr 23, 2014
Showing with 26 additions and 1 deletion.
  1. +6 −0 activerecord/CHANGELOG.md
  2. +1 −1 activerecord/lib/active_record/base.rb
  3. +19 −0 activerecord/test/cases/timestamp_test.rb
@@ -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.
@@ -296,7 +296,6 @@ class Base
include Core
include Persistence
- include NoTouching
include ReadonlyAttributes
include ModelSchema
include Inheritance
@@ -318,6 +317,7 @@ class Base
include NestedAttributes
include Aggregations
include Transactions
+ include NoTouching
include Reflection
include Serialization
include Store
@@ -158,6 +158,25 @@ def test_no_touching_threadsafe
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

0 comments on commit c20fe80

Please sign in to comment.