Do not prepare returning user for unpersisted records (#38136)

This commit is contained in:
Matt Jankowski
2026-03-10 12:37:59 -04:00
committed by GitHub
parent 3b6d94ce62
commit 64629eadb7
2 changed files with 8 additions and 2 deletions

View File

@@ -209,8 +209,10 @@ class User < ApplicationRecord
increment(:sign_in_count) if new_sign_in
save(validate: false) unless new_record?
prepare_returning_user!
unless new_record?
save(validate: false)
prepare_returning_user!
end
end
def pending?

View File

@@ -208,9 +208,13 @@ RSpec.describe User do
context 'with a new user' do
let(:user) { Fabricate.build :user }
before { allow(ActivityTracker).to receive(:record) }
it 'does not persist the user' do
expect { user.update_sign_in! }
.to_not change(user, :persisted?).from(false)
expect(ActivityTracker)
.to_not have_received(:record).with('activity:logins', anything)
end
end
end