Add phone and email fields to customer order summary in ProducerMailer

This commit is contained in:
Ahmed Ejaz
2025-06-15 20:07:27 +05:00
committed by Rachel Arnould
parent aabf3c861a
commit 5a13aa1c8a
3 changed files with 30 additions and 1 deletions

View File

@@ -92,6 +92,8 @@ class ProducerMailer < ApplicationMailer
quantity: line_item.quantity,
first_name: order.billing_address.first_name,
last_name: order.billing_address.last_name,
phone: order.billing_address.phone,
email: order.customer&.email,
business_name: customer_code,
order_number: order.number
}

View File

@@ -87,6 +87,11 @@
= t :business_name
%th.text-right
= t '.order_number'
- if @display_customer_names
%th.text-right
= t :phone
%th.text-right
= t :email
%tbody
- @customer_line_items.each do |line_item|
%tr
@@ -109,6 +114,11 @@
= line_item[:business_name]
%td
= line_item[:order_number]
- if @display_customer_names
%td
= line_item[:phone]
%td
= line_item[:email]
%p
= t :producer_mail_text_after
%p

View File

@@ -209,6 +209,21 @@ RSpec.describe ProducerMailer do
expect(table).to have_selector("th", text: "Last Name")
end
end
context "validate phone and email" do
let(:table_header) do
parsed_email.find("table.order-summary.customer-order thead")
end
it 'displays phone and email for the customer' do
expect(table_header).to have_selector("th", text: 'Phone') &
have_selector("th", text: 'Email')
expect(
parsed_email.find("table.order-summary.customer-order tbody tr")
).to have_selector("td", text: order.billing_address.phone) &
have_selector("td", text: order.customer.email)
end
end
end
context 'when flag show_customer_names_to_suppliers is false' do
@@ -216,10 +231,12 @@ RSpec.describe ProducerMailer do
order_cycle.coordinator.show_customer_names_to_suppliers = false
end
it "does not add customer names in the table" do
it "does not add customer names, phone and email in the table" do
parsed_email.find(".order-summary.customer-order").tap do |table|
expect(table).not_to have_selector("th", text: "First Name")
expect(table).not_to have_selector("th", text: "Last Name")
expect(table).not_to have_selector("th", text: "Phone")
expect(table).not_to have_selector("th", text: "Email")
end
end
end