mirror of
https://github.com/discourse/discourse.git
synced 2025-06-04 23:36:11 +08:00
FEATURE: add indication if incoming email attachment was rejected and inform sender about it (#6376)
* FEATURE: add indication if incoming email attachment was rejected and inform sender about it * include errors for rejected attachments in email * don't send warning email to staged users * use user object instead of user_id in add_attachments method
This commit is contained in:
@ -465,10 +465,24 @@ describe Email::Receiver do
|
||||
SiteSetting.authorized_extensions = "txt"
|
||||
expect { process(:attached_txt_file) }.to change { topic.posts.count }
|
||||
expect(topic.posts.last.raw).to match(/text\.txt/)
|
||||
end
|
||||
|
||||
SiteSetting.authorized_extensions = "csv"
|
||||
expect { process(:attached_txt_file_2) }.to change { topic.posts.count }
|
||||
expect(topic.posts.last.raw).to_not match(/text\.txt/)
|
||||
context "when attachment is rejected" do
|
||||
it "sends out the warning email" do
|
||||
expect { process(:attached_txt_file) }.to change { EmailLog.count }.by(1)
|
||||
expect(EmailLog.last.email_type).to eq("email_reject_attachment")
|
||||
end
|
||||
|
||||
it "doesn't send out the warning email if sender is staged user" do
|
||||
user.update_columns(staged: true)
|
||||
expect { process(:attached_txt_file) }.not_to change { EmailLog.count }
|
||||
end
|
||||
|
||||
it "creates the post with attachment missing message" do
|
||||
missing_attachment_regex = Regexp.escape(I18n.t('emails.incoming.missing_attachment', filename: "text.txt"))
|
||||
expect { process(:attached_txt_file) }.to change { topic.posts.count }
|
||||
expect(topic.posts.last.raw).to match(/#{missing_attachment_regex}/)
|
||||
end
|
||||
end
|
||||
|
||||
it "supports emails with just an attachment" do
|
||||
|
Reference in New Issue
Block a user