FIX: Allow sending test e-mails to any email address when disable_email is set to non-staff (#6792)

This commit is contained in:
Rishabh
2018-12-18 16:12:05 +01:00
committed by Régis Hanol
parent 32784ad11a
commit c279792130
5 changed files with 5 additions and 12 deletions
+3 -3
View File
@@ -27,10 +27,10 @@ describe Email::Sender do
context "disable_emails is enabled for non-staff users" do
before { SiteSetting.disable_emails = "non-staff" }
it "doesn't deliver mail to normal user" do
Mail::Message.any_instance.expects(:deliver_now).never
it "delivers mail to normal user" do
Mail::Message.any_instance.expects(:deliver_now).once
message = Mail::Message.new(to: user.email, body: "hello")
expect(Email::Sender.new(message, :hello).send).to eq(nil)
Email::Sender.new(message, :hello).send
end
it "delivers mail to staff user" do
+2 -2
View File
@@ -120,7 +120,7 @@ describe Admin::EmailController do
expect(incoming['sent_test_email_message']).to eq(I18n.t("admin.email.sent_test_disabled"))
end
it 'sends mail to staff only when setting is "non-staff"' do
it 'sends mail to everyone when setting is "non-staff"' do
SiteSetting.disable_emails = 'non-staff'
post "/admin/email/test.json", params: { email_address: admin.email }
@@ -129,7 +129,7 @@ describe Admin::EmailController do
post "/admin/email/test.json", params: { email_address: eviltrout.email }
incoming = JSON.parse(response.body)
expect(incoming['sent_test_email_message']).to eq(I18n.t("admin.email.sent_test_disabled_for_non_staff"))
expect(incoming['sent_test_email_message']).to eq(I18n.t("admin.email.sent_test"))
end
it 'sends mail to everyone when setting is "no"' do