Skip to content

Commit

Permalink
Merge pull request #5663 from solidusio/backport/v4.3/pr-5660
Browse files Browse the repository at this point in the history
[v4.3] Fix search by variant on stock items
  • Loading branch information
tvdeyen committed Apr 5, 2024
2 parents 06585a7 + 41f3c07 commit ce4b04c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
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

0 comments on commit ce4b04c

Please sign in to comment.