summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2014-07-07 14:06:40 +0000
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2014-07-07 14:06:40 +0000
commit664112b47eb40386f8fa982a748e279a1a5039e2 (patch)
tree18dbf7d1732fd24a948afab74c7cb8e53652d8f0 /spec
parentd5a8f9ccca0b206c6a111c81a9c1ac2340974e1a (diff)
parent6dafbf24124a098f65864cdecd91bcb5e50c2540 (diff)
downloadgitlab-ce-664112b47eb40386f8fa982a748e279a1a5039e2.tar.gz
Merge branch 'improve-email-threading' into 'master'
Improve email threading This is a follow-up to !112 : it improves email threading, without changing the receiver of the emails. * Subject of answers to an existing thread begins with `Re: ` (required by Mail.app) * Send a 'In-Reply-To' header along the 'References' header
Diffstat (limited to 'spec')
-rw-r--r--spec/mailers/notify_spec.rb43
1 files changed, 27 insertions, 16 deletions
diff --git a/spec/mailers/notify_spec.rb b/spec/mailers/notify_spec.rb
index 224b613b477..d7230ec4341 100644
--- a/spec/mailers/notify_spec.rb
+++ b/spec/mailers/notify_spec.rb
@@ -22,6 +22,23 @@ describe Notify do
end
end
+ shared_examples 'an email starting a new thread' do |message_id_prefix|
+ it 'has a discussion identifier' do
+ should have_header 'Message-ID', /<#{message_id_prefix}(.*)@#{Gitlab.config.gitlab.host}>/
+ end
+ end
+
+ shared_examples 'an answer to an existing thread' do |thread_id_prefix|
+ it 'has a subject that begins with Re: ' do
+ should have_subject /^Re: /
+ end
+
+ it 'has headers that reference an existing thread' do
+ should have_header 'References', /<#{thread_id_prefix}(.*)@#{Gitlab.config.gitlab.host}>/
+ should have_header 'In-Reply-To', /<#{thread_id_prefix}(.*)@#{Gitlab.config.gitlab.host}>/
+ end
+ end
+
describe 'for new users, the email' do
let(:example_site_path) { root_path }
let(:new_user) { create(:user, email: 'newguy@example.com', created_by_id: 1) }
@@ -153,6 +170,7 @@ describe Notify do
subject { Notify.new_issue_email(issue.assignee_id, issue.id) }
it_behaves_like 'an assignee email'
+ it_behaves_like 'an email starting a new thread', 'issue'
it 'has the correct subject' do
should have_subject /#{project.name} \| #{issue.title} \(##{issue.iid}\)/
@@ -161,10 +179,6 @@ describe Notify do
it 'contains a link to the new issue' do
should have_body_text /#{project_issue_path project, issue}/
end
-
- it 'has the correct message-id set' do
- should have_header 'Message-ID', "<issue_#{issue.id}@#{Gitlab.config.gitlab.host}>"
- end
end
describe 'that are new with a description' do
@@ -179,6 +193,7 @@ describe Notify do
subject { Notify.reassigned_issue_email(recipient.id, issue.id, previous_assignee.id, current_user) }
it_behaves_like 'a multiple recipients email'
+ it_behaves_like 'an answer to an existing thread', 'issue'
it 'is sent as the author' do
sender = subject.header[:from].addrs[0]
@@ -201,16 +216,14 @@ describe Notify do
it 'contains a link to the issue' do
should have_body_text /#{project_issue_path project, issue}/
end
-
- it 'has the correct reference set' do
- should have_header 'References', "<issue_#{issue.id}@#{Gitlab.config.gitlab.host}>"
- end
end
describe 'status changed' do
let(:status) { 'closed' }
subject { Notify.issue_status_changed_email(recipient.id, issue.id, status, current_user) }
+ it_behaves_like 'an answer to an existing thread', 'issue'
+
it 'is sent as the author' do
sender = subject.header[:from].addrs[0]
sender.display_name.should eq(current_user.name)
@@ -232,10 +245,6 @@ describe Notify do
it 'contains a link to the issue' do
should have_body_text /#{project_issue_path project, issue}/
end
-
- it 'has the correct reference set' do
- should have_header 'References', "<issue_#{issue.id}@#{Gitlab.config.gitlab.host}>"
- end
end
end
@@ -249,6 +258,7 @@ describe Notify do
subject { Notify.new_merge_request_email(merge_request.assignee_id, merge_request.id) }
it_behaves_like 'an assignee email'
+ it_behaves_like 'an email starting a new thread', 'merge_request'
it 'has the correct subject' do
should have_subject /#{merge_request.title} \(##{merge_request.iid}\)/
@@ -283,6 +293,7 @@ describe Notify do
subject { Notify.reassigned_merge_request_email(recipient.id, merge_request.id, previous_assignee.id, current_user.id) }
it_behaves_like 'a multiple recipients email'
+ it_behaves_like 'an answer to an existing thread', 'merge_request'
it 'is sent as the author' do
sender = subject.header[:from].addrs[0]
@@ -311,6 +322,7 @@ describe Notify do
subject { Notify.merged_merge_request_email(recipient.id, merge_request.id, merge_author.id) }
it_behaves_like 'a multiple recipients email'
+ it_behaves_like 'an answer to an existing thread', 'merge_request'
it 'is sent as the merge author' do
sender = subject.header[:from].addrs[0]
@@ -329,10 +341,6 @@ describe Notify do
it 'contains a link to the merge request' do
should have_body_text /#{project_merge_request_path project, merge_request}/
end
-
- it 'has the correct reference set' do
- should have_header 'References', "<merge_request_#{merge_request.id}@#{Gitlab.config.gitlab.host}>"
- end
end
end
end
@@ -410,6 +418,7 @@ describe Notify do
subject { Notify.note_commit_email(recipient.id, note.id) }
it_behaves_like 'a note email'
+ it_behaves_like 'an answer to an existing thread', 'commits'
it 'has the correct subject' do
should have_subject /#{commit.title} \(#{commit.short_id}\)/
@@ -428,6 +437,7 @@ describe Notify do
subject { Notify.note_merge_request_email(recipient.id, note.id) }
it_behaves_like 'a note email'
+ it_behaves_like 'an answer to an existing thread', 'merge_request'
it 'has the correct subject' do
should have_subject /#{merge_request.title} \(##{merge_request.iid}\)/
@@ -446,6 +456,7 @@ describe Notify do
subject { Notify.note_issue_email(recipient.id, note.id) }
it_behaves_like 'a note email'
+ it_behaves_like 'an answer to an existing thread', 'issue'
it 'has the correct subject' do
should have_subject /#{issue.title} \(##{issue.iid}\)/