diff options
Diffstat (limited to 'spec/lib/gitlab/email/receiver_spec.rb')
-rw-r--r-- | spec/lib/gitlab/email/receiver_spec.rb | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/spec/lib/gitlab/email/receiver_spec.rb b/spec/lib/gitlab/email/receiver_spec.rb index 9b05c12ef57..2c1fe529a5d 100644 --- a/spec/lib/gitlab/email/receiver_spec.rb +++ b/spec/lib/gitlab/email/receiver_spec.rb @@ -5,9 +5,13 @@ require 'spec_helper' RSpec.describe Gitlab::Email::Receiver do include_context :email_shared_context - shared_examples 'correctly finds the mail key' do - specify do + shared_examples 'correctly finds the mail key and adds metric event' do + let(:metric_transaction) { double('Gitlab::Metrics::WebTransaction') } + + specify :aggregate_failures do expect(Gitlab::Email::Handler).to receive(:for).with(an_instance_of(Mail::Message), 'gitlabhq/gitlabhq+auth_token').and_return(handler) + expect(::Gitlab::Metrics::BackgroundTransaction).to receive(:current).and_return(metric_transaction) + expect(metric_transaction).to receive(:add_event).with(handler.metrics_event, handler.metrics_params) receiver.execute end @@ -30,7 +34,7 @@ RSpec.describe Gitlab::Email::Receiver do context 'when in a Delivered-To header' do let(:email_raw) { fixture_file('emails/forwarded_new_issue.eml') } - it_behaves_like 'correctly finds the mail key' + it_behaves_like 'correctly finds the mail key and adds metric event' it 'parses the metadata' do expect(metadata[:delivered_to]). to eq(["incoming+gitlabhq/gitlabhq+auth_token@appmail.example.com", "support@example.com"]) @@ -40,7 +44,7 @@ RSpec.describe Gitlab::Email::Receiver do context 'when in an Envelope-To header' do let(:email_raw) { fixture_file('emails/envelope_to_header.eml') } - it_behaves_like 'correctly finds the mail key' + it_behaves_like 'correctly finds the mail key and adds metric event' it 'parses the metadata' do expect(metadata[:envelope_to]). to eq(["incoming+gitlabhq/gitlabhq+auth_token@appmail.example.com"]) @@ -50,7 +54,7 @@ RSpec.describe Gitlab::Email::Receiver do 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' + it_behaves_like 'correctly finds the mail key and adds metric event' it 'parses the metadata' do expect(metadata[:x_envelope_to]). to eq(["incoming+gitlabhq/gitlabhq+auth_token@appmail.example.com"]) @@ -60,7 +64,7 @@ RSpec.describe Gitlab::Email::Receiver do 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') } - it_behaves_like 'correctly finds the mail key' + it_behaves_like 'correctly finds the mail key and adds metric event' end end |