mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-01 02:03:22 +00:00
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:
@@ -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,
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user