2019-04-29 19:27:42 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2015-08-24 01:21:34 -05:00
|
|
|
describe UserActivator do
|
2021-11-25 01:34:39 -06:00
|
|
|
fab!(:user) { Fabricate(:user) }
|
|
|
|
let!(:email_token) { Fabricate(:email_token, user: user) }
|
2015-08-24 01:21:34 -05:00
|
|
|
|
|
|
|
describe 'email_activator' do
|
2021-11-25 01:34:39 -06:00
|
|
|
let(:activator) { EmailActivator.new(user, nil, nil, nil) }
|
2015-08-24 01:21:34 -05:00
|
|
|
|
2021-11-25 01:34:39 -06:00
|
|
|
it 'create email token and enqueues user email' do
|
2020-03-10 16:13:17 -05:00
|
|
|
now = freeze_time
|
2021-11-25 01:34:39 -06:00
|
|
|
activator.activate
|
2020-07-24 04:16:52 -05:00
|
|
|
email_token = user.reload.email_tokens.last
|
|
|
|
expect(email_token.created_at).to eq_time(now)
|
2021-11-25 01:34:39 -06:00
|
|
|
job_args = Jobs::CriticalUserEmail.jobs.last["args"].first
|
|
|
|
expect(job_args["user_id"]).to eq(user.id)
|
|
|
|
expect(job_args["type"]).to eq("signup")
|
|
|
|
expect(EmailToken.hash_token(job_args["email_token"])).to eq(email_token.token_hash)
|
2015-08-24 01:21:34 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|