Customer Information on mail show be displayed depending on order cycle coordinator's customer names flag

This commit is contained in:
vishaldeepak
2021-09-02 18:59:11 +05:30
parent 813deb49a4
commit b13b2b9b95
2 changed files with 7 additions and 3 deletions

View File

@@ -77,7 +77,7 @@ class ProducerMailer < Spree::BaseMailer
end
def set_customer_data(line_items)
return unless @producer.preferred_show_customer_names_to_suppliers
return unless @coordinator.preferred_show_customer_names_to_suppliers
line_items.map do |line_item|
{
sku: line_item.variant.sku,

View File

@@ -129,7 +129,9 @@ describe ProducerMailer, type: :mailer do
end
context 'when flag preferred_show_customer_names_to_suppliers is true' do
let(:s1) { create(:supplier_enterprise, preferred_show_customer_names_to_suppliers: true) }
before do
order_cycle.coordinator.set_preference(:show_customer_names_to_suppliers, true)
end
it "adds customer names table" do
expect(body_as_html(mail).find(".order-summary.customer-order")).to_not be_nil
@@ -155,7 +157,9 @@ describe ProducerMailer, type: :mailer do
end
context 'when flag preferred_show_customer_names_to_suppliers is false' do
let(:s1) { create(:supplier_enterprise, preferred_show_customer_names_to_suppliers: false) }
before do
order_cycle.coordinator.set_preference(:show_customer_names_to_suppliers, false)
end
it "does not add customer names table" do
expect { body_as_html(mail).find(".order-summary.customer-order") }.to raise_error(Capybara::ElementNotFound)