optimize enqueuing activation email code

This commit is contained in:
Arpit Jalan 2017-07-31 22:57:39 +05:30
parent 0b01d0e95d
commit 6c997b65d9
2 changed files with 2 additions and 2 deletions

View File

@ -650,7 +650,7 @@ class UsersController < ApplicationController
def enqueue_activation_email
@email_token ||= @user.email_tokens.create(email: @user.email)
Jobs.enqueue_in(1.second, :critical_user_email, type: :signup, user_id: @user.id, email_token: @email_token.token)
Jobs.enqueue(:critical_user_email, type: :signup, user_id: @user.id, email_token: @email_token.token, to_address: @user.email)
end
def search_users

View File

@ -1498,7 +1498,7 @@ describe UsersController do
unconfirmed_email_user = Fabricate(:user, active: true)
unconfirmed_email_user.email_tokens.create(email: unconfirmed_email_user.email)
session[SessionController::ACTIVATE_USER_KEY] = unconfirmed_email_user.id
Jobs.expects(:enqueue).with(:critical_user_email, has_entries(type: :signup))
Jobs.expects(:enqueue).with(:critical_user_email, has_entries(type: :signup, to_address: unconfirmed_email_user.email))
xhr :post, :send_activation_email, username: unconfirmed_email_user.username
expect(response.status).to eq(200)