mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-04 22:16:08 +00:00
Merge pull request #6268 from yihyang/master-yy-added-product-sorting
Sort products alphabetically in OC edit/create page
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,13 @@ describe ExchangeProductsRenderer do
|
||||
|
||||
expect(products.first.supplier.name).to eq exchange.variants.first.product.supplier.name
|
||||
end
|
||||
|
||||
it "loads products in order" do
|
||||
products = renderer.exchange_products(true, exchange.sender)
|
||||
sorted_products_names = products.map(&:name).sort
|
||||
|
||||
expect(products.map(&:name)).to eq(sorted_products_names)
|
||||
end
|
||||
end
|
||||
|
||||
describe "for an outgoing exchange" do
|
||||
@@ -27,6 +34,13 @@ describe ExchangeProductsRenderer do
|
||||
expect(suppliers).to include products.second.supplier.name
|
||||
end
|
||||
|
||||
it "loads products in order" do
|
||||
products = renderer.exchange_products(false, exchange.receiver)
|
||||
sorted_products_names = products.map(&:name).sort
|
||||
|
||||
expect(products.map(&: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