parent
671469bcc7
commit
3fedb2ad20
|
@ -4,7 +4,7 @@ class UserAssociatedAccount < ActiveRecord::Base
|
||||||
def self.cleanup!
|
def self.cleanup!
|
||||||
# This happens when a user starts the registration flow, but doesn't complete it
|
# 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
|
# 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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -117,13 +117,12 @@ describe Auth::ManagedAuthenticator do
|
||||||
|
|
||||||
context 'when no matching user' do
|
context 'when no matching user' do
|
||||||
it 'returns the correct information' do
|
it 'returns the correct information' do
|
||||||
result = nil
|
|
||||||
expect {
|
expect {
|
||||||
result = authenticator.after_authenticate(hash)
|
result = authenticator.after_authenticate(hash)
|
||||||
}.to change { UserAssociatedAccount.count }.by(1)
|
|
||||||
expect(result.user).to eq(nil)
|
expect(result.user).to eq(nil)
|
||||||
expect(result.username).to eq("IAmGroot")
|
expect(result.username).to eq("IAmGroot")
|
||||||
expect(result.email).to eq("awesome@example.com")
|
expect(result.email).to eq("awesome@example.com")
|
||||||
|
}.to change { UserAssociatedAccount.count }.by(1)
|
||||||
expect(UserAssociatedAccount.last.user).to eq(nil)
|
expect(UserAssociatedAccount.last.user).to eq(nil)
|
||||||
expect(UserAssociatedAccount.last.info["nickname"]).to eq("IAmGroot")
|
expect(UserAssociatedAccount.last.info["nickname"]).to eq("IAmGroot")
|
||||||
end
|
end
|
||||||
|
|
|
@ -6,9 +6,9 @@ describe Jobs::CleanUpAssociatedAccounts do
|
||||||
it "deletes the correct records" do
|
it "deletes the correct records" do
|
||||||
freeze_time
|
freeze_time
|
||||||
|
|
||||||
last_week = UserAssociatedAccount.create(provider_name: "twitter", provider_uid: "1", updated_at: 7.days.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)
|
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)
|
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 { subject }.to change { UserAssociatedAccount.count }.by(-1)
|
||||||
expect(UserAssociatedAccount.all).to contain_exactly(today, connected)
|
expect(UserAssociatedAccount.all).to contain_exactly(today, connected)
|
||||||
|
|
Loading…
Reference in New Issue