mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
added product sorting
This commit is contained in:
@@ -31,7 +31,7 @@ class ExchangeProductsRenderer
|
||||
end
|
||||
|
||||
def supplied_products(enterprises_query_matcher)
|
||||
products_relation = Spree::Product.where(supplier_id: enterprises_query_matcher)
|
||||
products_relation = Spree::Product.where(supplier_id: enterprises_query_matcher).order(:name)
|
||||
|
||||
filter_visible(products_relation)
|
||||
end
|
||||
|
||||
@@ -14,6 +14,12 @@ describe ExchangeProductsRenderer do
|
||||
|
||||
expect(products.first.supplier.name).to eq exchange.variants.first.product.supplier.name
|
||||
end
|
||||
|
||||
it "loads products in order" do
|
||||
sorted_products_names = products.pluck(:name).sort
|
||||
|
||||
expect(products.pluck(:name)).to eq(sorted_products_names)
|
||||
end
|
||||
end
|
||||
|
||||
describe "for an outgoing exchange" do
|
||||
@@ -27,6 +33,12 @@ describe ExchangeProductsRenderer do
|
||||
expect(suppliers).to include products.second.supplier.name
|
||||
end
|
||||
|
||||
it "loads products in order" do
|
||||
sorted_products_names = products.pluck(:name).sort
|
||||
|
||||
expect(products.pluck(:name)).to eq(sorted_products_names)
|
||||
end
|
||||
|
||||
context "showing products from coordinator inventory only" do
|
||||
before { order_cycle.update prefers_product_selection_from_coordinator_inventory_only: true }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user