-
Notifications
You must be signed in to change notification settings - Fork 521
Open
Description
Hi,
My after callbacks are no longer executed after upgrading from 1.1.2 to 1.2.0.
I confirmed that by rolling back to 1.1.2:
Following is the state machine with the after callback any => :active
state_machine :status, :initial => :draft do
state :draft, value: STATUS_DRAFT
state :active, value: STATUS_ACTIVE do
validate ->(agr) { agr.check_rules }
end
state :pending_org_approval, value: STATUS_PENDING_ORG_APPROVAL do
validates_presence_of :posting_rules
end
state :pending_cparty_approval, value: STATUS_PENDING_CPARTY_APPROVAL do
validates_presence_of :posting_rules
end
state :rejected_by_org, value: STATUS_REJECTED_BY_ORG do
validates_presence_of :posting_rules
end
state :rejected_by_cparty, value: STATUS_REJECTED_BY_CPARTY do
validates_presence_of :posting_rules
end
state :canceled, value: STATUS_CANCELED
state :replaced, value: STATUS_REPLACED
# create the accounts after activating the agreement
after_transition any => :active do |agreement, transition|
unless Account.where("organization_id = ? and accountable_id = ? and accountable_type = 'Organization'", agreement.organization_id, agreement.counterparty_id).present?
Account.create!(organization: agreement.organization, accountable: agreement.counterparty) if agreement.organization.subcontrax_member?
end
unless Account.where("organization_id = ? and accountable_id = ? and accountable_type = 'Organization'", agreement.counterparty_id, agreement.organization_id).present?
Account.create!(organization: agreement.counterparty, accountable: agreement.organization) if agreement.counterparty.subcontrax_member?
end
end
event :submit_for_approval do
transition :draft => :pending_cparty_approval, if: ->(agreement) { agreement.creator.organization == agreement.organization && agreement.counterparty.subcontrax_member? }
transition :draft => :pending_org_approval, if: ->(agreement) { agreement.creator.organization == agreement.counterparty && agreement.organization.subcontrax_member? }
end
event :activate do
transition :draft => :active, if: ->(agreement) { !agreement.organization.subcontrax_member? }
transition :draft => :active, if: ->(agreement) { !agreement.counterparty.subcontrax_member? }
end
event :submit_change do
transition [:pending_org_approval, :rejected_by_cparty] => :pending_cparty_approval
transition [:pending_cparty_approval, :rejected_by_org] => :pending_org_approval
end
event :accept do
transition [:pending_org_approval, :pending_cparty_approval] => :active
end
event :reject do
transition :pending_org_approval => :rejected_by_org
transition :pending_cparty_approval => :rejected_by_cparty
end
event :cancel do
transition :active => :canceled
end
endMetadata
Metadata
Assignees
Labels
No labels