From 78b22c4a823f6a3db72400c417ec09c442938da4 Mon Sep 17 00:00:00 2001 From: Bing Xie Date: Wed, 22 Jun 2016 14:54:06 +1000 Subject: [PATCH] Fix incorrectly aligned columns --- .../orders_and_fulfillments_report.rb | 1 + .../orders_and_fulfillments_report_spec.rb | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/lib/open_food_network/orders_and_fulfillments_report.rb b/lib/open_food_network/orders_and_fulfillments_report.rb index 089838a1b1..b4778a12aa 100644 --- a/lib/open_food_network/orders_and_fulfillments_report.rb +++ b/lib/open_food_network/orders_and_fulfillments_report.rb @@ -216,6 +216,7 @@ module OpenFoodNetwork proc { |line_items| "" }, proc { |line_items| "" }, proc { |line_items| "" }, + proc { |line_items| line_items.all? { |li| li.order.paid? } ? "Yes" : "No" }, proc { |line_items| line_items.first.order.shipping_method.andand.name }, proc { |line_items| rsa.call(line_items) ? 'Y' : 'N' }, diff --git a/spec/lib/open_food_network/orders_and_fulfillments_report_spec.rb b/spec/lib/open_food_network/orders_and_fulfillments_report_spec.rb index 55c8bd1197..f37dcefa02 100644 --- a/spec/lib/open_food_network/orders_and_fulfillments_report_spec.rb +++ b/spec/lib/open_food_network/orders_and_fulfillments_report_spec.rb @@ -93,5 +93,24 @@ module OpenFoodNetwork end end end + + describe "columns are aligned" do + let(:d1) { create(:distributor_enterprise) } + let(:oc1) { create(:simple_order_cycle) } + let(:o1) { create(:order, completed_at: 1.day.ago, order_cycle: oc1, distributor: d1) } + let(:li1) { build(:line_item) } + let(:user) { create(:admin_user)} + + before { o1.line_items << li1 } + + it 'has aligned columsn' do + report_types = ["", "order_cycle_supplier_totals", "order_cycle_supplier_totals_by_distributor", "order_cycle_distributor_totals_by_supplier", "order_cycle_customer_totals"] + + report_types.each do |report_type| + report = OrdersAndFulfillmentsReport.new user, report_type: report_type + report.header.size.should == report.columns.size + end + end + end end end