diff --git a/app/mailers/producer_mailer.rb b/app/mailers/producer_mailer.rb index e6abee7109..66a47d91c9 100644 --- a/app/mailers/producer_mailer.rb +++ b/app/mailers/producer_mailer.rb @@ -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, diff --git a/spec/mailers/producer_mailer_spec.rb b/spec/mailers/producer_mailer_spec.rb index d746fc44b5..e3a22d4ab2 100644 --- a/spec/mailers/producer_mailer_spec.rb +++ b/spec/mailers/producer_mailer_spec.rb @@ -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)