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 displaying of discarded variants in admin #4148

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
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