Skip to content

Commit

Permalink
Merge pull request #5335 from solidusio/backport/v4.0/pr-5330
Browse files Browse the repository at this point in the history
[v4.0] Fix error added when resetting order flow on an empty order
  • Loading branch information
waiting-for-dev committed Aug 14, 2023
2 parents f13e438 + b24cb5e commit 7bd6f37
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion core/app/models/spree/order.rb
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,7 @@ def restart_checkout_flow
state: 'cart',
updated_at: Time.current
)
self.next
self.next if line_items.any?
end

def refresh_shipment_rates
Expand Down
9 changes: 8 additions & 1 deletion core/spec/models/spree/order_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -579,10 +579,17 @@ def merge!(other_order, user = nil)
end

context "without line items" do
let(:order) { create(:order, state: "delivery", line_items: []) }

it "updates the state column to cart" do
order = create(:order, state: "delivery")
expect{ order.restart_checkout_flow }.to change{ order.state }.from("delivery").to("cart")
end

it "doesn't add errors to the order" do
order.restart_checkout_flow

expect(order.errors).to be_empty
end
end
end

Expand Down

0 comments on commit 7bd6f37

Please sign in to comment.