Skip to content

Commit 95a6570

Browse files
committed
Send welcome email for magic sign-in auto-confirm
1 parent 832e7cd commit 95a6570

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

app/lib/warden_extensions/setup.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ def configure_manager
2222
case auth.winning_strategy&.key
2323
when :magic_session
2424
user.confirm!
25+
WelcomeNotifier.deliver_to(user)
2526
when :password
2627
# no op
2728
else # nil, as with test helpers

spec/requests/users/sessions_spec.rb

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
expect(user.reload.last_sign_in_at).to be_present
5050
end
5151

52-
it "signs in unconfirmed user with valid magic session token" do
52+
it "signs in and confirms unconfirmed user with valid magic session token" do
5353
user = FactoryBot.create(:user, :unconfirmed)
5454
token = user.generate_token_for(:magic_session)
5555
expect(user.last_sign_in_at).to be_nil
@@ -65,6 +65,13 @@
6565

6666
expect(user.last_sign_in_at).to be_present
6767
expect(user).to be_confirmed
68+
69+
perform_enqueued_jobs_and_subsequently_enqueued_jobs
70+
71+
expect(ActionMailer::Base.deliveries.count).to eq(1)
72+
73+
mail = find_mail_to(user.email)
74+
expect(mail.subject).to eq("Welcome to Joy of Rails!")
6875
end
6976

7077
it "disallows when user not found with given email" do

0 commit comments

Comments
 (0)