Skip to content

Commit

Permalink
Marketplace: Set reply_to on Order::Mailers (#2644)
Browse files Browse the repository at this point in the history
- #2639

When I placed my order last week, the replies started going to
Convene Support, rather than the customer / seller.

This should reduce that happening.
  • Loading branch information
zspencer authored Oct 10, 2024
1 parent c8d1694 commit d62b3aa
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/furniture/marketplace/order/mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions app/furniture/marketplace/order/placed_mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 4 additions & 0 deletions app/furniture/marketplace/order/received_mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
5 changes: 5 additions & 0 deletions spec/furniture/marketplace/order/placed_mailer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion spec/furniture/marketplace/order/received_mailer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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: "[email protected]") }

describe "#notification" do
subject(:notification) { described_class.notification(order) }
Expand All @@ -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(["[email protected]"])
end

it { is_expected.to have_subject(t(".notification.subject", marketplace_name: order.marketplace_name, order_id: order.id)) }

specify do
Expand Down

0 comments on commit d62b3aa

Please sign in to comment.