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] if success && options[:persist]
event = self.class.aasm.state_machine.events[name] event = self.class.aasm.state_machine.events[name]
event.fire_callbacks(:after_commit, self) event.fire_callbacks(:after_commit, self, *args)
end end
success success

View file

@ -12,8 +12,8 @@ class Validator < ActiveRecord::Base
transitions :to => :running, :from => :sleeping transitions :to => :running, :from => :sleeping
end end
event :sleep do event :sleep do
after_commit do after_commit do |name|
change_name_on_sleep change_name_on_sleep name
end end
transitions :to => :sleeping, :from => :running transitions :to => :sleeping, :from => :running
end end
@ -29,8 +29,8 @@ class Validator < ActiveRecord::Base
save! save!
end end
def change_name_on_sleep def change_name_on_sleep name
self.name = "sleeper" self.name = name
save! save!
end end

View file

@ -454,7 +454,7 @@ describe 'transitions with persistence' do
expect(validator).to be_running expect(validator).to be_running
expect(validator.name).to eq("name changed") expect(validator.name).to eq("name changed")
validator.sleep! validator.sleep!("sleeper")
expect(validator).to be_sleeping expect(validator).to be_sleeping
expect(validator.name).to eq("sleeper") expect(validator.name).to eq("sleeper")
end end