From 110d692ffaa739c5b38cb577924a82e13be10206 Mon Sep 17 00:00:00 2001 From: Cillian O'Ruanaidh Date: Fri, 18 Dec 2020 17:16:49 +0000 Subject: [PATCH] Include the 'Ready for' time for the order cycle in the Notify Producers Email This is so people can distinguish which order cycle the email is referring to. Fixes #6371 --- app/mailers/producer_mailer.rb | 1 + app/views/producer_mailer/order_cycle_report.html.haml | 2 +- app/views/producer_mailer/order_cycle_report.text.haml | 2 +- config/locales/en.yml | 2 +- spec/mailers/producer_mailer_spec.rb | 5 +++++ 5 files changed, 9 insertions(+), 3 deletions(-) diff --git a/app/mailers/producer_mailer.rb b/app/mailers/producer_mailer.rb index 5c61f2d0c8..1d2f801fd2 100644 --- a/app/mailers/producer_mailer.rb +++ b/app/mailers/producer_mailer.rb @@ -36,6 +36,7 @@ class ProducerMailer < Spree::BaseMailer line_items = line_items_from(@order_cycle, @producer) @grouped_line_items = line_items.group_by(&:product_and_full_name) + @ready_for = @order_cycle.pickup_time_for(@coordinator) @receival_instructions = @order_cycle.receival_instructions_for(@producer) @total = total_from_line_items(line_items) @tax_total = tax_total_from_line_items(line_items) diff --git a/app/views/producer_mailer/order_cycle_report.html.haml b/app/views/producer_mailer/order_cycle_report.html.haml index cc78f43ecd..e83e74cb4e 100644 --- a/app/views/producer_mailer/order_cycle_report.html.haml +++ b/app/views/producer_mailer/order_cycle_report.html.haml @@ -2,7 +2,7 @@ = t :producer_mail_greeting #{" " + @producer.name}, %p - = t :producer_mail_text_before + = t :producer_mail_text_before, ready_for: @ready_for - if @receival_instructions %p %b diff --git a/app/views/producer_mailer/order_cycle_report.text.haml b/app/views/producer_mailer/order_cycle_report.text.haml index c322c3cac5..e92ac8aa3d 100644 --- a/app/views/producer_mailer/order_cycle_report.text.haml +++ b/app/views/producer_mailer/order_cycle_report.text.haml @@ -1,6 +1,6 @@ #{t :producer_mail_greeting} #{@producer.name}, \ -= t :producer_mail_text_before += t :producer_mail_text_before, ready_for: @ready_for \ - if @receival_instructions = t :producer_mail_delivery_instructions diff --git a/config/locales/en.yml b/config/locales/en.yml index 3a4700a9f5..cc7b13d670 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1656,7 +1656,7 @@ See the %{link} to find out more about %{sitename}'s features and to start using mistakenly_sent: "Not sure why you have received this email? Please contact %{owner_email} for more information." producer_mail_greeting: "Dear" - producer_mail_text_before: "We now have all the consumer orders for the next food drop." + producer_mail_text_before: "Please find below an update about the order cycle ready for %{ready_for}." producer_mail_order_text: "Here is a summary of the orders for your products:" producer_mail_delivery_instructions: "Stock pickup/delivery instructions:" producer_mail_text_after: "" diff --git a/spec/mailers/producer_mailer_spec.rb b/spec/mailers/producer_mailer_spec.rb index c85a16273a..956f875853 100644 --- a/spec/mailers/producer_mailer_spec.rb +++ b/spec/mailers/producer_mailer_spec.rb @@ -23,6 +23,7 @@ describe ProducerMailer, type: :mailer do let(:p5) { create(:product, name: "Daffodil", price: 56.78, supplier: s1) } let(:order_cycle) { create(:simple_order_cycle) } let!(:incoming_exchange) { order_cycle.exchanges.create! sender: s1, receiver: d1, incoming: true, receival_instructions: 'Outside shed.' } + let!(:outgoing_exchange) { order_cycle.exchanges.create! sender: order_cycle.coordinator, receiver: order_cycle.coordinator, incoming: false, pickup_time: 'Tue, 23rd Dec' } let!(:order) do order = create(:order, distributor: d1, order_cycle: order_cycle, state: 'complete') @@ -55,6 +56,10 @@ describe ProducerMailer, type: :mailer do expect(mail.reply_to).to eq [order_cycle.coordinator.contact.email] end + it "includes the pickup time" do + expect(mail.body.encoded).to include 'Tue, 23rd Dec' + end + it "includes receival instructions" do expect(mail.body.encoded).to include 'Outside shed.' end