diff --git a/app/furniture/marketplace/order/mailer.rb b/app/furniture/marketplace/order/mailer.rb index 62f2e0711..ba3a04e54 100644 --- a/app/furniture/marketplace/order/mailer.rb +++ b/app/furniture/marketplace/order/mailer.rb @@ -6,7 +6,7 @@ class Mailer < ApplicationMailer def notification(order) @order = order - mail(to: to, + mail(to: to, reply_to: reply_to, subject: t(".subject", marketplace_name: order.marketplace_name, order_id: order.id)) end diff --git a/app/furniture/marketplace/order/placed_mailer.rb b/app/furniture/marketplace/order/placed_mailer.rb index 1cf4f0342..f02f90385 100644 --- a/app/furniture/marketplace/order/placed_mailer.rb +++ b/app/furniture/marketplace/order/placed_mailer.rb @@ -4,6 +4,10 @@ class PlacedMailer < Mailer def to order.contact_email end + + def reply_to + order.marketplace.notification_methods.map(&:contact_location) + end end end end diff --git a/app/furniture/marketplace/order/received_mailer.rb b/app/furniture/marketplace/order/received_mailer.rb index 949463147..dc18205fb 100644 --- a/app/furniture/marketplace/order/received_mailer.rb +++ b/app/furniture/marketplace/order/received_mailer.rb @@ -4,6 +4,10 @@ class ReceivedMailer < Mailer def to order.marketplace.notification_methods.map(&:contact_location) end + + def reply_to + order.contact_email + end end end end diff --git a/spec/furniture/marketplace/order/placed_mailer_spec.rb b/spec/furniture/marketplace/order/placed_mailer_spec.rb index ff807aef2..f2e2385b0 100644 --- a/spec/furniture/marketplace/order/placed_mailer_spec.rb +++ b/spec/furniture/marketplace/order/placed_mailer_spec.rb @@ -7,6 +7,11 @@ subject(:notification) { described_class.notification(order) } it { is_expected.to be_to([order.contact_email]) } + + it "replies to the marketplace's notification emails" do + expect(notification.reply_to).to eq(order.marketplace.notification_methods.map(&:contact_location)) + end + it { is_expected.to have_subject(t(".notification.subject", marketplace_name: order.marketplace_name, order_id: order.id)) } specify do diff --git a/spec/furniture/marketplace/order/received_mailer_spec.rb b/spec/furniture/marketplace/order/received_mailer_spec.rb index f20315f9e..cd42986b8 100644 --- a/spec/furniture/marketplace/order/received_mailer_spec.rb +++ b/spec/furniture/marketplace/order/received_mailer_spec.rb @@ -2,7 +2,7 @@ RSpec.describe Marketplace::Order::ReceivedMailer, type: :mailer do let(:marketplace) { create(:marketplace) } - let(:order) { build(:marketplace_order, placed_at: 1.hour.ago, marketplace: marketplace) } + let(:order) { build(:marketplace_order, placed_at: 1.hour.ago, marketplace: marketplace, contact_email: "shopper@example.com") } describe "#notification" do subject(:notification) { described_class.notification(order) } @@ -13,6 +13,10 @@ it { is_expected.to be_to(marketplace.notification_methods.map(&:contact_location)) } + it "sets the shopper as the reply to" do + expect(notification.reply_to).to eq(["shopper@example.com"]) + end + it { is_expected.to have_subject(t(".notification.subject", marketplace_name: order.marketplace_name, order_id: order.id)) } specify do