FEATURE: If PM email bounced for staged user then alert in whisper reply (#6648)

This commit is contained in:
Vinoth Kannan
2018-11-27 00:29:37 +05:30
committed by GitHub
parent 8bca2647ea
commit cedd2118c4
5 changed files with 95 additions and 25 deletions

View File

@ -103,12 +103,40 @@ describe Email::Receiver do
)
end
it "raises a BouncerEmailError when email is a bounced email" do
expect { process(:bounced_email) }.to raise_error(Email::Receiver::BouncedEmailError)
expect(IncomingEmail.last.is_bounce).to eq(true)
context "bounces" do
it "raises a BouncerEmailError" do
expect { process(:bounced_email) }.to raise_error(Email::Receiver::BouncedEmailError)
expect(IncomingEmail.last.is_bounce).to eq(true)
expect { process(:bounced_email_multiple_status_codes) }.to raise_error(Email::Receiver::BouncedEmailError)
expect(IncomingEmail.last.is_bounce).to eq(true)
expect { process(:bounced_email_multiple_status_codes) }.to raise_error(Email::Receiver::BouncedEmailError)
expect(IncomingEmail.last.is_bounce).to eq(true)
end
it "creates a whisper post in PM if user is staged" do
SiteSetting.enable_staged_users = true
SiteSetting.enable_whispers = true
email = "linux-admin@b-s-c.co.jp"
user = Fabricate(:staged, email: email)
private_message = Fabricate(:topic, archetype: 'private_message', category_id: nil, user: user)
private_message.allowed_users = [user]
private_message.save!
post = create_post(topic: private_message, user: user)
post_reply_key = begin
Fabricate(:post_reply_key,
reply_key: "4f97315cc828096c9cb34c6f1a0d6fe8",
user: user,
post: post
)
end
expect { process(:bounced_email) }.to raise_error(Email::Receiver::BouncedEmailError)
post = Post.last
expect(post.whisper?).to eq(true)
expect(post.raw).to eq(I18n.t("system_messages.email_bounced", email: email, raw: "Your email bounced").strip)
expect(IncomingEmail.last.is_bounce).to eq(true)
end
end
it "logs a blank error" do