summaryrefslogtreecommitdiff
path: root/spec/lib/gitlab/email
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-02-18 09:45:46 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2022-02-18 09:45:46 +0000
commita7b3560714b4d9cc4ab32dffcd1f74a284b93580 (patch)
tree7452bd5c3545c2fa67a28aa013835fb4fa071baf /spec/lib/gitlab/email
parentee9173579ae56a3dbfe5afe9f9410c65bb327ca7 (diff)
downloadgitlab-ce-a7b3560714b4d9cc4ab32dffcd1f74a284b93580.tar.gz
Add latest changes from gitlab-org/gitlab@14-8-stable-eev14.8.0-rc42
Diffstat (limited to 'spec/lib/gitlab/email')
-rw-r--r--spec/lib/gitlab/email/handler/create_note_handler_spec.rb39
1 files changed, 38 insertions, 1 deletions
diff --git a/spec/lib/gitlab/email/handler/create_note_handler_spec.rb b/spec/lib/gitlab/email/handler/create_note_handler_spec.rb
index c0ac40e3249..59b87c5d8e7 100644
--- a/spec/lib/gitlab/email/handler/create_note_handler_spec.rb
+++ b/spec/lib/gitlab/email/handler/create_note_handler_spec.rb
@@ -5,7 +5,7 @@ require 'spec_helper'
RSpec.describe Gitlab::Email::Handler::CreateNoteHandler do
include_context :email_shared_context
- let_it_be(:user) { create(:user) }
+ let_it_be(:user) { create(:user, email: 'jake@adventuretime.ooo') }
let_it_be(:project) { create(:project, :public, :repository) }
let(:noteable) { note.noteable }
@@ -39,6 +39,43 @@ RSpec.describe Gitlab::Email::Handler::CreateNoteHandler do
end
end
+ context 'when the incoming email is from a different email address' do
+ before do
+ SentNotification.find_by(reply_key: mail_key).update!(recipient: original_recipient)
+ end
+
+ context 'when the issue is not a Service Desk issue' do
+ let(:original_recipient) { create(:user, email: 'john@somethingelse.com') }
+
+ context 'with only one email address' do
+ it 'raises a UserNotFoundError' do
+ expect { receiver.execute }.to raise_error(Gitlab::Email::UserNotFoundError)
+ end
+ end
+
+ context 'with a secondary verified email address' do
+ let(:verified_email) { 'alan@adventuretime.ooo'}
+ let(:email_raw) { fixture_file('emails/valid_reply.eml').gsub('jake@adventuretime.ooo', verified_email) }
+
+ before do
+ create(:email, :confirmed, user: original_recipient, email: verified_email)
+ end
+
+ it 'does not raise a UserNotFoundError' do
+ expect { receiver.execute }.not_to raise_error(Gitlab::Email::UserNotFoundError)
+ end
+ end
+ end
+
+ context 'when the issue is a Service Desk issue' do
+ let(:original_recipient) { User.support_bot }
+
+ it 'does not raise a UserNotFoundError' do
+ expect { receiver.execute }.not_to raise_error(Gitlab::Email::UserNotFoundError)
+ end
+ end
+ end
+
context 'when no sent notification for the mail key could be found' do
let(:email_raw) { fixture_file('emails/wrong_mail_key.eml') }