Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shipment transition callbacks being skipped #2066

Closed
skukx opened this issue Jul 6, 2017 · 1 comment
Closed

Shipment transition callbacks being skipped #2066

skukx opened this issue Jul 6, 2017 · 1 comment

Comments

@skukx
Copy link
Contributor

skukx commented Jul 6, 2017

Assume the below setup:

Spree::Shipment.class_eval do
  state_machine.after_transition to: :ready, do: :my_method

  def my_method
    puts 'my_method called'
  end
end

After an order is completed, Spree::Order#finalize! gets called.
See

shipments.each do |shipment|
shipment.update!(self)
shipment.finalize!
end

If the order is paid for then these shipments will be updated to ready. The problem is that this update skips callbacks so Spree::Shipment#my_method will not be called even though the shipment has transitioned to a state of ready.

Expected behavior would be that when the order moved to complete and updates the shipments. Each shipment that is updated to another state will create a transition event for that state change.

Solidus 2.2
Happens in Core Solidus

See #2065 for specs recreating behavior

@mamhoff
Copy link
Contributor

mamhoff commented Jul 8, 2017

This is a can of worms. We explicitly don't run the Shipment state machine, and rather determine the shipment's state by its attributes for performance and complexity reasons (the order and shipment state machine interact in strange ways).

You're right in that we should do one of two things: Either remove the shipment state machine entirely, or actually use it.

@solidusio solidusio locked and limited conversation to collaborators Sep 8, 2022
@waiting-for-dev waiting-for-dev converted this issue into discussion #4619 Sep 8, 2022

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants