Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delete user if email isn't confirmable #366

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions app/workers/email_confirmation_worker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,7 @@ class EmailConfirmationWorker
def perform(user_id)
user = User.find(user_id)
CustomerMailer.confirmation_email(user).deliver_now
rescue Net::SMTPSyntaxError
user.destroy
end
end
7 changes: 7 additions & 0 deletions spec/workers/email_confirmation_worker_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,11 @@
EmailConfirmationWorker.new.perform(user.id)
expect(ActionMailer::Base.deliveries.empty?).to be_falsey
end

it 'deletes user if email is invalid' do
user = FactoryGirl.create(:user)
user.update(email: 'notaemail@fakeonotreal.blorgh')
EmailConfirmationWorker.new.perform(user.id)
expect(User.count).to be_zero
end
end