From bf40e59becbe8e1339e9cdd84ca8f58d3ff9d42f Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Bellet Date: Tue, 7 Jun 2022 16:06:49 +0200 Subject: [PATCH] Should link to order.distributor website - order: the order summary the customer is seeing on this page - current_order: the order is the customer is check-outing + add specs --- app/views/spree/orders/form/_update_buttons.html.haml | 2 +- spec/system/consumer/shopping/orders_spec.rb | 11 +++++++++++ 2 files changed, 12 insertions(+), 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 95818e67b3..35b9ceaee4 100644 --- a/app/views/spree/orders/form/_update_buttons.html.haml +++ b/app/views/spree/orders/form/_update_buttons.html.haml @@ -10,7 +10,7 @@ = t(:order_back_to_store) .columns.small-12.medium-6 - if @order.distributor.website.present? - = link_to_service "https://", current_order.distributor.website, class: "button expand" do + = link_to_service "https://", @order.distributor.website, class: "button expand" do = t(:order_back_to_website) - else   diff --git a/spec/system/consumer/shopping/orders_spec.rb b/spec/system/consumer/shopping/orders_spec.rb index c0e4489d3e..be3452d41b 100644 --- a/spec/system/consumer/shopping/orders_spec.rb +++ b/spec/system/consumer/shopping/orders_spec.rb @@ -56,6 +56,17 @@ describe "Order Management", js: true do visit order_path(order) expect(page).to be_confirmed_order_page end + + it "allows the user to see a link to distributor website when distributor has one" do + distributor.update!(website: "www.example.com") + visit order_path(order, order_token: order.token) + expect(page).to have_link "Back To Website", href: "https://www.example.com" + end + + it "doesn't show any link if the distributor doesn't have a website" do + visit order_path(order, order_token: order.token) + expect(page).not_to have_link "Back To Website" + end end context "when logged in as the customer" do