Skip to content

Commit

Permalink
Merge pull request #4148 from luca-landa/fix-admin-discarded-variants…
Browse files Browse the repository at this point in the history
…-displaying

Fix displaying of discarded variants in admin
  • Loading branch information
kennyadsl authored Sep 1, 2021
2 parents 3b0b76b + 9dba25e commit bac2368
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</div>
</div>

<% if product.variants.discarded.any? %>
<% if product.variants.with_discarded.discarded.any? %>
<div class="col-2">
<div class="field checkbox">
<label>
Expand Down
2 changes: 1 addition & 1 deletion backend/app/views/spree/admin/variants/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<% end %>
<% end %>

<% if @variants.any? || @product.variants.discarded.any? %>
<% if @product.variants.with_discarded.any? %>
<%= render "table_filter", product: @product %>
<%= render "table", variants: @variants %>
<% else %>
Expand Down
22 changes: 22 additions & 0 deletions backend/spec/features/admin/products/variant_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,28 @@
end
end
end

context 'displaying discarded variants' do
let!(:existing_variant) { create(:variant, sku: 'existing_variant_sku', product: product) }
let!(:discarded_variant) { create(:variant, sku: 'discarded_variant_sku', product: product) }

before { discarded_variant.discard! }

it 'does not display deleted variants by default' do
visit spree.admin_product_variants_path(product)

expect(page).to have_content(existing_variant.sku)
expect(page).not_to have_content(discarded_variant.sku)
end

it 'allows to display deleted variants with a filter' do
visit spree.admin_product_variants_path(product)
check 'Show Deleted Variants'
click_button 'search'

expect(page).to have_content(discarded_variant.sku)
end
end
end

context "editing existent variant" do
Expand Down

0 comments on commit bac2368

Please sign in to comment.