FIX: failed messages posted via email silently ignored

also... test suite over mocking
This commit is contained in:
Sam
2014-07-31 18:46:02 +10:00
parent 138d013e56
commit dcc9923e4b
6 changed files with 107 additions and 212 deletions

View File

@ -14,6 +14,7 @@ module Email
class UserNotFoundError < ProcessingError; end
class UserNotSufficientTrustLevelError < ProcessingError; end
class EmailLogNotFound < ProcessingError; end
class InvalidPost < ProcessingError; end
attr_reader :body, :reply_key, :email_log
@ -40,6 +41,8 @@ module Email
@user = User.find_by_email(@message.from.first)
if @user.blank? && @allow_strangers
wrap_body_in_quote
# TODO This is WRONG it should register an account
# and email the user details on how to log in / activate
@user = Discourse.system_user
end
@ -213,7 +216,12 @@ module Email
end
def create_post(user, options)
PostCreator.new(user, options).create
creator = PostCreator.new(user, options)
post = creator.create
if creator.errors.present?
raise InvalidPost, creator.errors.full_messages.join("\n")
end
post
end
end