From ea877e88401e97d35e3d64598b6bfb1dc247407b Mon Sep 17 00:00:00 2001 From: Evan Petrie Date: Mon, 15 Jun 2015 13:53:44 -0700 Subject: [PATCH] pass args to after_commit callbacks --- lib/aasm/persistence/active_record_persistence.rb | 2 +- spec/models/validator.rb | 8 ++++---- spec/unit/persistence/active_record_persistence_spec.rb | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/aasm/persistence/active_record_persistence.rb b/lib/aasm/persistence/active_record_persistence.rb index db84345..79a4ea6 100644 --- a/lib/aasm/persistence/active_record_persistence.rb +++ b/lib/aasm/persistence/active_record_persistence.rb @@ -176,7 +176,7 @@ module AASM if success && options[:persist] event = self.class.aasm.state_machine.events[name] - event.fire_callbacks(:after_commit, self) + event.fire_callbacks(:after_commit, self, *args) end success diff --git a/spec/models/validator.rb b/spec/models/validator.rb index 2da81ef..c23bd52 100644 --- a/spec/models/validator.rb +++ b/spec/models/validator.rb @@ -12,8 +12,8 @@ class Validator < ActiveRecord::Base transitions :to => :running, :from => :sleeping end event :sleep do - after_commit do - change_name_on_sleep + after_commit do |name| + change_name_on_sleep name end transitions :to => :sleeping, :from => :running end @@ -29,8 +29,8 @@ class Validator < ActiveRecord::Base save! end - def change_name_on_sleep - self.name = "sleeper" + def change_name_on_sleep name + self.name = name save! end diff --git a/spec/unit/persistence/active_record_persistence_spec.rb b/spec/unit/persistence/active_record_persistence_spec.rb index fc2e486..d4898bb 100644 --- a/spec/unit/persistence/active_record_persistence_spec.rb +++ b/spec/unit/persistence/active_record_persistence_spec.rb @@ -454,7 +454,7 @@ describe 'transitions with persistence' do expect(validator).to be_running expect(validator.name).to eq("name changed") - validator.sleep! + validator.sleep!("sleeper") expect(validator).to be_sleeping expect(validator.name).to eq("sleeper") end