diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-07-12 18:09:19 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-07-12 18:09:19 +0300 |
commit | d9b3f39acad88d81eb7a75627c4325651fb7ff13 (patch) | |
tree | 9a10f44168d0d401c15b664c17e8a353674203b5 /spec/mailers | |
parent | f81141c25d0dd79de8c07559bf268cb6e0d287d3 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/mailers')
-rw-r--r-- | spec/mailers/emails/admin_notification_spec.rb | 11 | ||||
-rw-r--r-- | spec/mailers/notify_spec.rb | 26 |
2 files changed, 37 insertions, 0 deletions
diff --git a/spec/mailers/emails/admin_notification_spec.rb b/spec/mailers/emails/admin_notification_spec.rb new file mode 100644 index 00000000000..90381eb8ffd --- /dev/null +++ b/spec/mailers/emails/admin_notification_spec.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Emails::AdminNotification do + it 'adds email methods to Notify' do + subject.instance_methods.each do |email_method| + expect(Notify).to be_respond_to(email_method) + end + end +end diff --git a/spec/mailers/notify_spec.rb b/spec/mailers/notify_spec.rb index 3b1694527d3..ae956adf563 100644 --- a/spec/mailers/notify_spec.rb +++ b/spec/mailers/notify_spec.rb @@ -1609,6 +1609,32 @@ RSpec.describe Notify do end end end + + describe 'admin notification' do + let(:example_site_path) { root_path } + let(:user) { create(:user) } + + subject { @email = described_class.send_admin_notification(user.id, 'Admin announcement', 'Text') } + + it 'is sent as the author' do + sender = subject.header[:from].addrs[0] + expect(sender.display_name).to eq("GitLab") + expect(sender.address).to eq(gitlab_sender) + end + + it 'is sent to recipient' do + is_expected.to deliver_to user.email + end + + it 'has the correct subject' do + is_expected.to have_subject 'Admin announcement' + end + + it 'includes unsubscribe link' do + unsubscribe_link = "http://localhost/unsubscribes/#{Base64.urlsafe_encode64(user.email)}" + is_expected.to have_body_text(unsubscribe_link) + end + end end describe 'confirmation if email changed' do |