mirror of
https://github.com/discourse/discourse.git
synced 2025-05-31 04:38:47 +08:00
Merge pull request #4148 from tgxworld/dont_reply_to_emails_that_are_autogenerated
FIX: Don't send rejection mailer to bounced emails.
This commit is contained in:
@ -136,10 +136,15 @@ describe Email::MessageBuilder do
|
||||
|
||||
context "header args" do
|
||||
|
||||
let(:message_with_header_args) { Email::MessageBuilder.new(to_address,
|
||||
body: 'hello world',
|
||||
topic_id: 1234,
|
||||
post_id: 4567) }
|
||||
let(:message_with_header_args) do
|
||||
Email::MessageBuilder.new(
|
||||
to_address,
|
||||
body: 'hello world',
|
||||
topic_id: 1234,
|
||||
post_id: 4567,
|
||||
mark_as_reply_to_auto_generated: true
|
||||
)
|
||||
end
|
||||
|
||||
it "passes through a post_id" do
|
||||
expect(message_with_header_args.header_args['X-Discourse-Post-Id']).to eq('4567')
|
||||
@ -149,6 +154,12 @@ describe Email::MessageBuilder do
|
||||
expect(message_with_header_args.header_args['X-Discourse-Topic-Id']).to eq('1234')
|
||||
end
|
||||
|
||||
it "marks the email as replying to an auto generated email" do
|
||||
expect(message_with_header_args.header_args[
|
||||
Email::MessageBuilder::REPLY_TO_AUTO_GENERATED_HEADER_KEY
|
||||
]).to eq(Email::MessageBuilder::REPLY_TO_AUTO_GENERATED_HEADER_VALUE)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
context "unsubscribe link" do
|
||||
|
@ -8,10 +8,6 @@ describe Email::Receiver do
|
||||
SiteSetting.reply_by_email_address = "reply+%{reply_key}@bar.com"
|
||||
end
|
||||
|
||||
def email(email_name)
|
||||
fixture_file("emails/#{email_name}.eml")
|
||||
end
|
||||
|
||||
def process(email_name)
|
||||
Email::Receiver.new(email(email_name)).process!
|
||||
end
|
||||
@ -54,6 +50,17 @@ describe Email::Receiver do
|
||||
expect { process(:bad_destinations) }.to raise_error(Email::Receiver::BadDestinationAddress)
|
||||
end
|
||||
|
||||
it "raises an BouncerEmailError when email is a bounced email" do
|
||||
expect { process(:bounced_email) }.to raise_error(Email::Receiver::BouncedEmailError)
|
||||
end
|
||||
|
||||
it "raises an AutoGeneratedEmailReplyError when email contains a reply marked
|
||||
as reply to an auto generated email".squish do
|
||||
|
||||
expect { process(:bounced_email_2) }
|
||||
.to raise_error(Email::Receiver::AutoGeneratedEmailReplyError)
|
||||
end
|
||||
|
||||
context "reply" do
|
||||
|
||||
let(:reply_key) { "4f97315cc828096c9cb34c6f1a0d6fe8" }
|
||||
|
Reference in New Issue
Block a user