diff --git a/app/services/email_notifier.rb b/app/services/email_notifier.rb deleted file mode 100644 index cf95652032a..00000000000 --- a/app/services/email_notifier.rb +++ /dev/null @@ -1,19 +0,0 @@ -EmailNotifier = Struct.new(:user) do - def send_email_changed_email - UserMailer.email_changed(old_email).deliver_now_or_later if email_changed? - end - - private - - def email_changed? - changed_attributes.fetch('email_fingerprint', false) - end - - def changed_attributes - @changed_attributes ||= user.previous_changes - end - - def old_email - EncryptedAttribute.new(changed_attributes['encrypted_email'].first).decrypted - end -end diff --git a/spec/forms/update_user_password_form_spec.rb b/spec/forms/update_user_password_form_spec.rb index 855062750ad..f745eac0cd9 100644 --- a/spec/forms/update_user_password_form_spec.rb +++ b/spec/forms/update_user_password_form_spec.rb @@ -25,7 +25,6 @@ } expect(UpdateUser).not_to receive(:new) - expect(EmailNotifier).not_to receive(:new) expect(ActiveProfileEncryptor).not_to receive(:new) expect(subject.submit(params).to_h).to include( success: false, diff --git a/spec/services/email_notifier_spec.rb b/spec/services/email_notifier_spec.rb deleted file mode 100644 index d3870b277e9..00000000000 --- a/spec/services/email_notifier_spec.rb +++ /dev/null @@ -1,28 +0,0 @@ -require 'rails_helper' - -describe EmailNotifier do - describe '#send_email_changed_email' do - context 'when the email has not changed' do - it 'does not send an email' do - user = build_stubbed(:user, :signed_up) - - expect(UserMailer).to_not receive(:email_changed).with(user.email) - - EmailNotifier.new(user).send_email_changed_email - end - end - - context 'when the user has changed and confirmed their new email' do - it 'notifies the old email address of the email change' do - user = create(:user, :signed_up) - old_email = user.email - UpdateUser.new(user: user, attributes: { email: 'new@example.com' }).call - - expect(UserMailer).to receive(:email_changed).with(old_email).and_return(mailer) - expect(mailer).to receive(:deliver_now_or_later) - - EmailNotifier.new(user).send_email_changed_email - end - end - end -end