mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-02 21:57:17 +00:00
Merge pull request #9808 from abdellani/sort_items_by_product_name_in_ocstd_report
add sort by product name to order_cycle_supplier_totals_by_distributo…
This commit is contained in:
@@ -24,7 +24,8 @@ module Reporting
|
||||
header: true,
|
||||
},
|
||||
{
|
||||
group_by: proc { |line_items, _row| line_items.first.variant }
|
||||
group_by: proc { |line_items, _row| line_items.first.variant },
|
||||
sort_by: proc { |variant| variant.product.name }
|
||||
},
|
||||
{
|
||||
group_by: :hub,
|
||||
|
||||
@@ -9,7 +9,7 @@ module Reporting
|
||||
let!(:distributor) { create(:distributor_enterprise) }
|
||||
|
||||
let!(:order) do
|
||||
create(:completed_order_with_totals, line_items_count: 1, distributor: distributor)
|
||||
create(:completed_order_with_totals, line_items_count: 3, distributor: distributor)
|
||||
end
|
||||
|
||||
let(:current_user) { distributor.owner }
|
||||
@@ -23,7 +23,7 @@ module Reporting
|
||||
end
|
||||
|
||||
it "generates the report" do
|
||||
expect(report_table.length).to eq(2)
|
||||
expect(report_table.length).to eq(6)
|
||||
end
|
||||
|
||||
it "has a variant row under the distributor" do
|
||||
@@ -31,6 +31,14 @@ module Reporting
|
||||
expect(report.rows.first.producer).to eq supplier.name
|
||||
expect(report.rows.first.hub).to eq distributor.name
|
||||
end
|
||||
|
||||
it "lists products sorted by name" do
|
||||
order.line_items[0].variant.product.update(name: "Cucumber")
|
||||
order.line_items[1].variant.product.update(name: "Apple")
|
||||
order.line_items[2].variant.product.update(name: "Banane")
|
||||
product_names = report.rows.map(&:product).filter(&:present?)
|
||||
expect(product_names).to eq(["Apple", "Banane", "Cucumber"])
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user