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 2c99f16
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
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
8 changes: 8 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,12 @@
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_attribute(email: '[email protected]')
EmailConfirmationWorker.new.perform(user.id)
puts ActionMailer::Base.deliveries.inspect
expect(User.count).to be_zero
end
end

0 comments on commit 2c99f16

Please sign in to comment.