Skip to content
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

[v4.1] Fix error added when resetting order flow on an empty order #5336

Merged
merged 1 commit into from
Aug 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -590,10 +590,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