summaryrefslogtreecommitdiff
path: root/spec/mailers/notify_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/mailers/notify_spec.rb')
-rw-r--r--spec/mailers/notify_spec.rb86
1 files changed, 86 insertions, 0 deletions
diff --git a/spec/mailers/notify_spec.rb b/spec/mailers/notify_spec.rb
index 3ebc2fc1e36..53ce200eed5 100644
--- a/spec/mailers/notify_spec.rb
+++ b/spec/mailers/notify_spec.rb
@@ -224,6 +224,10 @@ RSpec.describe Notify do
let(:model) { issue }
end
+ it 'contains a link to the issue' do
+ is_expected.to have_body_text(issue.to_reference(full: false))
+ end
+
it_behaves_like 'it should show Gmail Actions View Issue link'
it_behaves_like 'an unsubscribeable thread'
it_behaves_like 'appearance header and footer enabled'
@@ -1611,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