diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-09-19 04:45:44 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-09-19 04:45:44 +0300 |
commit | 85dc423f7090da0a52c73eb66faf22ddb20efff9 (patch) | |
tree | 9160f299afd8c80c038f08e1545be119f5e3f1e1 /spec/lib/gitlab/email | |
parent | 15c2c8c66dbe422588e5411eee7e68f1fa440bb8 (diff) |
Add latest changes from gitlab-org/gitlab@13-4-stable-ee
Diffstat (limited to 'spec/lib/gitlab/email')
4 files changed, 39 insertions, 33 deletions
diff --git a/spec/lib/gitlab/email/handler/create_issue_handler_spec.rb b/spec/lib/gitlab/email/handler/create_issue_handler_spec.rb index ee2173a9c8d..1a7d837af73 100644 --- a/spec/lib/gitlab/email/handler/create_issue_handler_spec.rb +++ b/spec/lib/gitlab/email/handler/create_issue_handler_spec.rb @@ -4,17 +4,6 @@ require 'spec_helper' RSpec.describe Gitlab::Email::Handler::CreateIssueHandler do include_context :email_shared_context - it_behaves_like :reply_processing_shared_examples - - before do - stub_incoming_email_setting(enabled: true, address: "incoming+%{key}@appmail.adventuretime.ooo") - stub_config_setting(host: 'localhost') - end - - let(:email_raw) { email_fixture('emails/valid_new_issue.eml') } - let(:namespace) { create(:namespace, path: 'gitlabhq') } - - let!(:project) { create(:project, :public, namespace: namespace, path: 'gitlabhq') } let!(:user) do create( :user, @@ -23,6 +12,17 @@ RSpec.describe Gitlab::Email::Handler::CreateIssueHandler do ) end + let!(:project) { create(:project, :public, namespace: namespace, path: 'gitlabhq') } + let(:namespace) { create(:namespace, path: 'gitlabhq') } + let(:email_raw) { email_fixture('emails/valid_new_issue.eml') } + + it_behaves_like :reply_processing_shared_examples + + before do + stub_incoming_email_setting(enabled: true, address: "incoming+%{key}@appmail.adventuretime.ooo") + stub_config_setting(host: 'localhost') + end + context "when email key" do let(:mail) { Mail::Message.new(email_raw) } diff --git a/spec/lib/gitlab/email/handler/create_merge_request_handler_spec.rb b/spec/lib/gitlab/email/handler/create_merge_request_handler_spec.rb index 75d5fc040cb..37ee4591db0 100644 --- a/spec/lib/gitlab/email/handler/create_merge_request_handler_spec.rb +++ b/spec/lib/gitlab/email/handler/create_merge_request_handler_spec.rb @@ -4,6 +4,18 @@ require 'spec_helper' RSpec.describe Gitlab::Email::Handler::CreateMergeRequestHandler do include_context :email_shared_context + let!(:user) do + create( + :user, + email: 'jake@adventuretime.ooo', + incoming_email_token: 'auth_token' + ) + end + + let!(:project) { create(:project, :public, :repository, namespace: namespace, path: 'gitlabhq') } + let(:namespace) { create(:namespace, path: 'gitlabhq') } + let(:email_raw) { email_fixture('emails/valid_new_merge_request.eml') } + it_behaves_like :reply_processing_shared_examples before do @@ -15,18 +27,6 @@ RSpec.describe Gitlab::Email::Handler::CreateMergeRequestHandler do TestEnv.clean_test_path end - let(:email_raw) { email_fixture('emails/valid_new_merge_request.eml') } - let(:namespace) { create(:namespace, path: 'gitlabhq') } - - let!(:project) { create(:project, :public, :repository, namespace: namespace, path: 'gitlabhq') } - let!(:user) do - create( - :user, - email: 'jake@adventuretime.ooo', - incoming_email_token: 'auth_token' - ) - end - context "when email key" do let(:mail) { Mail::Message.new(email_raw) } 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 e5598bbd10f..07b8070be30 100644 --- a/spec/lib/gitlab/email/handler/create_note_handler_spec.rb +++ b/spec/lib/gitlab/email/handler/create_note_handler_spec.rb @@ -4,6 +4,16 @@ require 'spec_helper' RSpec.describe Gitlab::Email::Handler::CreateNoteHandler do include_context :email_shared_context + let!(:sent_notification) do + SentNotification.record_note(note, user.id, mail_key) + end + + let(:noteable) { note.noteable } + let(:note) { create(:diff_note_on_merge_request, project: project) } + let(:user) { create(:user) } + let(:project) { create(:project, :public, :repository) } + let(:email_raw) { fixture_file('emails/valid_reply.eml') } + it_behaves_like :reply_processing_shared_examples before do @@ -11,16 +21,6 @@ RSpec.describe Gitlab::Email::Handler::CreateNoteHandler do stub_config_setting(host: 'localhost') end - let(:email_raw) { fixture_file('emails/valid_reply.eml') } - let(:project) { create(:project, :public, :repository) } - let(:user) { create(:user) } - let(:note) { create(:diff_note_on_merge_request, project: project) } - let(:noteable) { note.noteable } - - let!(:sent_notification) do - SentNotification.record_note(note, user.id, mail_key) - end - context "when the recipient address doesn't include a mail key" do let(:email_raw) { fixture_file('emails/valid_reply.eml').gsub(mail_key, "") } diff --git a/spec/lib/gitlab/email/receiver_spec.rb b/spec/lib/gitlab/email/receiver_spec.rb index 592d3f3f0e4..ccff902d290 100644 --- a/spec/lib/gitlab/email/receiver_spec.rb +++ b/spec/lib/gitlab/email/receiver_spec.rb @@ -36,6 +36,12 @@ RSpec.describe Gitlab::Email::Receiver do it_behaves_like 'correctly finds the mail key' end + context 'when in an X-Envelope-To header' do + let(:email_raw) { fixture_file('emails/x_envelope_to_header.eml') } + + it_behaves_like 'correctly finds the mail key' + end + context 'when enclosed with angle brackets in an Envelope-To header' do let(:email_raw) { fixture_file('emails/envelope_to_header_with_angle_brackets.eml') } |