From b0dd76518155d0fac92d3f950c585b8af96bf711 Mon Sep 17 00:00:00 2001 From: Rohan Mitchell Date: Thu, 23 Jul 2015 13:44:23 +1000 Subject: [PATCH] Add a blank row after summary row in all reports --- lib/open_food_network/order_grouper.rb | 7 ++++--- spec/features/admin/reports_spec.rb | 6 +++--- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/lib/open_food_network/order_grouper.rb b/lib/open_food_network/order_grouper.rb index c24d1069b8..9a556e689f 100644 --- a/lib/open_food_network/order_grouper.rb +++ b/lib/open_food_network/order_grouper.rb @@ -31,10 +31,11 @@ module OpenFoodNetwork rows = [] unless is_leaf_node(groups) groups.each do |key, group| - unless key == :summary_row - build_table(group).each { |g| rows << g } - else + if key == :summary_row rows << group[:columns].map { |cols| cols.call(group[:items]) } + rows << Array.new(group[:columns].count, '') + else + build_table(group).each { |g| rows << g } end end else diff --git a/spec/features/admin/reports_spec.rb b/spec/features/admin/reports_spec.rb index 503a52762e..f5cd9c1afa 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 == 5 # Totals row per order + all('table#listing_orders tbody tr').count.should == 7 # 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 == 4 # Totals row per supplier + all('table#listing_orders tbody tr').count.should == 5 # 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 == 2 # Two rows per order + all('table#listing_orders tbody tr').count.should == 3 # Three rows per order end end