From 09f0f8c33f5505bc970143f2544ac51937c06ab6 Mon Sep 17 00:00:00 2001 From: Kristina Lim Date: Thu, 10 Oct 2019 18:49:58 +0800 Subject: [PATCH] Move "order_cycle_supplier_totals" report type to constant --- lib/open_food_network/orders_and_fulfillments_report.rb | 6 +++--- .../supplier_totals_report.rb | 2 ++ .../supplier_totals_report_spec.rb | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/open_food_network/orders_and_fulfillments_report.rb b/lib/open_food_network/orders_and_fulfillments_report.rb index eb107140d7..a5e631ae05 100644 --- a/lib/open_food_network/orders_and_fulfillments_report.rb +++ b/lib/open_food_network/orders_and_fulfillments_report.rb @@ -17,7 +17,7 @@ module OpenFoodNetwork def header case options[:report_type] - when "order_cycle_supplier_totals" + when SupplierTotalsReport::REPORT_TYPE SupplierTotalsReport.new(self).header when "order_cycle_supplier_totals_by_distributor" [I18n.t(:report_header_producer), I18n.t(:report_header_product), I18n.t(:report_header_variant), I18n.t(:report_header_to_hub), @@ -57,7 +57,7 @@ module OpenFoodNetwork def rules case options[:report_type] - when "order_cycle_supplier_totals" + when SupplierTotalsReport::REPORT_TYPE SupplierTotalsReport.new(self).rules when "order_cycle_supplier_totals_by_distributor" [ @@ -192,7 +192,7 @@ module OpenFoodNetwork # the logic to compute the value for each cell. def columns case options[:report_type] - when "order_cycle_supplier_totals" + when SupplierTotalsReport::REPORT_TYPE SupplierTotalsReport.new(self).columns when "order_cycle_supplier_totals_by_distributor" [ diff --git a/lib/open_food_network/orders_and_fulfillments_report/supplier_totals_report.rb b/lib/open_food_network/orders_and_fulfillments_report/supplier_totals_report.rb index 80bc82b29f..3d1f5cef15 100644 --- a/lib/open_food_network/orders_and_fulfillments_report/supplier_totals_report.rb +++ b/lib/open_food_network/orders_and_fulfillments_report/supplier_totals_report.rb @@ -1,6 +1,8 @@ module OpenFoodNetwork class OrdersAndFulfillmentsReport class SupplierTotalsReport + REPORT_TYPE = "order_cycle_supplier_totals" + attr_reader :context delegate :supplier_name, :product_name, :line_items_name, :total_units, to: :context diff --git a/spec/lib/open_food_network/orders_and_fulfillments_report/supplier_totals_report_spec.rb b/spec/lib/open_food_network/orders_and_fulfillments_report/supplier_totals_report_spec.rb index 1c6e50581e..143bc953e5 100644 --- a/spec/lib/open_food_network/orders_and_fulfillments_report/supplier_totals_report_spec.rb +++ b/spec/lib/open_food_network/orders_and_fulfillments_report/supplier_totals_report_spec.rb @@ -11,7 +11,7 @@ RSpec.describe OpenFoodNetwork::OrdersAndFulfillmentsReport::SupplierTotalsRepor let(:permissions) { OpenFoodNetwork::Permissions.new(current_user) } let(:report) do - report_options = { report_type: "order_cycle_supplier_totals" } + report_options = { report_type: described_class::REPORT_TYPE } OpenFoodNetwork::OrdersAndFulfillmentsReport.new(permissions, report_options, true) end