1
0
Fork 0
mirror of https://github.com/aasm/aasm synced 2023-03-27 23:22:41 -04:00

Merge pull request #238 from PeerStreet/master

pass args to after_commit callbacks
This commit is contained in:
Thorsten Böttger 2015-06-16 10:00:44 +12:00
commit 44a17aa535
3 changed files with 6 additions and 6 deletions

View file

@ -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

View file

@ -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

View file

@ -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