Move Order #state_changed method out into Checkout concern (alongside order states logic)

This commit is contained in:
Matt-Yorkley
2023-06-05 20:03:11 +01:00
parent a62e51c0d0
commit 7c72969792
2 changed files with 13 additions and 13 deletions

View File

@@ -426,19 +426,6 @@ module Spree
restart_checkout_flow if state.in?(["payment", "confirmation"])
end
def state_changed(name)
state = "#{name}_state"
return unless persisted?
old_state = __send__("#{state}_was")
state_changes.create(
previous_state: old_state,
next_state: __send__(state),
name: name,
user_id: user_id
)
end
def shipped?
%w(partial shipped).include?(shipment_state)
end

View File

@@ -136,6 +136,19 @@ module Spree
)
end
def state_changed(name)
state = "#{name}_state"
return unless persisted?
old_state = __send__("#{state}_was")
state_changes.create(
previous_state: old_state,
next_state: __send__(state),
name: name,
user_id: user_id
)
end
private
def validate_payment_method!