From 8b0c4ee0acacb3cc0c86f197acaa332f312c06b3 Mon Sep 17 00:00:00 2001 From: Maikel Linke Date: Wed, 15 Feb 2023 14:26:35 +1100 Subject: [PATCH] Add unit test for failing Enterprise Fee Summary I observed this data but I'm unsure about the root cause. It could be that the SQL query fetching this data needs tweaking to return the fee name in this case or it could be that it's not available (deleted). In any case, I thought I document what's happening and make this summarizer more robust before looking into the query. --- .../enterprise_fee_summary/summarizer_spec.rb | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 spec/lib/reports/enterprise_fee_summary/summarizer_spec.rb diff --git a/spec/lib/reports/enterprise_fee_summary/summarizer_spec.rb b/spec/lib/reports/enterprise_fee_summary/summarizer_spec.rb new file mode 100644 index 0000000000..ec041c2717 --- /dev/null +++ b/spec/lib/reports/enterprise_fee_summary/summarizer_spec.rb @@ -0,0 +1,45 @@ +# frozen_string_literal: true + +require "spec_helper" + +describe Reporting::Reports::EnterpriseFeeSummary::Summarizer do + let(:row) { + { + "total_amount" => 1, "payment_method_name" => nil, + "shipping_method_name" => nil, "hub_name" => "Kimchi Hub", + "enterprise_name" => nil, "fee_type" => nil, + "customer_name" => "Fermented Greens", + "customer_email" => "kimchi@example.com", "fee_name" => nil, + "tax_category_name" => nil, + "enterprise_fee_inherits_tax_category" => nil, + "product_tax_category_name" => nil, + "placement_enterprise_role" => nil, + "adjustment_adjustable_type" => nil, + "adjustment_source_distributor_name" => nil, + "incoming_exchange_enterprise_name" => nil, + "outgoing_exchange_enterprise_name" => nil, + "id" => nil + } + } + + it "represents a transaction fee" do + data = row.merge( + "payment_method_name" => "cash", + "adjustment_adjustable_type" => "Spree::Payment", + ) + summarizer = described_class.new(data) + expect(summarizer.fee_type).to eq "Payment Transaction" + end + + it "represents an enterprise fee without name" do + pending "Enterprise Fee Summary report fails #10395" + + data = row.merge( + "fee_name" => nil, + "placement_enterprise_role" => "coordinator", + "adjustment_adjustable_type" => "Spree::LineItem", + ) + summarizer = described_class.new(data) + expect(summarizer.fee_type).to eq nil + end +end