mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-23 23:58:31 -05:00
FIX: If there is an exception when parsing one email, don't stop all
work, return an error code and continue.
This commit is contained in:
parent
62592215f4
commit
318e692290
2 changed files with 13 additions and 1 deletions
|
@ -6,7 +6,7 @@ module Email
|
|||
class Receiver
|
||||
|
||||
def self.results
|
||||
@results ||= Enum.new(:unprocessable, :missing, :processed)
|
||||
@results ||= Enum.new(:unprocessable, :missing, :processed, :error)
|
||||
end
|
||||
|
||||
attr_reader :body, :reply_key, :email_log
|
||||
|
@ -46,6 +46,8 @@ module Email
|
|||
create_reply
|
||||
|
||||
Email::Receiver.results[:processed]
|
||||
rescue
|
||||
Email::Receiver.results[:error]
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
@ -9,6 +9,16 @@ describe Email::Receiver do
|
|||
SiteSetting.stubs(:reply_by_email_address).returns("reply+%{reply_key}@appmail.adventuretime.ooo")
|
||||
end
|
||||
|
||||
describe "exception raised" do
|
||||
it "returns error if it encountered an error processing" do
|
||||
receiver = Email::Receiver.new("some email")
|
||||
def receiver.parse_body
|
||||
raise "ERROR HAPPENED!"
|
||||
end
|
||||
expect(receiver.process).to eq(Email::Receiver.results[:error])
|
||||
end
|
||||
end
|
||||
|
||||
describe 'invalid emails' do
|
||||
it "returns unprocessable if the message is blank" do
|
||||
expect(Email::Receiver.new("").process).to eq(Email::Receiver.results[:unprocessable])
|
||||
|
|
Loading…
Reference in a new issue