diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-06-20 14:10:13 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-06-20 14:10:13 +0300 |
commit | 0ea3fcec397b69815975647f5e2aa5fe944a8486 (patch) | |
tree | 7979381b89d26011bcf9bdc989a40fcc2f1ed4ff /spec/mailers | |
parent | 72123183a20411a36d607d70b12d57c484394c8e (diff) |
Add latest changes from gitlab-org/gitlab@15-1-stable-eev15.1.0-rc42
Diffstat (limited to 'spec/mailers')
-rw-r--r-- | spec/mailers/emails/admin_notification_spec.rb | 53 | ||||
-rw-r--r-- | spec/mailers/notify_spec.rb | 2 |
2 files changed, 54 insertions, 1 deletions
diff --git a/spec/mailers/emails/admin_notification_spec.rb b/spec/mailers/emails/admin_notification_spec.rb index 90381eb8ffd..a233be86a83 100644 --- a/spec/mailers/emails/admin_notification_spec.rb +++ b/spec/mailers/emails/admin_notification_spec.rb @@ -3,9 +3,62 @@ require 'spec_helper' RSpec.describe Emails::AdminNotification do + include EmailSpec::Matchers + include_context 'gitlab email notification' + it 'adds email methods to Notify' do subject.instance_methods.each do |email_method| expect(Notify).to be_respond_to(email_method) end end + + describe 'user_auto_banned_email' do + let_it_be(:admin) { create(:user) } + let_it_be(:user) { create(:user) } + + let(:max_project_downloads) { 5 } + let(:time_period) { 600 } + + subject do + Notify.user_auto_banned_email( + admin.id, user.id, + max_project_downloads: max_project_downloads, + within_seconds: time_period + ) + 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 'is sent to the administrator' do + is_expected.to deliver_to admin.email + end + + it 'has the correct subject' do + is_expected.to have_subject "We've detected unusual activity" + end + + it 'includes the name of the user' do + is_expected.to have_body_text user.name + end + + it 'includes the reason' do + is_expected.to have_body_text "due to them downloading more than 5 project repositories within 10 minutes" + end + + it 'includes a link to unban the user' do + is_expected.to have_body_text admin_users_url(filter: 'banned') + end + + it 'includes a link to change the settings' do + is_expected.to have_body_text network_admin_application_settings_url(anchor: 'js-ip-limits-settings') + end + + it 'includes the email reason' do + is_expected.to have_body_text "You're receiving this email because of your account on localhost" + end + end end diff --git a/spec/mailers/notify_spec.rb b/spec/mailers/notify_spec.rb index b6ad66f41b5..a9796c28870 100644 --- a/spec/mailers/notify_spec.rb +++ b/spec/mailers/notify_spec.rb @@ -1858,7 +1858,7 @@ RSpec.describe Notify do end end - subject { ActionMailer::Base.deliveries.last } + subject { ActionMailer::Base.deliveries.first } it_behaves_like 'an email sent from GitLab' it_behaves_like "a user cannot unsubscribe through footer link" |