diff --git a/config/locales/en.yml b/config/locales/en.yml index f676290ebe..9c7a55f749 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1530,7 +1530,6 @@ en: all_products: All products inventory: Inventory (on hand) lettuce_share: LettuceShare - mailing_list: Mailing List addresses: Addresses payment_methods: Payment Methods Report delivery: Delivery Report diff --git a/lib/reporting/reports/customers/mailing_list.rb b/lib/reporting/reports/customers/mailing_list.rb deleted file mode 100644 index b334ce93e0..0000000000 --- a/lib/reporting/reports/customers/mailing_list.rb +++ /dev/null @@ -1,29 +0,0 @@ -# frozen_string_literal: true - -module Reporting - module Reports - module Customers - class MailingList < Base - def query_result - super.group_by do |order| - { - email: order.email, - first_name: order.billing_address.firstname, - last_name: order.billing_address.lastname, - suburb: order.billing_address.city, - } - end.values.map(&:first) - end - - def columns - { - email: proc { |order| order.email }, - first_name: proc { |order| order.billing_address.firstname }, - last_name: proc { |order| order.billing_address.lastname }, - suburb: proc { |order| order.billing_address.city }, - } - end - end - end - end -end diff --git a/lib/reporting/reports/list.rb b/lib/reporting/reports/list.rb index c15742fbef..4e129ac3b8 100644 --- a/lib/reporting/reports/list.rb +++ b/lib/reporting/reports/list.rb @@ -55,7 +55,6 @@ module Reporting def customers_report_types [ - [i18n_translate("mailing_list"), :mailing_list], [i18n_translate("addresses"), :addresses] ] end diff --git a/spec/controllers/admin/reports_controller_spec.rb b/spec/controllers/admin/reports_controller_spec.rb index b7eff12bcb..25ebfff0ce 100644 --- a/spec/controllers/admin/reports_controller_spec.rb +++ b/spec/controllers/admin/reports_controller_spec.rb @@ -262,7 +262,6 @@ describe Admin::ReportsController, type: :controller do it "should have report types for customers" do expect(subject.reports[:customers]).to eq([ - ["Mailing List", :mailing_list], ["Addresses", :addresses] ]) end diff --git a/spec/lib/reports/customers_report_spec.rb b/spec/lib/reports/customers_report_spec.rb index 529664b97c..c54772aec0 100644 --- a/spec/lib/reports/customers_report_spec.rb +++ b/spec/lib/reports/customers_report_spec.rb @@ -14,51 +14,6 @@ module Reporting end subject { Base.new user, {} } - describe "mailing list report" do - subject { MailingList.new user, {} } - - it "returns headers for mailing_list" do - expect(subject.table_headers).to eq(["Email", "First Name", "Last Name", "Suburb"]) - end - - it "builds a table from a list of variants" do - order = double(:order, email: "test@test.com") - address = double(:billing_address, firstname: "Firsty", - lastname: "Lasty", city: "Suburbia") - allow(order).to receive(:billing_address).and_return address - allow(subject).to receive(:query_result).and_return [order] - - expect(subject.table_rows).to eq([[ - "test@test.com", "Firsty", "Lasty", "Suburbia" - ]]) - end - - context "when there are multiple orders for the same customer" do - let!(:address) { - create(:bill_address, firstname: "Firsty", - lastname: "Lasty", city: "Suburbia") - } - let!(:order1) { - create(:order_with_totals_and_distribution, :completed, bill_address: address) - } - let!(:order2) { - create(:order_with_totals_and_distribution, :completed, bill_address: address) - } - before do - [order1, order2].each do |order| - order.update!(email: "test@test.com") - end - end - it "returns only one row per customer" do - expect(subject.query_result).to match_array [order1] - expect(subject.table_rows.size).to eq(1) - expect(subject.table_rows).to eq([[ - "test@test.com", "Firsty", "Lasty", "Suburbia" - ]]) - end - end - end - describe "addresses report" do subject { Addresses.new user, {} } diff --git a/spec/system/admin/reports_spec.rb b/spec/system/admin/reports_spec.rb index 447e557e40..9e595d1250 100644 --- a/spec/system/admin/reports_spec.rb +++ b/spec/system/admin/reports_spec.rb @@ -39,12 +39,12 @@ describe ' it "can run the customers report" do login_as_admin visit admin_report_path( - report_type: :customers, report_subtype: :mailing_list + report_type: :customers, report_subtype: :addresses ) generate_report expect(page).to have_selector "#report-table" - expect(page).to have_content "EMAIL FIRST NAME" + expect(page).to have_content "FIRST NAME LAST NAME BILLING ADDRESS EMAIL" end it "renders UTF-8 characters" do @@ -64,18 +64,18 @@ describe ' # Run the report: login_as_admin visit admin_report_path( - report_type: :customers, report_subtype: :mailing_list + report_type: :customers, report_subtype: :addresses ) generate_report expect(page).to have_content "Späti" - expect(page).to have_content "EMAIL FIRST NAME" + expect(page).to have_content "FIRST NAME LAST NAME BILLING ADDRESS EMAIL" expect(page).to have_content "Müller" end it "displays a friendly timeout message and offers download" do login_as_admin visit admin_report_path( - report_type: :customers, report_subtype: :mailing_list + report_type: :customers, report_subtype: :addresses ) stub_const("ReportJob::NOTIFICATION_TIME", 0) @@ -113,7 +113,7 @@ describe ' it "allows the report to finish before the loading screen is rendered" do login_as_admin visit admin_report_path( - report_type: :customers, report_subtype: :mailing_list + report_type: :customers, report_subtype: :addresses ) # The controller wants to execute the ReportJob in the background. @@ -130,7 +130,7 @@ describe ' click_button "Go" expect(page).to have_selector "#report-table table" - expect(page).to have_content "EMAIL FIRST NAME" + expect(page).to have_content "FIRST NAME LAST NAME BILLING ADDRESS EMAIL" # Now that we see the report, we need to make sure that it's not replaced # by the "loading" spinner when the controller action finishes. @@ -154,17 +154,6 @@ describe ' visit admin_reports_path end - it "customers report" do - click_link "Mailing List" - click_button "Go" - - rows = find("table.report__table").all("thead tr") - table = rows.map { |r| r.all("th").map { |c| c.text.strip } } - expect(table.sort).to eq([ - ["Email", "First Name", "Last Name", "Suburb"].map(&:upcase) - ].sort) - end - it "customers report" do click_link "Addresses" click_button "Go"