Delete Mailing List report

This commit is contained in:
Jean-Baptiste Bellet
2023-07-10 14:02:35 +02:00
committed by Filipe
parent c6c9cdca65
commit 5edc8d8ce1
6 changed files with 7 additions and 95 deletions

View File

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

View File

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

View File

@@ -55,7 +55,6 @@ module Reporting
def customers_report_types
[
[i18n_translate("mailing_list"), :mailing_list],
[i18n_translate("addresses"), :addresses]
]
end

View File

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

View File

@@ -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, {} }

View File

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