From 13317347bb8db1f9e5ef715cab087098d253e6a3 Mon Sep 17 00:00:00 2001 From: Rohan Mitchell Date: Sat, 27 Oct 2012 12:19:44 +1100 Subject: [PATCH] Display an explanation message on product page when no distributor is selected --- .../stylesheets/store/openfoodweb.css.scss | 10 ++++++++++ .../add_distributor_details_to_product.rb | 4 ++++ app/views/distributors/_details.html.haml | 2 ++ spec/requests/consumer/product_spec.rb | 19 +++++++++++++++++++ 4 files changed, 35 insertions(+) create mode 100644 app/overrides/add_distributor_details_to_product.rb create mode 100644 app/views/distributors/_details.html.haml diff --git a/app/assets/stylesheets/store/openfoodweb.css.scss b/app/assets/stylesheets/store/openfoodweb.css.scss index a3cb0a29f1..06979bf3ea 100644 --- a/app/assets/stylesheets/store/openfoodweb.css.scss +++ b/app/assets/stylesheets/store/openfoodweb.css.scss @@ -144,6 +144,16 @@ ul.product-listing { } +/* Distributor details on product details page */ +#product-distributor-details { + float: right; +} + +#product-variants { + float: none; +} + + /* Add to cart form on product details page */ #cart-form { .error-distributor { diff --git a/app/overrides/add_distributor_details_to_product.rb b/app/overrides/add_distributor_details_to_product.rb new file mode 100644 index 0000000000..b107869e19 --- /dev/null +++ b/app/overrides/add_distributor_details_to_product.rb @@ -0,0 +1,4 @@ +Deface::Override.new(:virtual_path => "spree/products/show", + :insert_before => "[data-hook='cart_form']", + :partial => "distributors/details", + :name => "product_distributor_details") diff --git a/app/views/distributors/_details.html.haml b/app/views/distributors/_details.html.haml new file mode 100644 index 0000000000..6646588ef4 --- /dev/null +++ b/app/views/distributors/_details.html.haml @@ -0,0 +1,2 @@ +#product-distributor-details.columns.five.omega + When you select a distributor for your order, their address and pickup times will be displayed here. diff --git a/spec/requests/consumer/product_spec.rb b/spec/requests/consumer/product_spec.rb index 97712d1e13..368452ab54 100644 --- a/spec/requests/consumer/product_spec.rb +++ b/spec/requests/consumer/product_spec.rb @@ -22,4 +22,23 @@ feature %q{ page.should have_selector 'td', :text => d.name end + describe "viewing distributor details" do + context "without Javascript" do + it "displays a holding message when no distributor is selected" do + p = create(:product) + + visit spree.product_path p + + page.should have_selector '#product-distributor-details', :text => 'When you select a distributor for your order, their address and pickup times will be displayed here.' + end + + it "displays distributor details when one is selected" + end + + context "with Javascript" do + it "changes distributor details when the distributor is changed" + end + end + + end