Skip to content

Commit

Permalink
Merge pull request #5334 from solidusio/backport/v3.4/pr-5330
Browse files Browse the repository at this point in the history
[v3.4] Fix error added when resetting order flow on an empty order
  • Loading branch information
waiting-for-dev authored Aug 14, 2023
2 parents 9830d55 + 710e3f9 commit 3a18bf6
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 @@ -534,7 +534,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 3a18bf6

Please sign in to comment.