Skip to content

Commit

Permalink
Fix error when listing products without price
Browse files Browse the repository at this point in the history
  • Loading branch information
jhawthorn committed Feb 28, 2018
1 parent 20a2c01 commit 2d56479
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
8 changes: 5 additions & 3 deletions frontend/app/views/spree/shared/_products.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,11 @@
</div>
<%= link_to truncate(product.name, length: 50), url, class: 'info', itemprop: "name", title: product.name %>
<span itemprop="offers" itemscope itemtype="http:https://schema.org/Offer">
<span class="price selling" itemprop="price" content="<%= product.price_for(current_pricing_options).to_d %>">
<%= display_price(product) %>
</span>
<% if price = product.price_for(current_pricing_options) %>
<span class="price selling" itemprop="price" content="<%= price.to_d %>">
<%= price.to_html %>
</span>
<% end %>
<span itemprop="priceCurrency" content="<%= current_pricing_options.currency %>"></span>
</span>
<% end %>
Expand Down
8 changes: 8 additions & 0 deletions frontend/spec/features/products_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 2d56479

Please sign in to comment.