From 5b942e6933f2d00587acda8a2f771b2172a81519 Mon Sep 17 00:00:00 2001 From: Maikel Linke Date: Fri, 7 Feb 2020 15:49:26 +1100 Subject: [PATCH 1/5] Add spec for "continue shopping" from cart https://github.com/openfoodfoundation/openfoodnetwork/issues/4771 --- spec/features/consumer/shopping/cart_spec.rb | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/spec/features/consumer/shopping/cart_spec.rb b/spec/features/consumer/shopping/cart_spec.rb index 3f1d78c215..424ba45faa 100644 --- a/spec/features/consumer/shopping/cart_spec.rb +++ b/spec/features/consumer/shopping/cart_spec.rb @@ -20,6 +20,26 @@ feature "full-page cart", js: true do set_order order end + describe "continue shopping" do + it "shows a button leading back to the shop" do + # Set up a shopfront message to test that we are not going to the + # home tab. + # PENDING: this passes only without home tab! + #distributor.preferred_shopfront_message = "Test driven farming" + + add_product_to_cart order, product_with_fee, quantity: 2 + visit main_app.cart_path + + expect(page).to have_link "Continue shopping" + + click_link "Continue shopping" + + expect(page).to have_no_link "Continue shopping" + expect(page).to have_button "Edit your cart" + #expect(page).to have_no_content distributor.preferred_shopfront_message + end + end + describe "product description" do it "does not link to the product page" do add_product_to_cart order, product_with_fee, quantity: 2 From c64493ca7773708ac627118b8099bcff72dc0f31 Mon Sep 17 00:00:00 2001 From: Maikel Linke Date: Fri, 7 Feb 2020 16:10:19 +1100 Subject: [PATCH 2/5] Continue shopping with the products list --- app/helpers/shared_helper.rb | 4 ++++ app/views/spree/orders/form/_cart_links.html.haml | 2 +- spec/features/consumer/shopping/cart_spec.rb | 5 ++--- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/app/helpers/shared_helper.rb b/app/helpers/shared_helper.rb index a1e1f84ec2..2c9bb17990 100644 --- a/app/helpers/shared_helper.rb +++ b/app/helpers/shared_helper.rb @@ -16,4 +16,8 @@ module SharedHelper def admin_user? spree_current_user.andand.has_spree_role? 'admin' end + + def current_shop_products_path + "#{main_app.enterprise_shop_path(current_distributor)}#/shop" + end end diff --git a/app/views/spree/orders/form/_cart_links.html.haml b/app/views/spree/orders/form/_cart_links.html.haml index cec97a8a4d..d787b9c50f 100644 --- a/app/views/spree/orders/form/_cart_links.html.haml +++ b/app/views/spree/orders/form/_cart_links.html.haml @@ -1,6 +1,6 @@ .row.links{'data-hook' => "cart_buttons"} .columns.large-8{"data-hook" => ""} - %a.button.large.secondary{href: main_app.shop_path} + %a.button.large.secondary{href: current_shop_products_path} %i.ofn-i_008-caret-left = t :orders_edit_continue .columns.large-4.text-right diff --git a/spec/features/consumer/shopping/cart_spec.rb b/spec/features/consumer/shopping/cart_spec.rb index 424ba45faa..ace11e775a 100644 --- a/spec/features/consumer/shopping/cart_spec.rb +++ b/spec/features/consumer/shopping/cart_spec.rb @@ -24,8 +24,7 @@ feature "full-page cart", js: true do it "shows a button leading back to the shop" do # Set up a shopfront message to test that we are not going to the # home tab. - # PENDING: this passes only without home tab! - #distributor.preferred_shopfront_message = "Test driven farming" + distributor.preferred_shopfront_message = "Test driven farming" add_product_to_cart order, product_with_fee, quantity: 2 visit main_app.cart_path @@ -36,7 +35,7 @@ feature "full-page cart", js: true do expect(page).to have_no_link "Continue shopping" expect(page).to have_button "Edit your cart" - #expect(page).to have_no_content distributor.preferred_shopfront_message + expect(page).to have_no_content distributor.preferred_shopfront_message end end From 5fce40ee71826a7ca96b7a85c9ed7a8413673ba4 Mon Sep 17 00:00:00 2001 From: Maikel Linke Date: Tue, 18 Feb 2020 14:06:20 +1100 Subject: [PATCH 3/5] Link "Continue shopping" to products tab --- app/views/spree/orders/edit.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/spree/orders/edit.html.haml b/app/views/spree/orders/edit.html.haml index d8d8ec600c..56f4e03ef8 100644 --- a/app/views/spree/orders/edit.html.haml +++ b/app/views/spree/orders/edit.html.haml @@ -22,7 +22,7 @@ - if @order.line_items.empty? %div.row{"data-hook" => "empty_cart"} %p= t(:your_cart_is_empty) - %p= link_to t(:continue_shopping), main_app.shop_path, :class => 'button continue' + %p= link_to t(:continue_shopping), current_shop_products_path, :class => 'button continue' - else %div{"data-hook" => "outside_cart_form"} From 1db8283e98a4171c622d7198fdbace362868e0fa Mon Sep 17 00:00:00 2001 From: Maikel Linke Date: Wed, 11 Mar 2020 13:40:36 +1100 Subject: [PATCH 4/5] Link "Back To Store" button to products page --- app/views/spree/orders/form/_update_buttons.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/spree/orders/form/_update_buttons.html.haml b/app/views/spree/orders/form/_update_buttons.html.haml index a054165546..3a64a79a43 100644 --- a/app/views/spree/orders/form/_update_buttons.html.haml +++ b/app/views/spree/orders/form/_update_buttons.html.haml @@ -6,7 +6,7 @@ %i.ofn-i_008-caret-left = t(:order_back_to_cart) - else - = link_to main_app.shop_path, :class => "button expand" do + = link_to current_shop_products_path, :class => "button expand" do %i.ofn-i_008-caret-left = t(:order_back_to_store) - else From 6b8b3be5241649f30eb2b9c5ae23afd72c85f1e4 Mon Sep 17 00:00:00 2001 From: Maikel Linke Date: Wed, 11 Mar 2020 15:59:07 +1100 Subject: [PATCH 5/5] Show "Back To Store" button when no shop has been selected yet --- app/views/spree/orders/form/_update_buttons.html.haml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/views/spree/orders/form/_update_buttons.html.haml b/app/views/spree/orders/form/_update_buttons.html.haml index 3a64a79a43..22ede28e57 100644 --- a/app/views/spree/orders/form/_update_buttons.html.haml +++ b/app/views/spree/orders/form/_update_buttons.html.haml @@ -1,12 +1,12 @@ .row .columns.small-12.medium-3 - - if current_order.andand.distributor == @order.distributor - - if current_order.line_items.present? + - if current_order.nil? || current_order.distributor.nil? || current_order.distributor == @order.distributor + - if current_order&.line_items.present? = link_to main_app.cart_path, :class => "button expand" do %i.ofn-i_008-caret-left = t(:order_back_to_cart) - else - = link_to current_shop_products_path, :class => "button expand" do + = link_to "#{main_app.enterprise_shop_path(@order.distributor)}#/shop", class: "button expand" do %i.ofn-i_008-caret-left = t(:order_back_to_store) - else