aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/models
diff options
context:
space:
mode:
authorHarry Brundage <harry.brundage@gmail.com>2013-08-26 13:15:37 -0400
committerCarlos Antonio da Silva <carlosantoniodasilva@gmail.com>2014-01-16 09:05:59 -0200
commit177989c6c0bfaffbb9dbf034b3b01d6e3edf1429 (patch)
treeb11d50e60d48cd028ffbacfca34b5174a093301e /activerecord/test/models
parent38fcee3871b2d39cd8ad713b2e9130e52ebd8553 (diff)
downloadrails-177989c6c0bfaffbb9dbf034b3b01d6e3edf1429.tar.gz
rails-177989c6c0bfaffbb9dbf034b3b01d6e3edf1429.tar.bz2
rails-177989c6c0bfaffbb9dbf034b3b01d6e3edf1429.zip
Make AR::Base#touch fire the after_commit and after_rollback callbacks
Diffstat (limited to 'activerecord/test/models')
-rw-r--r--activerecord/test/models/car.rb1
-rw-r--r--activerecord/test/models/owner.rb17
2 files changed, 17 insertions, 1 deletions
diff --git a/activerecord/test/models/car.rb b/activerecord/test/models/car.rb
index c4a15a79e2..db0f93f63b 100644
--- a/activerecord/test/models/car.rb
+++ b/activerecord/test/models/car.rb
@@ -15,7 +15,6 @@ class Car < ActiveRecord::Base
scope :incl_engines, -> { includes(:engines) }
scope :order_using_new_style, -> { order('name asc') }
-
end
class CoolCar < Car
diff --git a/activerecord/test/models/owner.rb b/activerecord/test/models/owner.rb
index 1c7ed4aa3e..cf24502d3a 100644
--- a/activerecord/test/models/owner.rb
+++ b/activerecord/test/models/owner.rb
@@ -2,4 +2,21 @@ class Owner < ActiveRecord::Base
self.primary_key = :owner_id
has_many :pets, -> { order 'pets.name desc' }
has_many :toys, :through => :pets
+
+ after_commit :execute_blocks
+
+ def blocks
+ @blocks ||= []
+ end
+
+ def on_after_commit(&block)
+ blocks << block
+ end
+
+ def execute_blocks
+ blocks.each do |block|
+ block.call(self)
+ end
+ @blocks = []
+ end
end