diff --git a/lib/open_food_network/order_grouper.rb b/lib/open_food_network/order_grouper.rb index 9a556e689f..c24d1069b8 100644 --- a/lib/open_food_network/order_grouper.rb +++ b/lib/open_food_network/order_grouper.rb @@ -31,11 +31,10 @@ module OpenFoodNetwork rows = [] unless is_leaf_node(groups) groups.each do |key, group| - if key == :summary_row - rows << group[:columns].map { |cols| cols.call(group[:items]) } - rows << Array.new(group[:columns].count, '') - else + unless key == :summary_row build_table(group).each { |g| rows << g } + else + rows << group[:columns].map { |cols| cols.call(group[:items]) } end end else diff --git a/spec/features/admin/reports_spec.rb b/spec/features/admin/reports_spec.rb index f5cd9c1afa..503a52762e 100644 --- a/spec/features/admin/reports_spec.rb +++ b/spec/features/admin/reports_spec.rb @@ -124,7 +124,7 @@ feature %q{ table.sort.should == [ ["Hub", "Code", "First Name", "Last Name", "Supplier", "Product", "Variant", "Quantity", "TempControlled?"] ].sort - all('table#listing_orders tbody tr').count.should == 7 # Totals row per order + all('table#listing_orders tbody tr').count.should == 5 # Totals row per order end scenario "Pack By Supplier" do @@ -139,7 +139,7 @@ feature %q{ table.sort.should == [ ["Hub", "Supplier", "Code", "First Name", "Last Name", "Product", "Variant", "Quantity", "TempControlled?"] ].sort - all('table#listing_orders tbody tr').count.should == 5 # Totals row per supplier + all('table#listing_orders tbody tr').count.should == 4 # Totals row per supplier end end @@ -266,7 +266,7 @@ feature %q{ click_button 'Search' # Then I should see the rows for the first order but not the second - all('table#listing_orders tbody tr').count.should == 3 # Three rows per order + all('table#listing_orders tbody tr').count.should == 2 # Two rows per order end end