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