summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLin Jen-Shin <godfat@godfat.org>2016-03-31 21:56:37 +0800
committerLin Jen-Shin <godfat@godfat.org>2016-05-16 21:27:16 +0000
commit347ee6cc912d49680d2f6b90134142c656868333 (patch)
tree9f3cd7068db03c090901696bd7b2808849d020bb
parenta61bf17fce17b06741d47206d04b1137381fc639 (diff)
downloadgitlab-ce-347ee6cc912d49680d2f6b90134142c656868333.tar.gz
Alloy empty reply for new issues, but not response
-rw-r--r--lib/gitlab/email/receiver.rb6
-rw-r--r--spec/fixtures/emails/valid_new_issue_empty.eml18
-rw-r--r--spec/lib/gitlab/email/receiver_spec.rb16
3 files changed, 36 insertions, 4 deletions
diff --git a/lib/gitlab/email/receiver.rb b/lib/gitlab/email/receiver.rb
index 169312f0b90..3dd3bd02707 100644
--- a/lib/gitlab/email/receiver.rb
+++ b/lib/gitlab/email/receiver.rb
@@ -44,7 +44,9 @@ module Gitlab
raise NoteableNotFoundError unless sent_notification.noteable
- note = create_note(handle_reply(project))
+ reply = handle_reply(project)
+ raise EmptyEmailError if reply.blank?
+ note = create_note(reply)
unless note.persisted?
msg = "The comment could not be created for the following reasons:"
@@ -104,8 +106,6 @@ module Gitlab
def handle_reply(project)
reply = ReplyParser.new(message).execute.strip
- raise EmptyEmailError if reply.blank?
-
add_attachments(reply, project)
reply
diff --git a/spec/fixtures/emails/valid_new_issue_empty.eml b/spec/fixtures/emails/valid_new_issue_empty.eml
new file mode 100644
index 00000000000..2173508d6f8
--- /dev/null
+++ b/spec/fixtures/emails/valid_new_issue_empty.eml
@@ -0,0 +1,18 @@
+Return-Path: <jake@adventuretime.ooo>
+Received: from iceking.adventuretime.ooo ([unix socket]) by iceking (Cyrus v2.2.13-Debian-2.2.13-19+squeeze3) with LMTPA; Thu, 13 Jun 2013 17:03:50 -0400
+Received: from mail-ie0-x234.google.com (mail-ie0-x234.google.com [IPv6:2607:f8b0:4001:c03::234]) by iceking.adventuretime.ooo (8.14.3/8.14.3/Debian-9.4) with ESMTP id r5DL3nFJ016967 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=NOT) for <incoming+gitlabhq/gitlabhq@appmail.adventuretime.ooo>; Thu, 13 Jun 2013 17:03:50 -0400
+Received: by mail-ie0-f180.google.com with SMTP id f4so21977375iea.25 for <incoming+gitlabhq/gitlabhq@appmail.adventuretime.ooo>; Thu, 13 Jun 2013 14:03:48 -0700
+Received: by 10.0.0.1 with HTTP; Thu, 13 Jun 2013 14:03:48 -0700
+Date: Thu, 13 Jun 2013 17:03:48 -0400
+From: Jake the Dog <jake@adventuretime.ooo>
+To: incoming+gitlabhq/gitlabhq@appmail.adventuretime.ooo
+Message-ID: <CADkmRc+rNGAGGbV2iE5p918UVy4UyJqVcXRO2=otppgzduJSg@mail.gmail.com>
+Subject: New Issue by email
+Mime-Version: 1.0
+Content-Type: text/plain;
+ charset=ISO-8859-1
+Content-Transfer-Encoding: 7bit
+X-Sieve: CMU Sieve 2.2
+X-Received: by 10.0.0.1 with SMTP id n7mr11234144ipb.85.1371157428600; Thu,
+ 13 Jun 2013 14:03:48 -0700 (PDT)
+X-Scanned-By: MIMEDefang 2.69 on IPv6:2001:470:1d:165::1
diff --git a/spec/lib/gitlab/email/receiver_spec.rb b/spec/lib/gitlab/email/receiver_spec.rb
index e7391a33751..4336f0f9e53 100644
--- a/spec/lib/gitlab/email/receiver_spec.rb
+++ b/spec/lib/gitlab/email/receiver_spec.rb
@@ -167,7 +167,6 @@ describe Gitlab::Email::Receiver, lib: true do
context "when it's trying to create a new issue" do
before do
- setup_attachment
stub_incoming_email_setting(enabled: true, address: "incoming+%{key}@appmail.adventuretime.ooo")
end
@@ -179,6 +178,8 @@ describe Gitlab::Email::Receiver, lib: true do
context "when everything is fine" do
it "creates a new issue" do
+ setup_attachment
+
expect { receiver.execute }.to change { project.issues.count }.by(1)
issue = project.issues.last
@@ -187,6 +188,19 @@ describe Gitlab::Email::Receiver, lib: true do
expect(issue.description).to include('reply by email')
expect(issue.description).to include(markdown)
end
+
+ context "when the reply is blank" do
+ let!(:email_raw) { fixture_file("emails/valid_new_issue_empty.eml") }
+
+ it "creates a new issue" do
+ expect { receiver.execute }.to change { project.issues.count }.by(1)
+ issue = project.issues.last
+
+ expect(issue.author).to eq(user)
+ expect(issue.title).to eq('New Issue by email')
+ expect(issue.description).to eq('')
+ end
+ end
end
context "something is wrong" do