Remove distinct to make proper ORDER BY

Update specs as well to test match array and test duplication by adding property2 to product1
This commit is contained in:
Jean-Baptiste Bellet
2022-04-12 17:02:20 +02:00
parent 96f267eefe
commit 3e5656e638
3 changed files with 7 additions and 5 deletions

View File

@@ -78,8 +78,7 @@ module Spree
where(producer_properties: { property_id: property_ids }).
or(
where(spree_product_properties: { property_id: property_ids })
).
distinct
)
}
delegate_belongs_to :master, :sku, :price, :currency, :display_amount, :display_price, :weight,

View File

@@ -63,12 +63,16 @@ module Api
end
context "with property filters" do
before do
product1.update!(properties: [property1, property2])
end
it "filters by product property" do
api_get :products, id: order_cycle.id, distributor: distributor.id,
q: { with_properties: [property1.id, property2.id] }
expect(response.status).to eq 200
expect(product_ids).to include product1.id, product2.id
expect(product_ids).to eq [product1.id, product2.id]
expect(product_ids).to_not include product3.id
end
@@ -87,7 +91,7 @@ module Api
q: { with_properties: [supplier_property.id] }
expect(response.status).to eq 200
expect(product_ids).to include product1.id, product2.id
expect(product_ids).to eq [product1.id, product2.id]
expect(product_ids).to_not include product3.id
end
end

View File

@@ -130,7 +130,6 @@ describe "As a consumer I want to view products", js: true do
toggle_filter property.presentation
end
pending("Closing issue #9046")
expect(page).to have_content variant.name.to_s
expect(page).not_to have_content variant2.name.to_s
end