summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLin Jen-Shin <godfat@godfat.org>2016-06-15 20:10:16 +0800
committerLin Jen-Shin <godfat@godfat.org>2016-06-15 20:10:16 +0800
commit09c38e46e5e2e3c3f8a1dcda572243966be48b10 (patch)
tree80f7b0c9abaf0e4deb5f32ba0776af7649c33802
parent94178149703f06a7fef958bb4dd964819a02fe13 (diff)
downloadgitlab-ce-09c38e46e5e2e3c3f8a1dcda572243966be48b10.tar.gz
Only pass item name
-rw-r--r--lib/gitlab/email/handler/base_handler.rb5
-rw-r--r--lib/gitlab/email/handler/create_issue_handler.rb6
-rw-r--r--lib/gitlab/email/handler/create_note_handler.rb6
3 files changed, 6 insertions, 11 deletions
diff --git a/lib/gitlab/email/handler/base_handler.rb b/lib/gitlab/email/handler/base_handler.rb
index e6c2705421d..4d74e770b91 100644
--- a/lib/gitlab/email/handler/base_handler.rb
+++ b/lib/gitlab/email/handler/base_handler.rb
@@ -42,9 +42,12 @@ module Gitlab
end.join
end
- def verify_record!(record, exception, error_title)
+ def verify_record!(record, exception, name)
return if record.persisted?
+ error_title =
+ "The #{name} could not be created for the following reasons:"
+
msg = error_title + record.errors.full_messages.map do |error|
"\n\n- #{error}"
end.join
diff --git a/lib/gitlab/email/handler/create_issue_handler.rb b/lib/gitlab/email/handler/create_issue_handler.rb
index 431bd9a8f4e..f8b23d07165 100644
--- a/lib/gitlab/email/handler/create_issue_handler.rb
+++ b/lib/gitlab/email/handler/create_issue_handler.rb
@@ -22,11 +22,7 @@ module Gitlab
validate_permission!(:create_issue)
- verify_record!(
- create_issue,
- InvalidIssueError,
- "The issue could not be created for the following reasons:"
- )
+ verify_record!(create_issue, InvalidIssueError, 'issue')
end
def author
diff --git a/lib/gitlab/email/handler/create_note_handler.rb b/lib/gitlab/email/handler/create_note_handler.rb
index a9af2f44a81..e4da6b590fb 100644
--- a/lib/gitlab/email/handler/create_note_handler.rb
+++ b/lib/gitlab/email/handler/create_note_handler.rb
@@ -19,11 +19,7 @@ module Gitlab
raise NoteableNotFoundError unless sent_notification.noteable
raise EmptyEmailError if message.blank?
- verify_record!(
- create_note,
- InvalidNoteError,
- "The comment could not be created for the following reasons:"
- )
+ verify_record!(create_note, InvalidNoteError, 'comment')
end
def author