From 0c879dc4c9450818100237c23f0d84a5acf902b4 Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Wed, 15 Sep 2021 10:54:59 +0100 Subject: [PATCH] Fix order_path issue in cart page The order_path route wasn't being inferred correctly from this Spree controller, causing errors to be thrown in the cart page if the number of editable orders was precisely one: ActionView::Template::Error: undefined method `order_path' --- app/helpers/spree/orders_helper.rb | 2 +- spec/features/consumer/shopping/cart_spec.rb | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/app/helpers/spree/orders_helper.rb b/app/helpers/spree/orders_helper.rb index 268d1876c1..06b20e70c0 100644 --- a/app/helpers/spree/orders_helper.rb +++ b/app/helpers/spree/orders_helper.rb @@ -30,7 +30,7 @@ module Spree end def changeable_orders_link_path - changeable_orders.one? ? order_path(changeable_orders.first) : spree.account_path + changeable_orders.one? ? main_app.order_path(changeable_orders.first) : spree.account_path end def shop_changeable_orders_alert_html diff --git a/spec/features/consumer/shopping/cart_spec.rb b/spec/features/consumer/shopping/cart_spec.rb index 0a7ffdb8a1..d041f5fdc7 100644 --- a/spec/features/consumer/shopping/cart_spec.rb +++ b/spec/features/consumer/shopping/cart_spec.rb @@ -315,6 +315,16 @@ feature "full-page cart", js: true do expect(page).to have_no_content item1.variant.name expect(page).to have_content item2.variant.name end + + context "with a single editable order" do # Regression test for #8191 + before do + prev_order2.destroy + end + + it "doesn't throw an error" do + expect{ visit main_app.cart_path }.to_not raise_error + end + end end end end