mirror of
https://github.com/ditkrg/workflower.git
synced 2026-01-22 22:26:40 +00:00
Sets workflow_transition_event_name attribute of the calling_model when reflection methods of events are called
This commit is contained in:
parent
0d135937c3
commit
47ee3ff006
@ -16,7 +16,7 @@ module Workflower
|
|||||||
# InstanceMethods
|
# InstanceMethods
|
||||||
module InstanceMethods
|
module InstanceMethods
|
||||||
# mattr_accessor :workflower_base
|
# mattr_accessor :workflower_base
|
||||||
attr_accessor :possible_events, :allowed_events, :allowed_transitions
|
attr_accessor :possible_events, :allowed_events, :allowed_transitions, :workflow_transition_event_name
|
||||||
|
|
||||||
def set_intial_state
|
def set_intial_state
|
||||||
write_attribute self.class.workflower_state_column_name, workflower_initial_state
|
write_attribute self.class.workflower_state_column_name, workflower_initial_state
|
||||||
@ -39,6 +39,7 @@ module Workflower
|
|||||||
|
|
||||||
@workflower_base.allowed_transitions.each do |flow|
|
@workflower_base.allowed_transitions.each do |flow|
|
||||||
define_singleton_method flow.trigger_action_name.to_s do
|
define_singleton_method flow.trigger_action_name.to_s do
|
||||||
|
write_attribute :workflow_transition_event_name, flow.event
|
||||||
@workflower_base.process_transition!(flow)
|
@workflower_base.process_transition!(flow)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -12,6 +12,7 @@ RSpec.describe Workflower do
|
|||||||
@test.workflower_initializer
|
@test.workflower_initializer
|
||||||
|
|
||||||
@test.submit!
|
@test.submit!
|
||||||
|
expect(@test.workflow_transition_event_name).to eq("submit")
|
||||||
expect(@test.workflow_state).to eq("submitted")
|
expect(@test.workflow_state).to eq("submitted")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user