FIX: allow an admin to click on blank errors (#5027)

* FIX: allow an admin to click on blank errors

* i18nlize strings

* what would a rails master do?
This commit is contained in:
Leo McArdle
2017-08-04 19:04:26 +01:00
committed by Régis Hanol
parent a3ef814245
commit a7b7fe335f
6 changed files with 28 additions and 4 deletions

View File

@ -16,7 +16,7 @@ class IncomingEmailDetailsSerializer < ApplicationSerializer
EMAIL_RECEIVER_ERROR_PREFIX = "Email::Receiver::".freeze EMAIL_RECEIVER_ERROR_PREFIX = "Email::Receiver::".freeze
def error def error
@error_string @error_string.presence || I18n.t("emails.incoming.unrecognized_error")
end end
def error_description def error_description

View File

@ -29,4 +29,8 @@ class IncomingEmailSerializer < ApplicationSerializer
object.cc_addresses.split(";") object.cc_addresses.split(";")
end end
def error
@object.error.presence || I18n.t("emails.incoming.unrecognized_error")
end
end end

View File

@ -78,6 +78,7 @@ en:
topic_closed_error: "Happens when a reply came in but the related topic has been closed." topic_closed_error: "Happens when a reply came in but the related topic has been closed."
bounced_email_error: "Email is a bounced email report." bounced_email_error: "Email is a bounced email report."
screened_email_error: "Happens when the sender's email address was already screened." screened_email_error: "Happens when the sender's email address was already screened."
unrecognized_error: "Unrecognized Error"
errors: &errors errors: &errors
format: ! '%{attribute} %{message}' format: ! '%{attribute} %{message}'

View File

@ -66,9 +66,9 @@ describe Email::Processor do
Rails.logger.expects(:error) Rails.logger.expects(:error)
Email::Processor.process!(mail) Email::Processor.process!(mail)
expect(IncomingEmail.first.error).to eq("boom") expect(IncomingEmail.last.error).to eq("boom")
expect(IncomingEmail.first.rejection_message).to be_present expect(IncomingEmail.last.rejection_message).to be_present
expect(EmailLog.first.email_type).to eq("email_reject_unrecognized_error") expect(EmailLog.last.email_type).to eq("email_reject_unrecognized_error")
end end
it "sends more than one rejection email per day" do it "sends more than one rejection email per day" do

View File

@ -81,4 +81,22 @@ describe Admin::EmailController do
end end
end end
context '.rejected' do
it 'should provide a string for a blank error' do
Fabricate(:incoming_email, error: "")
xhr :get, :rejected
rejected = JSON.parse(response.body)
expect(rejected.first['error']).to eq(I18n.t("emails.incoming.unrecognized_error"))
end
end
context '.incoming' do
it 'should provide a string for a blank error' do
incoming_email = Fabricate(:incoming_email, error: "")
xhr :get, :incoming, id: incoming_email.id
incoming = JSON.parse(response.body)
expect(incoming['error']).to eq(I18n.t("emails.incoming.unrecognized_error"))
end
end
end end

View File

@ -0,0 +1 @@
Fabricator(:incoming_email)