Browse Source

Autofix Rubocop RSpec/BeNil (#23653)

closed-social-glitch-2
Nick Schonning 1 year ago
committed by GitHub
parent
commit
68b1071f86
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 22 additions and 41 deletions
  1. +0
    -19
      .rubocop_todo.yml
  2. +1
    -1
      spec/controllers/accounts_controller_spec.rb
  3. +1
    -1
      spec/controllers/activitypub/collections_controller_spec.rb
  4. +1
    -1
      spec/controllers/activitypub/outboxes_controller_spec.rb
  5. +1
    -1
      spec/controllers/activitypub/replies_controller_spec.rb
  6. +1
    -1
      spec/controllers/api/v1/apps_controller_spec.rb
  7. +1
    -1
      spec/controllers/api/v1/statuses_controller_spec.rb
  8. +1
    -1
      spec/controllers/instance_actors_controller_spec.rb
  9. +1
    -1
      spec/controllers/statuses_controller_spec.rb
  10. +10
    -10
      spec/models/account_statuses_cleanup_policy_spec.rb
  11. +1
    -1
      spec/models/concerns/account_interactions_spec.rb
  12. +2
    -2
      spec/models/session_activation_spec.rb
  13. +1
    -1
      spec/models/user_spec.rb

+ 0
- 19
.rubocop_todo.yml View File

@ -914,25 +914,6 @@ RSpec/BeEq:
- 'spec/workers/feed_insert_worker_spec.rb'
- 'spec/workers/regeneration_worker_spec.rb'
# Offense count: 22
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyle.
# SupportedStyles: be, be_nil
RSpec/BeNil:
Exclude:
- 'spec/controllers/accounts_controller_spec.rb'
- 'spec/controllers/activitypub/collections_controller_spec.rb'
- 'spec/controllers/activitypub/outboxes_controller_spec.rb'
- 'spec/controllers/activitypub/replies_controller_spec.rb'
- 'spec/controllers/api/v1/apps_controller_spec.rb'
- 'spec/controllers/api/v1/statuses_controller_spec.rb'
- 'spec/controllers/instance_actors_controller_spec.rb'
- 'spec/controllers/statuses_controller_spec.rb'
- 'spec/models/account_statuses_cleanup_policy_spec.rb'
- 'spec/models/concerns/account_interactions_spec.rb'
- 'spec/models/session_activation_spec.rb'
- 'spec/models/user_spec.rb'
# Offense count: 1
RSpec/BeforeAfterAll:
Exclude:

+ 1
- 1
spec/controllers/accounts_controller_spec.rb View File

@ -8,7 +8,7 @@ RSpec.describe AccountsController, type: :controller do
shared_examples 'cacheable response' do
it 'does not set cookies' do
expect(response.cookies).to be_empty
expect(response.headers['Set-Cookies']).to be nil
expect(response.headers['Set-Cookies']).to be_nil
end
it 'does not set sessions' do

+ 1
- 1
spec/controllers/activitypub/collections_controller_spec.rb View File

@ -10,7 +10,7 @@ RSpec.describe ActivityPub::CollectionsController, type: :controller do
shared_examples 'cacheable response' do
it 'does not set cookies' do
expect(response.cookies).to be_empty
expect(response.headers['Set-Cookies']).to be nil
expect(response.headers['Set-Cookies']).to be_nil
end
it 'does not set sessions' do

+ 1
- 1
spec/controllers/activitypub/outboxes_controller_spec.rb View File

@ -6,7 +6,7 @@ RSpec.describe ActivityPub::OutboxesController, type: :controller do
shared_examples 'cacheable response' do
it 'does not set cookies' do
expect(response.cookies).to be_empty
expect(response.headers['Set-Cookies']).to be nil
expect(response.headers['Set-Cookies']).to be_nil
end
it 'does not set sessions' do

+ 1
- 1
spec/controllers/activitypub/replies_controller_spec.rb View File

@ -11,7 +11,7 @@ RSpec.describe ActivityPub::RepliesController, type: :controller do
shared_examples 'cacheable response' do
it 'does not set cookies' do
expect(response.cookies).to be_empty
expect(response.headers['Set-Cookies']).to be nil
expect(response.headers['Set-Cookies']).to be_nil
end
it 'does not set sessions' do

+ 1
- 1
spec/controllers/api/v1/apps_controller_spec.rb View File

@ -28,7 +28,7 @@ RSpec.describe Api::V1::AppsController, type: :controller do
end
it 'creates an OAuth app' do
expect(Doorkeeper::Application.find_by(name: client_name)).to_not be nil
expect(Doorkeeper::Application.find_by(name: client_name)).to_not be_nil
end
it 'returns client ID and client secret' do

+ 1
- 1
spec/controllers/api/v1/statuses_controller_spec.rb View File

@ -195,7 +195,7 @@ RSpec.describe Api::V1::StatusesController, type: :controller do
end
it 'removes the status' do
expect(Status.find_by(id: status.id)).to be nil
expect(Status.find_by(id: status.id)).to be_nil
end
end

+ 1
- 1
spec/controllers/instance_actors_controller_spec.rb View File

@ -20,7 +20,7 @@ RSpec.describe InstanceActorsController, type: :controller do
it 'does not set cookies' do
expect(response.cookies).to be_empty
expect(response.headers['Set-Cookies']).to be nil
expect(response.headers['Set-Cookies']).to be_nil
end
it 'does not set sessions' do

+ 1
- 1
spec/controllers/statuses_controller_spec.rb View File

@ -8,7 +8,7 @@ describe StatusesController do
shared_examples 'cacheable response' do
it 'does not set cookies' do
expect(response.cookies).to be_empty
expect(response.headers['Set-Cookies']).to be nil
expect(response.headers['Set-Cookies']).to be_nil
end
it 'does not set sessions' do

+ 10
- 10
spec/models/account_statuses_cleanup_policy_spec.rb View File

@ -35,61 +35,61 @@ RSpec.describe AccountStatusesCleanupPolicy, type: :model do
it 'invalidates last_inspected when widened because of keep_direct' do
account_statuses_cleanup_policy.keep_direct = false
account_statuses_cleanup_policy.save
expect(account_statuses_cleanup_policy.last_inspected).to be nil
expect(account_statuses_cleanup_policy.last_inspected).to be_nil
end
it 'invalidates last_inspected when widened because of keep_pinned' do
account_statuses_cleanup_policy.keep_pinned = false
account_statuses_cleanup_policy.save
expect(account_statuses_cleanup_policy.last_inspected).to be nil
expect(account_statuses_cleanup_policy.last_inspected).to be_nil
end
it 'invalidates last_inspected when widened because of keep_polls' do
account_statuses_cleanup_policy.keep_polls = false
account_statuses_cleanup_policy.save
expect(account_statuses_cleanup_policy.last_inspected).to be nil
expect(account_statuses_cleanup_policy.last_inspected).to be_nil
end
it 'invalidates last_inspected when widened because of keep_media' do
account_statuses_cleanup_policy.keep_media = false
account_statuses_cleanup_policy.save
expect(account_statuses_cleanup_policy.last_inspected).to be nil
expect(account_statuses_cleanup_policy.last_inspected).to be_nil
end
it 'invalidates last_inspected when widened because of keep_self_fav' do
account_statuses_cleanup_policy.keep_self_fav = false
account_statuses_cleanup_policy.save
expect(account_statuses_cleanup_policy.last_inspected).to be nil
expect(account_statuses_cleanup_policy.last_inspected).to be_nil
end
it 'invalidates last_inspected when widened because of keep_self_bookmark' do
account_statuses_cleanup_policy.keep_self_bookmark = false
account_statuses_cleanup_policy.save
expect(account_statuses_cleanup_policy.last_inspected).to be nil
expect(account_statuses_cleanup_policy.last_inspected).to be_nil
end
it 'invalidates last_inspected when widened because of higher min_favs' do
account_statuses_cleanup_policy.min_favs = 5
account_statuses_cleanup_policy.save
expect(account_statuses_cleanup_policy.last_inspected).to be nil
expect(account_statuses_cleanup_policy.last_inspected).to be_nil
end
it 'invalidates last_inspected when widened because of disabled min_favs' do
account_statuses_cleanup_policy.min_favs = nil
account_statuses_cleanup_policy.save
expect(account_statuses_cleanup_policy.last_inspected).to be nil
expect(account_statuses_cleanup_policy.last_inspected).to be_nil
end
it 'invalidates last_inspected when widened because of higher min_reblogs' do
account_statuses_cleanup_policy.min_reblogs = 5
account_statuses_cleanup_policy.save
expect(account_statuses_cleanup_policy.last_inspected).to be nil
expect(account_statuses_cleanup_policy.last_inspected).to be_nil
end
it 'invalidates last_inspected when widened because of disable min_reblogs' do
account_statuses_cleanup_policy.min_reblogs = nil
account_statuses_cleanup_policy.save
expect(account_statuses_cleanup_policy.last_inspected).to be nil
expect(account_statuses_cleanup_policy.last_inspected).to be_nil
end
end

+ 1
- 1
spec/models/concerns/account_interactions_spec.rb View File

@ -317,7 +317,7 @@ describe AccountInteractions do
context 'not muting the conversation' do
it 'returns nil' do
is_expected.to be nil
is_expected.to be_nil
end
end
end

+ 2
- 2
spec/models/session_activation_spec.rb View File

@ -44,7 +44,7 @@ RSpec.describe SessionActivation, type: :model do
let(:id) { nil }
it 'returns nil' do
is_expected.to be nil
is_expected.to be_nil
end
end
@ -89,7 +89,7 @@ RSpec.describe SessionActivation, type: :model do
let(:id) { nil }
it 'returns nil' do
expect(described_class.deactivate(id)).to be nil
expect(described_class.deactivate(id)).to be_nil
end
end

+ 1
- 1
spec/models/user_spec.rb View File

@ -285,7 +285,7 @@ RSpec.describe User, type: :model do
it 'saves nil for otp_secret' do
user = Fabricate.build(:user, otp_secret: 'oldotpcode')
user.disable_two_factor!
expect(user.reload.otp_secret).to be nil
expect(user.reload.otp_secret).to be_nil
end
it 'saves cleared otp_backup_codes' do

Loading…
Cancel
Save