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

[v4.3] Fix search by variant on stock items #5663

Merged
merged 2 commits into from
Apr 5, 2024
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def load_stock_management_data
def variant_scope
scope = Spree::Variant
.accessible_by(current_ability)
.distinct.order(:sku)
.distinct
.includes(
:images,
stock_items: :stock_location,
Expand Down
14 changes: 12 additions & 2 deletions backend/spec/features/admin/stock_items_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@
stub_authorization!

let(:admin_user) { create(:admin_user) }
let!(:variant_1) { create(:variant) }
let!(:variant_2) { create(:variant) }
let!(:variant_1) { create(:variant, product: product1) }
let!(:variant_2) { create(:variant, product: product2) }
let(:product1) { create(:product, name: 'Ruby Shirt') }
let(:product2) { create(:product, name: 'Solidus Shirt') }
let!(:stock_location) { create(:stock_location_without_variant_propagation) }

scenario 'User can add a new stock locations to any variant' do
Expand All @@ -19,4 +21,12 @@
end
expect(page).to have_content("Created successfully")
end

scenario 'searching by variant' do
visit spree.admin_stock_items_path
fill_in 'SKU or Option Value', with: 'Ruby'
click_on 'Filter Results'
expect(page).to have_content "Ruby Shirt"
expect(page).to_not have_content "Solidus Shirt"
end
end