Skip to content

Commit 016af03

Browse files
committed
Lookup user by id, not username - fixes AR::RecordNotFound.
1 parent 5cf94c5 commit 016af03

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

app/workers/user_activate_worker.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ def perform(user_id)
66
user = User.find(user_id)
77
return if user.active?
88

9-
RefreshUserJob.new.perform(user.username)
9+
RefreshUserJob.new.perform(user.id)
1010
NotifierMailer.welcome_email(user.username).deliver
1111

1212
user.activate!

spec/workers/user_activate_worker_spec.rb

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,19 @@
2222
expect(user.active?).to eq(true)
2323
expect(user.activated_on).not_to eq(nil)
2424
end
25+
26+
it "should send welcome mail" do
27+
mail = double("mail")
28+
expect(NotifierMailer).to receive(:welcome_email).with(user.username).and_return(mail)
29+
expect(mail).to receive(:deliver)
30+
worker.perform(user.id)
31+
end
32+
33+
it "should create refresh job" do
34+
expect_any_instance_of(RefreshUserJob).to receive(:perform).with(user.id)
35+
worker.perform(user.id)
36+
end
37+
2538
end
2639

2740
context 'when activate user' do

0 commit comments

Comments
 (0)