From 09c38e46e5e2e3c3f8a1dcda572243966be48b10 Mon Sep 17 00:00:00 2001
From: Lin Jen-Shin <godfat@godfat.org>
Date: Wed, 15 Jun 2016 20:10:16 +0800
Subject: [PATCH] Only pass item name

---
 lib/gitlab/email/handler/base_handler.rb         | 5 ++++-
 lib/gitlab/email/handler/create_issue_handler.rb | 6 +-----
 lib/gitlab/email/handler/create_note_handler.rb  | 6 +-----
 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
-- 
GitLab