Move "order_cycle_supplier_totals" report type to constant

This commit is contained in:
Kristina Lim
2019-10-10 18:49:58 +08:00
parent 8bc1718978
commit 09f0f8c33f
3 changed files with 6 additions and 4 deletions

View File

@@ -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"
[

View File

@@ -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

View File

@@ -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