Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix linting issue #26106

Merged
merged 1 commit into from Jul 21, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
30 changes: 15 additions & 15 deletions spec/lib/vacuum/applications_vacuum_spec.rb
Expand Up @@ -6,43 +6,43 @@
subject { described_class.new }

describe '#perform' do
let!(:app1) { Fabricate(:application, created_at: 1.month.ago) }
let!(:app2) { Fabricate(:application, created_at: 1.month.ago) }
let!(:app3) { Fabricate(:application, created_at: 1.month.ago) }
let!(:app4) { Fabricate(:application, created_at: 1.month.ago, owner: Fabricate(:user)) }
let!(:app5) { Fabricate(:application, created_at: 1.month.ago) }
let!(:app6) { Fabricate(:application, created_at: 1.hour.ago) }
let!(:app_with_token) { Fabricate(:application, created_at: 1.month.ago) }
let!(:app_with_grant) { Fabricate(:application, created_at: 1.month.ago) }
let!(:app_with_signup) { Fabricate(:application, created_at: 1.month.ago) }
let!(:app_with_owner) { Fabricate(:application, created_at: 1.month.ago, owner: Fabricate(:user)) }
let!(:unused_app) { Fabricate(:application, created_at: 1.month.ago) }
let!(:recent_app) { Fabricate(:application, created_at: 1.hour.ago) }

let!(:active_access_token) { Fabricate(:access_token, application: app1) }
let!(:active_access_grant) { Fabricate(:access_grant, application: app2) }
let!(:user) { Fabricate(:user, created_by_application: app3) }
let!(:active_access_token) { Fabricate(:access_token, application: app_with_token) }
let!(:active_access_grant) { Fabricate(:access_grant, application: app_with_grant) }
let!(:user) { Fabricate(:user, created_by_application: app_with_signup) }

before do
subject.perform
end

it 'does not delete applications with valid access tokens' do
expect { app1.reload }.to_not raise_error
expect { app_with_token.reload }.to_not raise_error
end

it 'does not delete applications with valid access grants' do
expect { app2.reload }.to_not raise_error
expect { app_with_grant.reload }.to_not raise_error
end

it 'does not delete applications that were used to create users' do
expect { app3.reload }.to_not raise_error
expect { app_with_signup.reload }.to_not raise_error
end

it 'does not delete owned applications' do
expect { app4.reload }.to_not raise_error
expect { app_with_owner.reload }.to_not raise_error
end

it 'does not delete applications registered less than a day ago' do
expect { app6.reload }.to_not raise_error
expect { recent_app.reload }.to_not raise_error
end

it 'deletes unused applications' do
expect { app5.reload }.to raise_error ActiveRecord::RecordNotFound
expect { unused_app.reload }.to raise_error ActiveRecord::RecordNotFound
end
end
end