From 2399724614f3c4dcf3059038d997193830de93ee Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Tue, 21 Jan 2020 03:08:37 +0000 Subject: Add latest changes from gitlab-org/gitlab@master --- spec/lib/gitlab/email/receiver_spec.rb | 8 +++++ spec/lib/gitlab/mail_room/mail_room_spec.rb | 34 ++++++++++++++++++++++ .../gitlab/untrusted_regexp/ruby_syntax_spec.rb | 2 +- spec/lib/gitlab/untrusted_regexp_spec.rb | 2 +- 4 files changed, 44 insertions(+), 2 deletions(-) (limited to 'spec/lib/gitlab') diff --git a/spec/lib/gitlab/email/receiver_spec.rb b/spec/lib/gitlab/email/receiver_spec.rb index 018219e5647..b764bb39682 100644 --- a/spec/lib/gitlab/email/receiver_spec.rb +++ b/spec/lib/gitlab/email/receiver_spec.rb @@ -5,6 +5,14 @@ require 'spec_helper' describe Gitlab::Email::Receiver do include_context :email_shared_context + shared_examples 'correctly finds the mail key' do + specify do + expect(Gitlab::Email::Handler).to receive(:for).with(an_instance_of(Mail::Message), 'gitlabhq/gitlabhq+auth_token').and_return(handler) + + receiver.execute + end + end + context 'when the email contains a valid email address in a header' do let(:handler) { double(:handler) } diff --git a/spec/lib/gitlab/mail_room/mail_room_spec.rb b/spec/lib/gitlab/mail_room/mail_room_spec.rb index cb3e214d38b..43218fc6e0d 100644 --- a/spec/lib/gitlab/mail_room/mail_room_spec.rb +++ b/spec/lib/gitlab/mail_room/mail_room_spec.rb @@ -16,6 +16,40 @@ describe Gitlab::MailRoom do } end + shared_examples_for 'only truthy if both enabled and address are truthy' do |target_proc| + context 'with both enabled and address as truthy values' do + it 'is truthy' do + stub_config(enabled: true, address: 'localhost') + + expect(target_proc.call).to be_truthy + end + end + + context 'with address only as truthy' do + it 'is falsey' do + stub_config(enabled: false, address: 'localhost') + + expect(target_proc.call).to be_falsey + end + end + + context 'with enabled only as truthy' do + it 'is falsey' do + stub_config(enabled: true, address: nil) + + expect(target_proc.call).to be_falsey + end + end + + context 'with neither address nor enabled as truthy' do + it 'is falsey' do + stub_config(enabled: false, address: nil) + + expect(target_proc.call).to be_falsey + end + end + end + before do described_class.reset_config! allow(File).to receive(:exist?).and_return true diff --git a/spec/lib/gitlab/untrusted_regexp/ruby_syntax_spec.rb b/spec/lib/gitlab/untrusted_regexp/ruby_syntax_spec.rb index 68402e64012..cdd681a9345 100644 --- a/spec/lib/gitlab/untrusted_regexp/ruby_syntax_spec.rb +++ b/spec/lib/gitlab/untrusted_regexp/ruby_syntax_spec.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true require 'fast_spec_helper' -require 'support/shared_examples/malicious_regexp_shared_examples' +require 'support/shared_examples/lib/gitlab/malicious_regexp_shared_examples' require 'support/helpers/stub_feature_flags' describe Gitlab::UntrustedRegexp::RubySyntax do diff --git a/spec/lib/gitlab/untrusted_regexp_spec.rb b/spec/lib/gitlab/untrusted_regexp_spec.rb index 4cc21e94a83..60f14d0277b 100644 --- a/spec/lib/gitlab/untrusted_regexp_spec.rb +++ b/spec/lib/gitlab/untrusted_regexp_spec.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true require 'fast_spec_helper' -require 'support/shared_examples/malicious_regexp_shared_examples' +require 'support/shared_examples/lib/gitlab/malicious_regexp_shared_examples' describe Gitlab::UntrustedRegexp do describe '#initialize' do -- cgit v1.2.3