summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Kalderimis <alex.kalderimis@gmail.com>2019-08-20 22:22:40 +0100
committerAlex Kalderimis <alex.kalderimis@gmail.com>2019-08-20 22:22:40 +0100
commit8db842e8f8d0eb8a53c4cf6378e655ed3f469a96 (patch)
treeacf4d7cae228d0a20e6d0648558de4a62b3cc558
parentcc57bf5dc4c28361a10efe64ac8f06e1a8eb60b3 (diff)
downloadgitlab-ce-8db842e8f8d0eb8a53c4cf6378e655ed3f469a96.tar.gz
Also test the standard, non-namespaced path
-rw-r--r--spec/mailers/notify_spec.rb55
1 files changed, 40 insertions, 15 deletions
diff --git a/spec/mailers/notify_spec.rb b/spec/mailers/notify_spec.rb
index 4ad401ee244..6cba7df114c 100644
--- a/spec/mailers/notify_spec.rb
+++ b/spec/mailers/notify_spec.rb
@@ -544,6 +544,46 @@ describe Notify do
end
describe '#mail_thread' do
+ set(:mail_thread_note) { create(:note) }
+
+ let(:headers) do
+ {
+ from: 'someone@test.com',
+ to: 'someone-else@test.com',
+ subject: 'something',
+ template_name: '_note_email' # re-use this for testing
+ }
+ end
+
+ let(:mailer) do
+ mailer = described_class.new
+ mailer.instance_variable_set(:@note, mail_thread_note)
+ mailer
+ end
+
+ context 'the model has no namespace' do
+ class TopLevelThing
+ include Referable
+ include Noteable
+
+ def to_reference(*_args)
+ 'tlt-ref'
+ end
+
+ def id
+ 'tlt-id'
+ end
+ end
+
+ subject do
+ mailer.send(:mail_thread, TopLevelThing.new, headers)
+ end
+
+ it 'has X-GitLab-Namespaced-Thing-ID header' do
+ expect(subject.header['X-GitLab-TopLevelThing-ID'].value).to eq('tlt-id')
+ end
+ end
+
context 'the model has a namespace' do
module Namespaced
class Thing
@@ -560,21 +600,6 @@ describe Notify do
end
end
- let(:headers) do
- {
- from: 'someone@test.com',
- to: 'someone-else@test.com',
- subject: 'something',
- template_name: '_note_email' # re-use this for testing
- }
- end
-
- let(:mailer) do
- mailer = described_class.new
- mailer.instance_variable_set(:@note, create(:note))
- mailer
- end
-
subject do
mailer.send(:mail_thread, Namespaced::Thing.new, headers)
end