Skip to content

Commit

Permalink
Make display_price optional on admin variants list
Browse files Browse the repository at this point in the history
When there are variants with not fully configured prices (e.g. because
they are being created) the product variants page breaks without the
admin really knowing why.
This allows for the variants list to be displayed anyway.
  • Loading branch information
luca-landa committed Nov 29, 2021
1 parent 76e2875 commit 41c9017
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion backend/app/views/spree/admin/variants/_table.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<% end %>
</td>
<td><%= variant.options_text %></td>
<td><%= variant.display_price.to_html %></td>
<td><%= variant.display_price&.to_html %></td>
<td><%= variant.sku %></td>
<td class="actions">
<% if can?(:update, variant) %>
Expand Down
12 changes: 12 additions & 0 deletions backend/spec/features/admin/products/variant_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,18 @@
expect(page).to have_content(discarded_variant.sku)
end
end

context 'displaying variants with unconfigured prices' do
let!(:variant) { create(:variant, sku: 'priceless_variant', product: product) }

before { variant.prices.delete_all }

it 'renders the listing correctly' do
visit spree.admin_product_variants_path(product)

expect(page).to have_content('priceless_variant')
end
end
end

context "editing existent variant" do
Expand Down

0 comments on commit 41c9017

Please sign in to comment.