diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-06-16 18:25:58 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-06-16 18:25:58 +0000 |
commit | a5f4bba440d7f9ea47046a0a561d49adf0a1e6d4 (patch) | |
tree | fb69158581673816a8cd895f9d352dcb3c678b1e /spec/mailers | |
parent | d16b2e8639e99961de6ddc93909f3bb5c1445ba1 (diff) | |
download | gitlab-ce-a5f4bba440d7f9ea47046a0a561d49adf0a1e6d4.tar.gz |
Add latest changes from gitlab-org/gitlab@14-0-stable-eev14.0.0-rc42
Diffstat (limited to 'spec/mailers')
-rw-r--r-- | spec/mailers/emails/in_product_marketing_spec.rb | 36 | ||||
-rw-r--r-- | spec/mailers/emails/profile_spec.rb | 6 | ||||
-rw-r--r-- | spec/mailers/emails/service_desk_spec.rb | 12 | ||||
-rw-r--r-- | spec/mailers/notify_spec.rb | 32 |
4 files changed, 57 insertions, 29 deletions
diff --git a/spec/mailers/emails/in_product_marketing_spec.rb b/spec/mailers/emails/in_product_marketing_spec.rb index 3d17e16ef48..74354630ade 100644 --- a/spec/mailers/emails/in_product_marketing_spec.rb +++ b/spec/mailers/emails/in_product_marketing_spec.rb @@ -9,6 +9,8 @@ RSpec.describe Emails::InProductMarketing do let_it_be(:user) { create(:user) } let_it_be(:group) { create(:group) } + let!(:onboarding_progress) { create(:onboarding_progress, namespace: group) } + describe '#in_product_marketing_email' do using RSpec::Parameterized::TableSyntax @@ -45,29 +47,35 @@ 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 + :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 end with_them do it 'has the correct subject and content' do - message = Gitlab::Email::Message::InProductMarketing.for(track).new(group: group, series: series) + message = Gitlab::Email::Message::InProductMarketing.for(track).new(group: group, user: user, series: series) aggregate_failures do is_expected.to have_subject(message.subject_line) is_expected.to have_body_text(message.title) is_expected.to have_body_text(message.subtitle) - is_expected.to have_body_text(CGI.unescapeHTML(message.cta_link)) + + if track == :experience + is_expected.to have_body_text(CGI.unescapeHTML(message.feedback_link(1))) + else + is_expected.to have_body_text(CGI.unescapeHTML(message.cta_link)) + end end end end diff --git a/spec/mailers/emails/profile_spec.rb b/spec/mailers/emails/profile_spec.rb index 0ca202aa7be..365ca892bb1 100644 --- a/spec/mailers/emails/profile_spec.rb +++ b/spec/mailers/emails/profile_spec.rb @@ -264,7 +264,7 @@ RSpec.describe Emails::Profile do include_examples 'valid use case' it_behaves_like 'has the correct subject', /Your SSH key has expired/ - it_behaves_like 'has the correct body text', /Your SSH keys with the following fingerprints have expired/ + it_behaves_like 'has the correct body text', /SSH keys with the following fingerprints have expired/ end context 'when invalid' do @@ -291,7 +291,7 @@ RSpec.describe Emails::Profile do include_examples 'valid use case' it_behaves_like 'has the correct subject', /Your SSH key is expiring soon/ - it_behaves_like 'has the correct body text', /Your SSH keys with the following fingerprints are scheduled to expire soon/ + it_behaves_like 'has the correct body text', /SSH keys with the following fingerprints are scheduled to expire soon/ end context 'when invalid' do @@ -337,7 +337,7 @@ RSpec.describe Emails::Profile do end it 'mentioned the time' do - is_expected.to have_body_text current_time.strftime('%Y-%m-%d %l:%M:%S %p %Z') + is_expected.to have_body_text current_time.strftime('%Y-%m-%d %H:%M:%S %Z') end it 'includes a link to the change password documentation' do diff --git a/spec/mailers/emails/service_desk_spec.rb b/spec/mailers/emails/service_desk_spec.rb index 57fa990d399..995e6c006cd 100644 --- a/spec/mailers/emails/service_desk_spec.rb +++ b/spec/mailers/emails/service_desk_spec.rb @@ -115,6 +115,16 @@ RSpec.describe Emails::ServiceDesk do end end + shared_examples 'notification with metric event' do |event_type| + it 'adds metric event' do + metric_transaction = double('Gitlab::Metrics::WebTransaction', increment: true, observe: true) + allow(::Gitlab::Metrics::BackgroundTransaction).to receive(:current).and_return(metric_transaction) + expect(metric_transaction).to receive(:add_event).with(event_type) + + subject.content_type + end + end + describe '.service_desk_thank_you_email' do let_it_be(:reply_in_subject) { true } let_it_be(:default_text) do @@ -124,6 +134,7 @@ RSpec.describe Emails::ServiceDesk do subject { ServiceEmailClass.service_desk_thank_you_email(issue.id) } it_behaves_like 'read template from repository', 'thank_you' + it_behaves_like 'notification with metric event', :service_desk_thank_you_email context 'handling template markdown' do context 'with a simple text' do @@ -164,6 +175,7 @@ RSpec.describe Emails::ServiceDesk do subject { ServiceEmailClass.service_desk_new_note_email(issue.id, note.id, email) } it_behaves_like 'read template from repository', 'new_note' + it_behaves_like 'notification with metric event', :service_desk_new_note_email context 'handling template markdown' do context 'with a simple text' do diff --git a/spec/mailers/notify_spec.rb b/spec/mailers/notify_spec.rb index b073b647532..8ee88776107 100644 --- a/spec/mailers/notify_spec.rb +++ b/spec/mailers/notify_spec.rb @@ -790,7 +790,7 @@ RSpec.describe Notify do it_behaves_like 'appearance header and footer not enabled' it_behaves_like 'does not render a manage notifications link' - context 'when there is an inviter' do + context 'when there is an inviter', :aggregate_failures do it 'contains all the useful information' do is_expected.to have_subject "#{inviter.name} invited you to join GitLab" is_expected.to have_body_text project.full_name @@ -799,21 +799,16 @@ RSpec.describe Notify do is_expected.to have_link('Join now', href: invite_url(project_member.invite_token, invite_type: Members::InviteEmailExperiment::INVITE_TYPE)) end - it 'contains invite link for the avatar' do - stub_experiments('members/invite_email': :avatar) + it 'contains invite link for the group activity' do + stub_experiments('members/invite_email': :activity) + is_expected.to have_content("#{inviter.name} invited you to join the") + is_expected.to have_content('Project details') + is_expected.to have_content("What's it about?") is_expected.not_to have_content('You are invited!') is_expected.not_to have_body_text 'What is a GitLab' end - it 'contains invite link for the avatar' do - stub_experiments('members/invite_email': :permission_info) - - is_expected.not_to have_content('You are invited!') - is_expected.to have_body_text 'What is a GitLab' - is_expected.to have_body_text 'What can I do with' - end - it 'has invite link for the control group' do stub_experiments('members/invite_email': :control) @@ -821,7 +816,7 @@ RSpec.describe Notify do end end - context 'when there is no inviter' do + context 'when there is no inviter', :aggregate_failures do let(:inviter) { nil } it 'contains all the useful information' do @@ -831,6 +826,19 @@ RSpec.describe Notify do is_expected.to have_body_text project_member.invite_token end end + + context 'when on gitlab.com' do + before do + allow(Gitlab).to receive(:dev_env_or_com?).and_return(true) + end + + it 'has custom headers' do + aggregate_failures do + expect(subject).to have_header('X-Mailgun-Tag', 'invite_email') + expect(subject).to have_header('X-Mailgun-Variables', { 'invite_token' => project_member.invite_token }.to_json) + end + end + end end describe 'project invitation accepted' do |