Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix error when listing products without price #2605

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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://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