diff options
Diffstat (limited to 'spec/mailers/emails')
-rw-r--r-- | spec/mailers/emails/in_product_marketing_spec.rb | 49 | ||||
-rw-r--r-- | spec/mailers/emails/pipelines_spec.rb | 21 |
2 files changed, 55 insertions, 15 deletions
diff --git a/spec/mailers/emails/in_product_marketing_spec.rb b/spec/mailers/emails/in_product_marketing_spec.rb index 99beef92dea..3b92b049e42 100644 --- a/spec/mailers/emails/in_product_marketing_spec.rb +++ b/spec/mailers/emails/in_product_marketing_spec.rb @@ -47,22 +47,31 @@ RSpec.describe Emails::InProductMarketing do end where(:track, :series) do - :create | 0 - :create | 1 - :create | 2 - :verify | 0 - :verify | 1 - :verify | 2 - :trial | 0 - :trial | 1 - :trial | 2 - :team | 0 - :team | 1 - :team | 2 - :experience | 0 + :create | 0 + :create | 1 + :create | 2 + :verify | 0 + :verify | 1 + :verify | 2 + :trial | 0 + :trial | 1 + :trial | 2 + :team | 0 + :team | 1 + :team | 2 + :experience | 0 + :team_short | 0 + :trial_short | 0 + :admin_verify | 0 + :invite_team | 0 end with_them do + before do + stub_experiments(invite_members_for_task: :candidate) + group.add_owner(user) + end + it 'has the correct subject and content' do message = Gitlab::Email::Message::InProductMarketing.for(track).new(group: group, user: user, series: series) @@ -76,6 +85,20 @@ RSpec.describe Emails::InProductMarketing do else is_expected.to have_body_text(CGI.unescapeHTML(message.cta_link)) end + + if track =~ /(create|verify)/ + is_expected.to have_body_text(message.invite_text) + is_expected.to have_body_text(CGI.unescapeHTML(message.invite_link)) + else + is_expected.not_to have_body_text(message.invite_text) + is_expected.not_to have_body_text(CGI.unescapeHTML(message.invite_link)) + end + + if track == :invite_team + is_expected.not_to have_body_text(/This is email \d of \d/) + else + is_expected.to have_body_text(message.progress) + end end end end diff --git a/spec/mailers/emails/pipelines_spec.rb b/spec/mailers/emails/pipelines_spec.rb index b9bc53625ac..3a2eb105964 100644 --- a/spec/mailers/emails/pipelines_spec.rb +++ b/spec/mailers/emails/pipelines_spec.rb @@ -71,10 +71,19 @@ RSpec.describe Emails::Pipelines do end end + shared_examples_for 'only accepts a single recipient' do + let(:recipient) { ['test@gitlab.com', 'test2@gitlab.com'] } + + it 'raises an ArgumentError' do + expect { subject.deliver_now }.to raise_error(ArgumentError) + end + end + describe '#pipeline_success_email' do - subject { Notify.pipeline_success_email(pipeline, pipeline.user.try(:email)) } + subject { Notify.pipeline_success_email(pipeline, recipient) } let(:pipeline) { create(:ci_pipeline, project: project, ref: ref, sha: sha) } + let(:recipient) { pipeline.user.try(:email) } let(:ref) { 'master' } let(:sha) { project.commit(ref).sha } @@ -93,12 +102,15 @@ RSpec.describe Emails::Pipelines do stub_config_setting(email_subject_suffix: email_subject_suffix) end end + + it_behaves_like 'only accepts a single recipient' end describe '#pipeline_failed_email' do - subject { Notify.pipeline_failed_email(pipeline, pipeline.user.try(:email)) } + subject { Notify.pipeline_failed_email(pipeline, recipient) } let(:pipeline) { create(:ci_pipeline, project: project, ref: ref, sha: sha) } + let(:recipient) { pipeline.user.try(:email) } let(:ref) { 'master' } let(:sha) { project.commit(ref).sha } @@ -106,12 +118,15 @@ RSpec.describe Emails::Pipelines do let(:status) { 'Failed' } let(:status_text) { "Pipeline ##{pipeline.id} has failed!" } end + + it_behaves_like 'only accepts a single recipient' end describe '#pipeline_fixed_email' do subject { Notify.pipeline_fixed_email(pipeline, pipeline.user.try(:email)) } let(:pipeline) { create(:ci_pipeline, project: project, ref: ref, sha: sha) } + let(:recipient) { pipeline.user.try(:email) } let(:ref) { 'master' } let(:sha) { project.commit(ref).sha } @@ -119,5 +134,7 @@ RSpec.describe Emails::Pipelines do let(:status) { 'Fixed' } let(:status_text) { "Pipeline has been fixed and ##{pipeline.id} has passed!" } end + + it_behaves_like 'only accepts a single recipient' end end |