diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-01-14 18:10:59 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-01-14 18:10:59 +0000 |
commit | ea3306a15e945e694afba62dc93b17500ffaec7f (patch) | |
tree | aa444f7fe503e5650bfdb6500ed428b4619ff37b /spec/mailers/notify_spec.rb | |
parent | 8106ac487c3b52471e2ca894c65c13162c2fb1a8 (diff) | |
download | gitlab-ce-ea3306a15e945e694afba62dc93b17500ffaec7f.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/mailers/notify_spec.rb')
-rw-r--r-- | spec/mailers/notify_spec.rb | 82 |
1 files changed, 82 insertions, 0 deletions
diff --git a/spec/mailers/notify_spec.rb b/spec/mailers/notify_spec.rb index ab45f9472a3..53ce200eed5 100644 --- a/spec/mailers/notify_spec.rb +++ b/spec/mailers/notify_spec.rb @@ -1615,6 +1615,88 @@ RSpec.describe Notify do is_expected.to have_body_text group_member.invite_email end end + + describe 'group expiration date updated' do + let_it_be(:group_member) { create(:group_member, group: group, expires_at: 1.day.from_now) } + + context 'when expiration date is changed' do + subject { described_class.member_expiration_date_updated_email('group', group_member.id) } + + 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' + + context 'when expiration date is one day away' do + it 'contains all the useful information' do + is_expected.to have_subject 'Group membership expiration date changed' + is_expected.to have_body_text group_member.user.name + is_expected.to have_body_text group.name + is_expected.to have_body_text group.web_url + is_expected.to have_body_text group_group_members_url(group, search: group_member.user.username) + is_expected.to have_body_text 'day.' + is_expected.not_to have_body_text 'days.' + end + end + + context 'when expiration date is more than one day away' do + before do + group_member.update!(expires_at: 20.days.from_now) + end + + it 'contains all the useful information' do + is_expected.to have_subject 'Group membership expiration date changed' + is_expected.to have_body_text group_member.user.name + is_expected.to have_body_text group.name + is_expected.to have_body_text group.web_url + is_expected.to have_body_text group_group_members_url(group, search: group_member.user.username) + is_expected.to have_body_text 'days.' + is_expected.not_to have_body_text 'day.' + end + end + + context 'when a group member is newly given an expiration date' do + let_it_be(:group_member) { create(:group_member, group: group) } + + before do + group_member.update!(expires_at: 5.days.from_now) + end + + subject { described_class.member_expiration_date_updated_email('group', group_member.id) } + + it 'contains all the useful information' do + is_expected.to have_subject 'Group membership expiration date changed' + is_expected.to have_body_text group_member.user.name + is_expected.to have_body_text group.name + is_expected.to have_body_text group.web_url + is_expected.to have_body_text group_group_members_url(group, search: group_member.user.username) + is_expected.to have_body_text 'days.' + is_expected.not_to have_body_text 'day.' + end + end + end + + context 'when expiration date is removed' do + before do + group_member.update!(expires_at: nil) + end + + subject { described_class.member_expiration_date_updated_email('group', group_member.id) } + + 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 'contains all the useful information' do + is_expected.to have_subject 'Group membership expiration date removed' + is_expected.to have_body_text group_member.user.name + is_expected.to have_body_text group.name + end + end + end end describe 'confirmation if email changed' do |