From 2d564792021e0674a5200c6812bce1c7c9b92e41 Mon Sep 17 00:00:00 2001 From: John Hawthorn Date: Tue, 27 Feb 2018 16:14:31 -0800 Subject: [PATCH] Fix error when listing products without price --- frontend/app/views/spree/shared/_products.html.erb | 8 +++++--- frontend/spec/features/products_spec.rb | 8 ++++++++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/frontend/app/views/spree/shared/_products.html.erb b/frontend/app/views/spree/shared/_products.html.erb index d4783affd9f..a52892e3c12 100644 --- a/frontend/app/views/spree/shared/_products.html.erb +++ b/frontend/app/views/spree/shared/_products.html.erb @@ -32,9 +32,11 @@ <%= link_to truncate(product.name, length: 50), url, class: 'info', itemprop: "name", title: product.name %> - - <%= display_price(product) %> - + <% if price = product.price_for(current_pricing_options) %> + + <%= price.to_html %> + + <% end %> <% end %> diff --git a/frontend/spec/features/products_spec.rb b/frontend/spec/features/products_spec.rb index 825bd1f394b..19aed176b08 100644 --- a/frontend/spec/features/products_spec.rb +++ b/frontend/spec/features/products_spec.rb @@ -270,6 +270,14 @@ expect(page).not_to have_content "add-to-cart-button" end + it "should be able to list products without a price" do + product = FactoryBot.create(:base_product, description: nil, name: 'Sample', price: '19.99') + Spree::Config.currency = "CAN" + Spree::Config.show_products_without_price = true + visit spree.products_path + expect(page).to have_content(product.name) + end + it "should return the correct title when displaying a single product" do product = Spree::Product.find_by(name: "Ruby on Rails Baseball Jersey") click_link product.name