diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-11-19 11:27:35 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-11-19 11:27:35 +0300 |
commit | 7e9c479f7de77702622631cff2628a9c8dcbc627 (patch) | |
tree | c8f718a08e110ad7e1894510980d2155a6549197 /spec/mailers/notify_spec.rb | |
parent | e852b0ae16db4052c1c567d9efa4facc81146e88 (diff) |
Add latest changes from gitlab-org/gitlab@13-6-stable-eev13.6.0-rc42
Diffstat (limited to 'spec/mailers/notify_spec.rb')
-rw-r--r-- | spec/mailers/notify_spec.rb | 197 |
1 files changed, 34 insertions, 163 deletions
diff --git a/spec/mailers/notify_spec.rb b/spec/mailers/notify_spec.rb index 8604939ead9..3cc5f202b1f 100644 --- a/spec/mailers/notify_spec.rb +++ b/spec/mailers/notify_spec.rb @@ -619,6 +619,7 @@ RSpec.describe Notify do let(:mailer) do mailer = described_class.new mailer.instance_variable_set(:@note, mail_thread_note) + mailer.instance_variable_set(:@target_url, "https://some.link") mailer end @@ -887,96 +888,30 @@ RSpec.describe Notify do subject { described_class.member_invited_email('project', project_member.id, project_member.invite_token) } - context 'when invite_email_experiment is disabled' do - before do - stub_feature_flags(invite_email_experiment: false) - end - - it_behaves_like 'an email sent from GitLab' - it_behaves_like 'it should not have Gmail Actions links' - it_behaves_like "a user cannot unsubscribe through footer link" - it_behaves_like 'appearance header and footer enabled' - it_behaves_like 'appearance header and footer not enabled' + it_behaves_like 'an email sent from GitLab' + it_behaves_like 'it should not have Gmail Actions links' + it_behaves_like "a user cannot unsubscribe through footer link" + it_behaves_like 'appearance header and footer enabled' + 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 it 'contains all the useful information' do - is_expected.to have_subject "Invitation to join the #{project.full_name} project" + is_expected.to have_subject "#{inviter.name} invited you to join GitLab" is_expected.to have_body_text project.full_name - is_expected.to have_body_text project_member.human_access + is_expected.to have_body_text project_member.human_access.downcase is_expected.to have_body_text project_member.invite_token end - - context 'when member is invited via an email address' do - it 'does add a param to the invite link' do - is_expected.to have_body_text 'new_user_invite=control' - end - - it 'tracks an event' do - expect(Gitlab::Tracking).to receive(:event).with( - 'Growth::Acquisition::Experiment::InviteEmail', - 'sent', - property: 'control_group' - ) - - subject.deliver_now - end - end - - context 'when member is already a user' do - let(:project_member) { invite_to_project(project, inviter: maintainer, user: create(:user)) } - - it 'does not add a param to the invite link' do - is_expected.not_to have_body_text 'new_user_invite' - end - - it 'does not track an event' do - expect(Gitlab::Tracking).not_to receive(:event) - - subject.deliver_now - end - end end - context 'when invite_email_experiment is enabled' do - before do - stub_feature_flags(invite_email_experiment: true) - end - - it_behaves_like 'an email sent from GitLab' - it_behaves_like 'it should not have Gmail Actions links' - it_behaves_like "a user cannot unsubscribe through footer link" - - context 'when there is no inviter' do - let(:inviter) { nil } - - it 'contains all the useful information' do - is_expected.to have_subject "Invitation to join the #{project.full_name} project" - is_expected.to have_body_text project.full_name - is_expected.to have_body_text project_member.human_access.downcase - is_expected.to have_body_text project_member.invite_token - end - end + context 'when there is no inviter' do + let(:inviter) { nil } - context 'when there is an inviter' 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 - is_expected.to have_body_text project_member.human_access.downcase - is_expected.to have_body_text project_member.invite_token - end - end - - it 'adds a param to the invite link' do - is_expected.to have_body_text 'new_user_invite=experiment' - end - - it 'tracks an event' do - expect(Gitlab::Tracking).to receive(:event).with( - 'Growth::Acquisition::Experiment::InviteEmail', - 'sent', - property: 'experiment_group' - ) - - subject.deliver_now + it 'contains all the useful information' do + is_expected.to have_subject "Invitation to join the #{project.full_name} project" + is_expected.to have_body_text project.full_name + is_expected.to have_body_text project_member.human_access.downcase + is_expected.to have_body_text project_member.invite_token end end end @@ -1547,95 +1482,31 @@ RSpec.describe Notify do end end - context 'when invite_email_experiment is disabled' do - before do - stub_feature_flags(invite_email_experiment: false) - end - - it_behaves_like 'an email sent from GitLab' - it_behaves_like 'it should not have Gmail Actions links' - it_behaves_like "a user cannot unsubscribe through footer link" - it_behaves_like 'appearance header and footer enabled' - it_behaves_like 'appearance header and footer not enabled' - it_behaves_like 'it requires a group' + it_behaves_like 'an email sent from GitLab' + it_behaves_like 'it should not have Gmail Actions links' + it_behaves_like "a user cannot unsubscribe through footer link" + it_behaves_like 'appearance header and footer enabled' + it_behaves_like 'appearance header and footer not enabled' + it_behaves_like 'it requires a group' + it_behaves_like 'does not render a manage notifications link' + context 'when there is an inviter' do it 'contains all the useful information' do - is_expected.to have_subject "Invitation to join the #{group.name} group" + is_expected.to have_subject "#{group_member.created_by.name} invited you to join GitLab" is_expected.to have_body_text group.name - is_expected.to have_body_text group.web_url - is_expected.to have_body_text group_member.human_access + is_expected.to have_body_text group_member.human_access.downcase is_expected.to have_body_text group_member.invite_token end - - context 'when member is invited via an email address' do - it 'does add a param to the invite link' do - is_expected.to have_body_text 'new_user_invite=control' - end - - it 'tracks an event' do - expect(Gitlab::Tracking).to receive(:event).with( - 'Growth::Acquisition::Experiment::InviteEmail', - 'sent', - property: 'control_group' - ) - - subject.deliver_now - end - end - - context 'when member is already a user' do - let(:group_member) { invite_to_group(group, inviter: owner, user: create(:user)) } - - it 'does not add a param to the invite link' do - is_expected.not_to have_body_text 'new_user_invite' - end - - it 'does not track an event' do - expect(Gitlab::Tracking).not_to receive(:event) - - subject.deliver_now - end - end end - context 'when invite_email_experiment is enabled' do - it_behaves_like 'an email sent from GitLab' - it_behaves_like 'it should not have Gmail Actions links' - it_behaves_like "a user cannot unsubscribe through footer link" - it_behaves_like 'it requires a group' - - context 'when there is no inviter' do - let(:inviter) { nil } - - it 'contains all the useful information' do - is_expected.to have_subject "Invitation to join the #{group.name} group" - is_expected.to have_body_text group.name - is_expected.to have_body_text group_member.human_access.downcase - is_expected.to have_body_text group_member.invite_token - end - end + context 'when there is no inviter' do + let(:inviter) { nil } - context 'when there is an inviter' do - it 'contains all the useful information' do - is_expected.to have_subject "#{group_member.created_by.name} invited you to join GitLab" - is_expected.to have_body_text group.name - is_expected.to have_body_text group_member.human_access.downcase - is_expected.to have_body_text group_member.invite_token - end - end - - it 'does add a param to the invite link' do - is_expected.to have_body_text 'new_user_invite' - end - - it 'tracks an event' do - expect(Gitlab::Tracking).to receive(:event).with( - 'Growth::Acquisition::Experiment::InviteEmail', - 'sent', - property: 'experiment_group' - ) - - subject.deliver_now + it 'contains all the useful information' do + is_expected.to have_subject "Invitation to join the #{group.name} group" + is_expected.to have_body_text group.name + is_expected.to have_body_text group_member.human_access.downcase + is_expected.to have_body_text group_member.invite_token end end end |