Skip to content

Commit

Permalink
Delete user if email isn't confirmable
Browse files Browse the repository at this point in the history
  • Loading branch information
mftaff committed Jan 23, 2018
1 parent 0fdc38e commit 3c8a705
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
2 changes: 2 additions & 0 deletions app/workers/email_confirmation_worker.rb
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
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

0 comments on commit 3c8a705

Please sign in to comment.