diff --git a/app/assets/stylesheets/store/openfoodweb.css.scss b/app/assets/stylesheets/store/openfoodweb.css.scss index 512ddd1790..7ee4a622ff 100644 --- a/app/assets/stylesheets/store/openfoodweb.css.scss +++ b/app/assets/stylesheets/store/openfoodweb.css.scss @@ -22,3 +22,13 @@ nav#filters { } } } + +/* Style the product source on the product details page in the + * same manner as the product properties table above it. + */ +#product-source { + @extend #product-properties; +} +#product-properties td, #product-source td { + width: 50%; +} diff --git a/app/overrides/add_source_to_product.rb b/app/overrides/add_source_to_product.rb new file mode 100644 index 0000000000..9229a278d9 --- /dev/null +++ b/app/overrides/add_source_to_product.rb @@ -0,0 +1,4 @@ +Deface::Override.new(:virtual_path => "spree/products/show", + :insert_bottom => "[data-hook='product_left_part_wrap']", + :partial => "spree/products/source", + :name => "product_source") diff --git a/app/views/spree/products/_source.html.haml b/app/views/spree/products/_source.html.haml new file mode 100644 index 0000000000..48ac00e756 --- /dev/null +++ b/app/views/spree/products/_source.html.haml @@ -0,0 +1,14 @@ +%div{:data-hook => "product_source"} + %h6.product-section-title Source + %table#product-source.table-display{:width => "100%"} + %tbody + - if @product.supplier + %tr.odd + %td + %strong Supplier + %td= @product.supplier.name + - @product.distributors.each do |distributor| + %tr.even + %td + %strong Distributor + %td= distributor.name diff --git a/spec/requests/consumer/product_spec.rb b/spec/requests/consumer/product_spec.rb new file mode 100644 index 0000000000..97712d1e13 --- /dev/null +++ b/spec/requests/consumer/product_spec.rb @@ -0,0 +1,25 @@ +require 'spec_helper' + +feature %q{ + As a consumer + I want to see products + So that I can shop +} do + include AuthenticationWorkflow + include WebHelper + + scenario "viewing a product shows its supplier and distributor" do + # Given a product with a supplier and distributor + s = create(:supplier) + d = create(:distributor) + p = create(:product, :supplier => s, :distributors => [d]) + + # When I view the product + visit spree.product_path p + + # Then I should see the product's supplier and distributor + page.should have_selector 'td', :text => s.name + page.should have_selector 'td', :text => d.name + end + +end