2019-04-30 08:27:42 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2022-07-28 10:27:38 +08:00
|
|
|
RSpec.describe UserActivator do
|
2021-11-25 15:34:39 +08:00
|
|
|
fab!(:user) { Fabricate(:user) }
|
|
|
|
let!(:email_token) { Fabricate(:email_token, user: user) }
|
2015-08-24 14:21:34 +08:00
|
|
|
|
|
|
|
describe 'email_activator' do
|
2021-11-25 15:34:39 +08:00
|
|
|
let(:activator) { EmailActivator.new(user, nil, nil, nil) }
|
2015-08-24 14:21:34 +08:00
|
|
|
|
2021-11-25 15:34:39 +08:00
|
|
|
it 'create email token and enqueues user email' do
|
2020-03-11 05:13:17 +08:00
|
|
|
now = freeze_time
|
2021-11-25 15:34:39 +08:00
|
|
|
activator.activate
|
2020-07-24 17:16:52 +08:00
|
|
|
email_token = user.reload.email_tokens.last
|
|
|
|
expect(email_token.created_at).to eq_time(now)
|
2021-11-25 15:34:39 +08: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 14:21:34 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|