diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-11-03 12:10:26 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-11-03 12:10:26 +0000 |
commit | 94822e35f8bfbca6f7b161e22f61b086efb51b2a (patch) | |
tree | 54cd209bc30fe9e7ff84c18a7ecbb1f5c7d0b52d /spec/models/integrations | |
parent | f3189d2a01f0b44915b5d7a2301af1445f759c9f (diff) | |
download | gitlab-ce-94822e35f8bfbca6f7b161e22f61b086efb51b2a.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/models/integrations')
-rw-r--r-- | spec/models/integrations/pipelines_email_spec.rb | 38 | ||||
-rw-r--r-- | spec/models/integrations/zentao_spec.rb | 6 |
2 files changed, 43 insertions, 1 deletions
diff --git a/spec/models/integrations/pipelines_email_spec.rb b/spec/models/integrations/pipelines_email_spec.rb index afd9d71ebc4..d70f104b965 100644 --- a/spec/models/integrations/pipelines_email_spec.rb +++ b/spec/models/integrations/pipelines_email_spec.rb @@ -35,6 +35,42 @@ RSpec.describe Integrations::PipelinesEmail, :mailer do it { is_expected.not_to validate_presence_of(:recipients) } end + + describe 'validates number of recipients' do + before do + stub_const("#{described_class}::RECIPIENTS_LIMIT", 2) + end + + subject(:integration) { described_class.new(project: project, recipients: recipients, active: true) } + + context 'valid number of recipients' do + let(:recipients) { 'foo@bar.com, , ' } + + it 'does not count empty emails' do + is_expected.to be_valid + end + end + + context 'invalid number of recipients' do + let(:recipients) { 'foo@bar.com bar@foo.com bob@gitlab.com' } + + it { is_expected.not_to be_valid } + + it 'adds an error message' do + integration.valid? + + expect(integration.errors).to contain_exactly('Recipients can\'t exceed 2') + end + + context 'when integration is not active' do + before do + integration.active = false + end + + it { is_expected.to be_valid } + end + end + end end shared_examples 'sending email' do |branches_to_be_notified: nil| @@ -50,7 +86,7 @@ RSpec.describe Integrations::PipelinesEmail, :mailer do it 'sends email' do emails = receivers.map { |r| double(notification_email_or_default: r) } - should_only_email(*emails, kind: :bcc) + should_only_email(*emails) end end diff --git a/spec/models/integrations/zentao_spec.rb b/spec/models/integrations/zentao_spec.rb index a1503ecc092..2b0532c7930 100644 --- a/spec/models/integrations/zentao_spec.rb +++ b/spec/models/integrations/zentao_spec.rb @@ -50,4 +50,10 @@ RSpec.describe Integrations::Zentao do expect(zentao_integration.test).to eq(test_response) end end + + describe '#help' do + it 'renders prompt information' do + expect(zentao_integration.help).not_to be_empty + end + end end |