1
0
Fork 0
forked from fedi/mastodon

Fix RSpec/SubjectDeclaration cop (#25312)

This commit is contained in:
Matt Jankowski 2023-07-12 03:49:33 -04:00 committed by GitHub
parent f134a5f9d8
commit c75df62ccc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
21 changed files with 45 additions and 51 deletions

View file

@ -409,29 +409,6 @@ RSpec/StubbedMock:
- 'spec/lib/webfinger_resource_spec.rb'
- 'spec/services/activitypub/process_collection_service_spec.rb'
RSpec/SubjectDeclaration:
Exclude:
- 'spec/controllers/admin/domain_blocks_controller_spec.rb'
- 'spec/models/account_migration_spec.rb'
- 'spec/models/account_spec.rb'
- 'spec/models/relationship_filter_spec.rb'
- 'spec/models/user_role_spec.rb'
- 'spec/policies/account_moderation_note_policy_spec.rb'
- 'spec/policies/account_policy_spec.rb'
- 'spec/policies/backup_policy_spec.rb'
- 'spec/policies/custom_emoji_policy_spec.rb'
- 'spec/policies/domain_block_policy_spec.rb'
- 'spec/policies/email_domain_block_policy_spec.rb'
- 'spec/policies/instance_policy_spec.rb'
- 'spec/policies/invite_policy_spec.rb'
- 'spec/policies/relay_policy_spec.rb'
- 'spec/policies/report_note_policy_spec.rb'
- 'spec/policies/report_policy_spec.rb'
- 'spec/policies/settings_policy_spec.rb'
- 'spec/policies/tag_policy_spec.rb'
- 'spec/policies/user_policy_spec.rb'
- 'spec/services/activitypub/process_account_service_spec.rb'
RSpec/SubjectStub:
Exclude:
- 'spec/services/unallow_domain_service_spec.rb'

View file

@ -166,10 +166,11 @@ RSpec.describe Admin::DomainBlocksController do
end
describe 'PUT #update' do
let!(:remote_account) { Fabricate(:account, domain: 'example.com') }
let(:subject) do
subject do
post :update, params: { :id => domain_block.id, :domain_block => { domain: 'example.com', severity: new_severity }, 'confirm' => '' }
end
let!(:remote_account) { Fabricate(:account, domain: 'example.com') }
let(:domain_block) { Fabricate(:domain_block, domain: 'example.com', severity: original_severity) }
before do

View file

@ -4,11 +4,11 @@ require 'rails_helper'
RSpec.describe AccountMigration do
describe 'validations' do
subject { described_class.new(account: source_account, acct: target_acct) }
let(:source_account) { Fabricate(:account) }
let(:target_acct) { target_account.acct }
let(:subject) { described_class.new(account: source_account, acct: target_acct) }
context 'with valid properties' do
let(:target_account) { Fabricate(:account, username: 'target', domain: 'remote.org') }

View file

@ -20,7 +20,9 @@ RSpec.describe Account do
end
context 'when the account is of a local user' do
let!(:subject) { Fabricate(:user, email: 'foo+bar@domain.org').account }
subject { local_user_account }
let!(:local_user_account) { Fabricate(:user, email: 'foo+bar@domain.org').account }
it 'creates a canonical domain block' do
subject.suspend!

View file

@ -7,7 +7,7 @@ describe RelationshipFilter do
describe '#results' do
context 'when default params are used' do
let(:subject) do
subject do
described_class.new(account, 'order' => 'active').results
end

View file

@ -93,7 +93,7 @@ RSpec.describe UserRole do
describe '#computed_permissions' do
context 'when the role is nobody' do
let(:subject) { described_class.nobody }
subject { described_class.nobody }
it 'returns none' do
expect(subject.computed_permissions).to eq UserRole::Flags::NONE
@ -101,7 +101,7 @@ RSpec.describe UserRole do
end
context 'when the role is everyone' do
let(:subject) { described_class.everyone }
subject { described_class.everyone }
it 'returns permissions' do
expect(subject.computed_permissions).to eq subject.permissions

View file

@ -4,7 +4,8 @@ require 'rails_helper'
require 'pundit/rspec'
RSpec.describe AccountModerationNotePolicy do
let(:subject) { described_class }
subject { described_class }
let(:admin) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')).account }
let(:john) { Fabricate(:account) }

View file

@ -4,7 +4,8 @@ require 'rails_helper'
require 'pundit/rspec'
RSpec.describe AccountPolicy do
let(:subject) { described_class }
subject { described_class }
let(:admin) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')).account }
let(:john) { Fabricate(:account) }
let(:alice) { Fabricate(:account) }

View file

@ -4,7 +4,8 @@ require 'rails_helper'
require 'pundit/rspec'
RSpec.describe BackupPolicy do
let(:subject) { described_class }
subject { described_class }
let(:john) { Fabricate(:account) }
permissions :create? do

View file

@ -4,7 +4,8 @@ require 'rails_helper'
require 'pundit/rspec'
RSpec.describe CustomEmojiPolicy do
let(:subject) { described_class }
subject { described_class }
let(:admin) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')).account }
let(:john) { Fabricate(:account) }

View file

@ -4,7 +4,8 @@ require 'rails_helper'
require 'pundit/rspec'
RSpec.describe DomainBlockPolicy do
let(:subject) { described_class }
subject { described_class }
let(:admin) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')).account }
let(:john) { Fabricate(:account) }

View file

@ -4,7 +4,8 @@ require 'rails_helper'
require 'pundit/rspec'
RSpec.describe EmailDomainBlockPolicy do
let(:subject) { described_class }
subject { described_class }
let(:admin) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')).account }
let(:john) { Fabricate(:account) }

View file

@ -4,7 +4,8 @@ require 'rails_helper'
require 'pundit/rspec'
RSpec.describe InstancePolicy do
let(:subject) { described_class }
subject { described_class }
let(:admin) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')).account }
let(:john) { Fabricate(:account) }

View file

@ -4,7 +4,8 @@ require 'rails_helper'
require 'pundit/rspec'
RSpec.describe InvitePolicy do
let(:subject) { described_class }
subject { described_class }
let(:admin) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')).account }
let(:john) { Fabricate(:user).account }

View file

@ -4,7 +4,8 @@ require 'rails_helper'
require 'pundit/rspec'
RSpec.describe RelayPolicy do
let(:subject) { described_class }
subject { described_class }
let(:admin) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')).account }
let(:john) { Fabricate(:account) }

View file

@ -4,7 +4,8 @@ require 'rails_helper'
require 'pundit/rspec'
RSpec.describe ReportNotePolicy do
let(:subject) { described_class }
subject { described_class }
let(:admin) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')).account }
let(:john) { Fabricate(:account) }

View file

@ -4,7 +4,8 @@ require 'rails_helper'
require 'pundit/rspec'
RSpec.describe ReportPolicy do
let(:subject) { described_class }
subject { described_class }
let(:admin) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')).account }
let(:john) { Fabricate(:account) }

View file

@ -4,7 +4,8 @@ require 'rails_helper'
require 'pundit/rspec'
RSpec.describe SettingsPolicy do
let(:subject) { described_class }
subject { described_class }
let(:admin) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')).account }
let(:john) { Fabricate(:account) }

View file

@ -4,7 +4,8 @@ require 'rails_helper'
require 'pundit/rspec'
RSpec.describe TagPolicy do
let(:subject) { described_class }
subject { described_class }
let(:admin) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')).account }
let(:john) { Fabricate(:account) }

View file

@ -4,7 +4,8 @@ require 'rails_helper'
require 'pundit/rspec'
RSpec.describe UserPolicy do
let(:subject) { described_class }
subject { described_class }
let(:admin) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')).account }
let(:john) { Fabricate(:account) }

View file

@ -113,11 +113,7 @@ RSpec.describe ActivityPub::ProcessAccountService, type: :service do
end
context 'when discovering many subdomains in a short timeframe' do
before do
stub_const 'ActivityPub::ProcessAccountService::SUBDOMAINS_RATELIMIT', 5
end
let(:subject) do
subject do
8.times do |i|
domain = "test#{i}.testdomain.com"
json = {
@ -129,6 +125,10 @@ RSpec.describe ActivityPub::ProcessAccountService, type: :service do
end
end
before do
stub_const 'ActivityPub::ProcessAccountService::SUBDOMAINS_RATELIMIT', 5
end
it 'creates at least some accounts' do
expect { subject }.to change { Account.remote.count }.by_at_least(2)
end