diff options
author | Robert Speicher <rspeicher@gmail.com> | 2021-01-20 13:34:23 -0600 |
---|---|---|
committer | Robert Speicher <rspeicher@gmail.com> | 2021-01-20 13:34:23 -0600 |
commit | 6438df3a1e0fb944485cebf07976160184697d72 (patch) | |
tree | 00b09bfd170e77ae9391b1a2f5a93ef6839f2597 /spec/mailers | |
parent | 42bcd54d971da7ef2854b896a7b34f4ef8601067 (diff) | |
download | gitlab-ce-6438df3a1e0fb944485cebf07976160184697d72.tar.gz |
Add latest changes from gitlab-org/gitlab@13-8-stable-eev13.8.0-rc42
Diffstat (limited to 'spec/mailers')
-rw-r--r-- | spec/mailers/emails/merge_requests_spec.rb | 2 | ||||
-rw-r--r-- | spec/mailers/emails/pipelines_spec.rb | 32 | ||||
-rw-r--r-- | spec/mailers/notify_spec.rb | 86 |
3 files changed, 103 insertions, 17 deletions
diff --git a/spec/mailers/emails/merge_requests_spec.rb b/spec/mailers/emails/merge_requests_spec.rb index 412cdff3aba..34665d943ab 100644 --- a/spec/mailers/emails/merge_requests_spec.rb +++ b/spec/mailers/emails/merge_requests_spec.rb @@ -64,7 +64,7 @@ RSpec.describe Emails::MergeRequests do } end - it { expect(subject).to have_content('This attachment has been truncated to avoid exceeding the maximum allowed attachment size of 15MB.') } + it { expect(subject).to have_content('attachment has been truncated to avoid exceeding the maximum allowed attachment size of 15 MB.') } end end end diff --git a/spec/mailers/emails/pipelines_spec.rb b/spec/mailers/emails/pipelines_spec.rb index f0f23fe2097..3ac68721357 100644 --- a/spec/mailers/emails/pipelines_spec.rb +++ b/spec/mailers/emails/pipelines_spec.rb @@ -11,8 +11,8 @@ RSpec.describe Emails::Pipelines do shared_examples_for 'correct pipeline information' do it 'has a correct information' do expect(subject) - .to have_subject "#{project.name} | Pipeline ##{pipeline.id} has " \ - "#{status} for #{pipeline.source_ref} | " \ + .to have_subject "#{status} pipeline for #{pipeline.source_ref} | " \ + "#{project.name} | " \ "#{pipeline.short_sha}".to_s expect(subject).to have_body_text pipeline.source_ref @@ -29,8 +29,8 @@ RSpec.describe Emails::Pipelines do it 'has correct information that there is no merge request link' do expect(subject) - .to have_subject "#{project.name} | Pipeline ##{pipeline.id} has " \ - "#{status} for #{pipeline.source_ref} | " \ + .to have_subject "#{status} pipeline for #{pipeline.source_ref} | " \ + "#{project.name} | " \ "#{pipeline.short_sha}".to_s expect(subject).to have_body_text pipeline.source_ref @@ -49,9 +49,9 @@ RSpec.describe Emails::Pipelines do it 'has correct information that there is a merge request link' do expect(subject) - .to have_subject "#{project.name} | Pipeline ##{pipeline.id} has " \ - "#{status} for #{pipeline.source_ref} | " \ - "#{pipeline.short_sha} in !#{merge_request.iid}".to_s + .to have_subject "#{status} pipeline for #{pipeline.source_ref} | " \ + "#{project.name} | " \ + "#{pipeline.short_sha}".to_s expect(subject).to have_body_text merge_request.to_reference expect(subject).to have_body_text pipeline.source_ref @@ -71,9 +71,9 @@ RSpec.describe Emails::Pipelines do it 'has correct information that there is a merge request link' do expect(subject) - .to have_subject "#{project.name} | Pipeline ##{pipeline.id} has " \ - "#{status} for #{pipeline.source_ref} | " \ - "#{pipeline.short_sha} in !#{merge_request.iid}".to_s + .to have_subject "#{status} pipeline for #{pipeline.source_ref} | " \ + "#{project.name} | " \ + "#{pipeline.short_sha}".to_s expect(subject).to have_body_text merge_request.to_reference expect(subject).to have_body_text pipeline.source_ref @@ -89,8 +89,8 @@ RSpec.describe Emails::Pipelines do let(:sha) { project.commit(ref).sha } it_behaves_like 'correct pipeline information' do - let(:status) { 'succeeded' } - let(:status_text) { 'Your pipeline has passed.' } + let(:status) { 'Succesful' } + let(:status_text) { "Pipeline ##{pipeline.id} has passed!" } end end @@ -102,8 +102,8 @@ RSpec.describe Emails::Pipelines do let(:sha) { project.commit(ref).sha } it_behaves_like 'correct pipeline information' do - let(:status) { 'failed' } - let(:status_text) { 'Your pipeline has failed.' } + let(:status) { 'Failed' } + let(:status_text) { "Pipeline ##{pipeline.id} has failed!" } end end @@ -115,8 +115,8 @@ RSpec.describe Emails::Pipelines do let(:sha) { project.commit(ref).sha } it_behaves_like 'correct pipeline information' do - let(:status) { 'been fixed' } - let(:status_text) { 'Your pipeline has been fixed!' } + let(:status) { 'Fixed' } + let(:status_text) { "Pipeline has been fixed and ##{pipeline.id} has passed!" } end end end 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 |