diff options
Diffstat (limited to 'spec/mailers')
-rw-r--r-- | spec/mailers/emails/profile_spec.rb | 42 | ||||
-rw-r--r-- | spec/mailers/notify_spec.rb | 32 |
2 files changed, 56 insertions, 18 deletions
diff --git a/spec/mailers/emails/profile_spec.rb b/spec/mailers/emails/profile_spec.rb index 767eddb7f98..cdc298d685e 100644 --- a/spec/mailers/emails/profile_spec.rb +++ b/spec/mailers/emails/profile_spec.rb @@ -152,7 +152,7 @@ RSpec.describe Emails::Profile do end it 'includes the email reason' do - is_expected.to have_body_text %r{You're receiving this email because of your account on <a .*>localhost<\/a>} + is_expected.to have_body_text %r{You're receiving this email because of your account on <a .*>localhost</a>} end end end @@ -188,7 +188,7 @@ RSpec.describe Emails::Profile do end it 'includes the email reason' do - is_expected.to have_body_text %r{You're receiving this email because of your account on <a .*>localhost<\/a>} + is_expected.to have_body_text %r{You're receiving this email because of your account on <a .*>localhost</a>} end context 'with User does not exist' do @@ -223,7 +223,7 @@ RSpec.describe Emails::Profile do end it 'includes the email reason' do - is_expected.to have_body_text %r{You're receiving this email because of your account on <a .*>localhost<\/a>} + is_expected.to have_body_text %r{You're receiving this email because of your account on <a .*>localhost</a>} end end @@ -269,8 +269,40 @@ RSpec.describe Emails::Profile do is_expected.to have_body_text /#{token.name}/ end + it 'wont include the revocation reason' do + is_expected.not_to have_body_text %r{We found your token in a public project and have automatically revoked it to protect your account.$} + end + + it 'includes the email reason' do + is_expected.to have_body_text %r{You're receiving this email because of your account on <a .*>localhost</a>} + end + end + + context 'when source is provided' do + subject { Notify.access_token_revoked_email(user, token.name, 'secret_detection') } + + 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 'is sent to the user' do + is_expected.to deliver_to user.email + end + + it 'has the correct subject' do + is_expected.to have_subject /^A personal access token has been revoked$/i + end + + it 'provides the names of the token' do + is_expected.to have_body_text /#{token.name}/ + end + + it 'includes the revocation reason' do + is_expected.to have_body_text %r{We found your token in a public project and have automatically revoked it to protect your account.$} + end + it 'includes the email reason' do - is_expected.to have_body_text %r{You're receiving this email because of your account on <a .*>localhost<\/a>} + is_expected.to have_body_text %r{You're receiving this email because of your account on <a .*>localhost</a>} end end end @@ -296,7 +328,7 @@ RSpec.describe Emails::Profile do end shared_examples 'includes the email reason' do - it { is_expected.to have_body_text %r{You're receiving this email because of your account on <a .*>localhost<\/a>} } + it { is_expected.to have_body_text %r{You're receiving this email because of your account on <a .*>localhost</a>} } end shared_examples 'valid use case' do diff --git a/spec/mailers/notify_spec.rb b/spec/mailers/notify_spec.rb index 5733e892d2a..684fe9bb9cf 100644 --- a/spec/mailers/notify_spec.rb +++ b/spec/mailers/notify_spec.rb @@ -419,15 +419,15 @@ RSpec.describe Notify do end it 'includes the reason in the footer' do - text = EmailsHelper.instance_method(:notification_reason_text).bind(self).call(reason: NotificationReason::ASSIGNED, format: :html) + text = EmailsHelper.instance_method(:notification_reason_text).bind_call(self, reason: NotificationReason::ASSIGNED, format: :html) is_expected.to have_body_text(text) new_subject = described_class.reassigned_merge_request_email(recipient.id, merge_request.id, [previous_assignee.id], current_user.id, NotificationReason::MENTIONED) - text = EmailsHelper.instance_method(:notification_reason_text).bind(self).call(reason: NotificationReason::MENTIONED, format: :html) + text = EmailsHelper.instance_method(:notification_reason_text).bind_call(self, reason: NotificationReason::MENTIONED, format: :html) expect(new_subject).to have_body_text(text) new_subject = described_class.reassigned_merge_request_email(recipient.id, merge_request.id, [previous_assignee.id], current_user.id, nil) - text = EmailsHelper.instance_method(:notification_reason_text).bind(self).call(format: :html) + text = EmailsHelper.instance_method(:notification_reason_text).bind_call(self, format: :html) expect(new_subject).to have_body_text(text) end end @@ -649,16 +649,20 @@ RSpec.describe Notify do end context 'the model has no namespace' do - class TopLevelThing - include Referable - include Noteable + before do + stub_const('TopLevelThing', Class.new) - def to_reference(*_args) - 'tlt-ref' - end + TopLevelThing.class_eval do + include Referable + include Noteable - def id - 'tlt-id' + def to_reference(*_args) + 'tlt-ref' + end + + def id + 'tlt-id' + end end end @@ -672,8 +676,10 @@ RSpec.describe Notify do end context 'the model has a namespace' do - module Namespaced - class Thing + before do + stub_const('Namespaced::Thing', Class.new) + + Namespaced::Thing.class_eval do include Referable include Noteable |