diff --git a/app/models/user_associated_account.rb b/app/models/user_associated_account.rb index ef85326ef1e..d21078153cb 100644 --- a/app/models/user_associated_account.rb +++ b/app/models/user_associated_account.rb @@ -4,7 +4,7 @@ class UserAssociatedAccount < ActiveRecord::Base def self.cleanup! # This happens when a user starts the registration flow, but doesn't complete it # Keeping the rows doesn't cause any technical issue, but we shouldn't store PII unless it's attached to a user - self.where("user_id IS NULL AND updated_at < ?", 1.day.ago).destroy_all + self.where("user_id IS NULL AND updated_at < ?", 1.day.ago).delete_all end end diff --git a/spec/components/auth/managed_authenticator_spec.rb b/spec/components/auth/managed_authenticator_spec.rb index 870536be183..63950ce0d15 100644 --- a/spec/components/auth/managed_authenticator_spec.rb +++ b/spec/components/auth/managed_authenticator_spec.rb @@ -117,13 +117,12 @@ describe Auth::ManagedAuthenticator do context 'when no matching user' do it 'returns the correct information' do - result = nil expect { result = authenticator.after_authenticate(hash) + expect(result.user).to eq(nil) + expect(result.username).to eq("IAmGroot") + expect(result.email).to eq("awesome@example.com") }.to change { UserAssociatedAccount.count }.by(1) - expect(result.user).to eq(nil) - expect(result.username).to eq("IAmGroot") - expect(result.email).to eq("awesome@example.com") expect(UserAssociatedAccount.last.user).to eq(nil) expect(UserAssociatedAccount.last.info["nickname"]).to eq("IAmGroot") end diff --git a/spec/jobs/clean_up_associated_accounts_spec.rb b/spec/jobs/clean_up_associated_accounts_spec.rb index 4874ad53320..38502b8fb74 100644 --- a/spec/jobs/clean_up_associated_accounts_spec.rb +++ b/spec/jobs/clean_up_associated_accounts_spec.rb @@ -6,9 +6,9 @@ describe Jobs::CleanUpAssociatedAccounts do it "deletes the correct records" do freeze_time - last_week = UserAssociatedAccount.create(provider_name: "twitter", provider_uid: "1", updated_at: 7.days.ago) - today = UserAssociatedAccount.create(provider_name: "twitter", provider_uid: "12", updated_at: 12.hours.ago) - connected = UserAssociatedAccount.create(provider_name: "twitter", provider_uid: "123", user: Fabricate(:user), updated_at: 12.hours.ago) + last_week = UserAssociatedAccount.create!(provider_name: "twitter", provider_uid: "1", updated_at: 7.days.ago) + today = UserAssociatedAccount.create!(provider_name: "twitter", provider_uid: "12", updated_at: 12.hours.ago) + connected = UserAssociatedAccount.create!(provider_name: "twitter", provider_uid: "123", user: Fabricate(:user), updated_at: 12.hours.ago) expect { subject }.to change { UserAssociatedAccount.count }.by(-1) expect(UserAssociatedAccount.all).to contain_exactly(today, connected)