diff options
author | Sean McGivern <sean@mcgivern.me.uk> | 2017-12-14 10:39:16 +0000 |
---|---|---|
committer | Sean McGivern <sean@mcgivern.me.uk> | 2017-12-14 10:39:16 +0000 |
commit | 1fbda39c8dd8774d13832d5492e800b66ba90d6d (patch) | |
tree | 6ece7745cd17f6029dedff1d49622de015dae295 /spec | |
parent | c74e556d89bb74fa09e38b8680981a466c88fd20 (diff) | |
parent | f55aaca561986757343fb410a9e6c09cfcc61385 (diff) | |
download | gitlab-ce-1fbda39c8dd8774d13832d5492e800b66ba90d6d.tar.gz |
Merge branch 'tc-correct-email-in-reply-to' into 'master'
Make mail notifications of discussion notes In-Reply-To of each other
Closes #36054
See merge request gitlab-org/gitlab-ce!14289
Diffstat (limited to 'spec')
-rw-r--r-- | spec/mailers/notify_spec.rb | 40 | ||||
-rw-r--r-- | spec/models/note_spec.rb | 22 |
2 files changed, 62 insertions, 0 deletions
diff --git a/spec/mailers/notify_spec.rb b/spec/mailers/notify_spec.rb index e1d71a9573b..4d0a3942996 100644 --- a/spec/mailers/notify_spec.rb +++ b/spec/mailers/notify_spec.rb @@ -342,6 +342,46 @@ describe Notify do end end + context 'for issue notes' do + let(:host) { Gitlab.config.gitlab.host } + + context 'in discussion' do + set(:first_note) { create(:discussion_note_on_issue) } + set(:second_note) { create(:discussion_note_on_issue, in_reply_to: first_note) } + set(:third_note) { create(:discussion_note_on_issue, in_reply_to: second_note) } + + subject { described_class.note_issue_email(recipient.id, third_note.id) } + + it 'has In-Reply-To header pointing to previous note in discussion' do + expect(subject.header['In-Reply-To'].message_ids).to eq(["note_#{second_note.id}@#{host}"]) + end + + it 'has References header including the notes and issue of the discussion' do + expect(subject.header['References'].message_ids).to include("issue_#{first_note.noteable.id}@#{host}", + "note_#{first_note.id}@#{host}", + "note_#{second_note.id}@#{host}") + end + + it 'has X-GitLab-Discussion-ID header' do + expect(subject.header['X-GitLab-Discussion-ID'].value).to eq(third_note.discussion.id) + end + end + + context 'individual issue comments' do + set(:note) { create(:note_on_issue) } + + subject { described_class.note_issue_email(recipient.id, note.id) } + + it 'has In-Reply-To header pointing to the issue' do + expect(subject.header['In-Reply-To'].message_ids).to eq(["issue_#{note.noteable.id}@#{host}"]) + end + + it 'has References header including the notes and issue of the discussion' do + expect(subject.header['References'].message_ids).to include("issue_#{note.noteable.id}@#{host}") + end + end + end + context 'for snippet notes' do let(:project_snippet) { create(:project_snippet, project: project) } let(:project_snippet_note) { create(:note_on_project_snippet, project: project, noteable: project_snippet) } diff --git a/spec/models/note_spec.rb b/spec/models/note_spec.rb index e1a0c55b6a6..cefbf60b28c 100644 --- a/spec/models/note_spec.rb +++ b/spec/models/note_spec.rb @@ -756,6 +756,28 @@ describe Note do end end + describe '#references' do + context 'when part of a discussion' do + it 'references all earlier notes in the discussion' do + first_note = create(:discussion_note_on_issue) + second_note = create(:discussion_note_on_issue, in_reply_to: first_note) + third_note = create(:discussion_note_on_issue, in_reply_to: second_note) + create(:discussion_note_on_issue, in_reply_to: third_note) + + expect(third_note.references).to eq([first_note.noteable, first_note, second_note]) + end + end + + context 'when not part of a discussion' do + subject { create(:note) } + let(:note) { create(:note, in_reply_to: subject) } + + it 'returns the noteable' do + expect(note.references).to eq([note.noteable]) + end + end + end + describe 'expiring ETag cache' do let(:note) { build(:note_on_issue) } |