diff options
author | Matt Jankowski <matt@jankowski.online> | 2023-06-06 07:58:33 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-06-06 13:58:33 +0200 |
commit | c42591356da45c52f215ea00cf5c0ecd753afe06 (patch) | |
tree | c2fe6e6852846dfe27fceead296bfbadf4a1f063 /spec/models | |
parent | 1e243e2df7ff9dfaf753e86e8f93760a96ffda18 (diff) |
Fix `RSpec/DescribedClass` cop (#25104)
Diffstat (limited to 'spec/models')
-rw-r--r-- | spec/models/account_conversation_spec.rb | 16 | ||||
-rw-r--r-- | spec/models/account_domain_block_spec.rb | 4 | ||||
-rw-r--r-- | spec/models/account_migration_spec.rb | 2 | ||||
-rw-r--r-- | spec/models/account_spec.rb | 90 | ||||
-rw-r--r-- | spec/models/block_spec.rb | 4 | ||||
-rw-r--r-- | spec/models/domain_block_spec.rb | 36 | ||||
-rw-r--r-- | spec/models/email_domain_block_spec.rb | 6 | ||||
-rw-r--r-- | spec/models/export_spec.rb | 14 | ||||
-rw-r--r-- | spec/models/favourite_spec.rb | 8 | ||||
-rw-r--r-- | spec/models/follow_spec.rb | 8 | ||||
-rw-r--r-- | spec/models/identity_spec.rb | 2 | ||||
-rw-r--r-- | spec/models/import_spec.rb | 6 | ||||
-rw-r--r-- | spec/models/media_attachment_spec.rb | 20 | ||||
-rw-r--r-- | spec/models/notification_spec.rb | 8 | ||||
-rw-r--r-- | spec/models/relationship_filter_spec.rb | 2 | ||||
-rw-r--r-- | spec/models/report_filter_spec.rb | 6 | ||||
-rw-r--r-- | spec/models/session_activation_spec.rb | 2 | ||||
-rw-r--r-- | spec/models/setting_spec.rb | 2 | ||||
-rw-r--r-- | spec/models/site_upload_spec.rb | 2 | ||||
-rw-r--r-- | spec/models/status_pin_spec.rb | 18 | ||||
-rw-r--r-- | spec/models/status_spec.rb | 54 | ||||
-rw-r--r-- | spec/models/user_spec.rb | 32 |
22 files changed, 171 insertions, 171 deletions
diff --git a/spec/models/account_conversation_spec.rb b/spec/models/account_conversation_spec.rb index a16aa500cf9..4e8727ca395 100644 --- a/spec/models/account_conversation_spec.rb +++ b/spec/models/account_conversation_spec.rb @@ -12,7 +12,7 @@ RSpec.describe AccountConversation do status = Fabricate(:status, account: alice, visibility: :direct) status.mentions.create(account: bob) - conversation = AccountConversation.add_status(alice, status) + conversation = described_class.add_status(alice, status) expect(conversation.participant_accounts).to include(bob) expect(conversation.last_status).to eq status @@ -21,12 +21,12 @@ RSpec.describe AccountConversation do it 'appends to old record when there is a match' do last_status = Fabricate(:status, account: alice, visibility: :direct) - conversation = AccountConversation.create!(account: alice, conversation: last_status.conversation, participant_account_ids: [bob.id], status_ids: [last_status.id]) + conversation = described_class.create!(account: alice, conversation: last_status.conversation, participant_account_ids: [bob.id], status_ids: [last_status.id]) status = Fabricate(:status, account: bob, visibility: :direct, thread: last_status) status.mentions.create(account: alice) - new_conversation = AccountConversation.add_status(alice, status) + new_conversation = described_class.add_status(alice, status) expect(new_conversation.id).to eq conversation.id expect(new_conversation.participant_accounts).to include(bob) @@ -36,13 +36,13 @@ RSpec.describe AccountConversation do it 'creates new record when new participants are added' do last_status = Fabricate(:status, account: alice, visibility: :direct) - conversation = AccountConversation.create!(account: alice, conversation: last_status.conversation, participant_account_ids: [bob.id], status_ids: [last_status.id]) + conversation = described_class.create!(account: alice, conversation: last_status.conversation, participant_account_ids: [bob.id], status_ids: [last_status.id]) status = Fabricate(:status, account: bob, visibility: :direct, thread: last_status) status.mentions.create(account: alice) status.mentions.create(account: mark) - new_conversation = AccountConversation.add_status(alice, status) + new_conversation = described_class.add_status(alice, status) expect(new_conversation.id).to_not eq conversation.id expect(new_conversation.participant_accounts).to include(bob, mark) @@ -55,7 +55,7 @@ RSpec.describe AccountConversation do it 'updates last status to a previous value' do last_status = Fabricate(:status, account: alice, visibility: :direct) status = Fabricate(:status, account: alice, visibility: :direct) - conversation = AccountConversation.create!(account: alice, conversation: last_status.conversation, participant_account_ids: [bob.id], status_ids: [status.id, last_status.id]) + conversation = described_class.create!(account: alice, conversation: last_status.conversation, participant_account_ids: [bob.id], status_ids: [status.id, last_status.id]) last_status.mentions.create(account: bob) last_status.destroy! conversation.reload @@ -65,10 +65,10 @@ RSpec.describe AccountConversation do it 'removes the record if no other statuses are referenced' do last_status = Fabricate(:status, account: alice, visibility: :direct) - conversation = AccountConversation.create!(account: alice, conversation: last_status.conversation, participant_account_ids: [bob.id], status_ids: [last_status.id]) + conversation = described_class.create!(account: alice, conversation: last_status.conversation, participant_account_ids: [bob.id], status_ids: [last_status.id]) last_status.mentions.create(account: bob) last_status.destroy! - expect(AccountConversation.where(id: conversation.id).count).to eq 0 + expect(described_class.where(id: conversation.id).count).to eq 0 end end end diff --git a/spec/models/account_domain_block_spec.rb b/spec/models/account_domain_block_spec.rb index f3246d04c51..10bd579363c 100644 --- a/spec/models/account_domain_block_spec.rb +++ b/spec/models/account_domain_block_spec.rb @@ -7,14 +7,14 @@ RSpec.describe AccountDomainBlock do account = Fabricate(:account) Rails.cache.write("exclude_domains_for:#{account.id}", 'a.domain.already.blocked') - AccountDomainBlock.create!(account: account, domain: 'a.domain.blocked.later') + described_class.create!(account: account, domain: 'a.domain.blocked.later') expect(Rails.cache.exist?("exclude_domains_for:#{account.id}")).to be false end it 'removes blocking cache after destruction' do account = Fabricate(:account) - block = AccountDomainBlock.create!(account: account, domain: 'domain') + block = described_class.create!(account: account, domain: 'domain') Rails.cache.write("exclude_domains_for:#{account.id}", 'domain') block.destroy! diff --git a/spec/models/account_migration_spec.rb b/spec/models/account_migration_spec.rb index 519b9a97a56..d76edddd510 100644 --- a/spec/models/account_migration_spec.rb +++ b/spec/models/account_migration_spec.rb @@ -7,7 +7,7 @@ RSpec.describe AccountMigration do let(:source_account) { Fabricate(:account) } let(:target_acct) { target_account.acct } - let(:subject) { AccountMigration.new(account: source_account, acct: target_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') } diff --git a/spec/models/account_spec.rb b/spec/models/account_spec.rb index 6e9c608ab05..d966bffa9b1 100644 --- a/spec/models/account_spec.rb +++ b/spec/models/account_spec.rb @@ -362,7 +362,7 @@ RSpec.describe Account do suspended: true ) - results = Account.search_for('username') + results = described_class.search_for('username') expect(results).to eq [] end @@ -375,7 +375,7 @@ RSpec.describe Account do match.user.update(approved: false) - results = Account.search_for('username') + results = described_class.search_for('username') expect(results).to eq [] end @@ -388,7 +388,7 @@ RSpec.describe Account do match.user.update(confirmed_at: nil) - results = Account.search_for('username') + results = described_class.search_for('username') expect(results).to eq [] end @@ -400,7 +400,7 @@ RSpec.describe Account do domain: 'example.com' ) - results = Account.search_for('A?l\i:c e') + results = described_class.search_for('A?l\i:c e') expect(results).to eq [match] end @@ -412,7 +412,7 @@ RSpec.describe Account do domain: 'example.com' ) - results = Account.search_for('display') + results = described_class.search_for('display') expect(results).to eq [match] end @@ -424,7 +424,7 @@ RSpec.describe Account do domain: 'example.com' ) - results = Account.search_for('username') + results = described_class.search_for('username') expect(results).to eq [match] end @@ -436,19 +436,19 @@ RSpec.describe Account do domain: 'example.com' ) - results = Account.search_for('example') + results = described_class.search_for('example') expect(results).to eq [match] end it 'limits by 10 by default' do 11.times.each { Fabricate(:account, display_name: 'Display Name') } - results = Account.search_for('display') + results = described_class.search_for('display') expect(results.size).to eq 10 end it 'accepts arbitrary limits' do 2.times.each { Fabricate(:account, display_name: 'Display Name') } - results = Account.search_for('display', limit: 1) + results = described_class.search_for('display', limit: 1) expect(results.size).to eq 1 end @@ -458,7 +458,7 @@ RSpec.describe Account do { display_name: 'Display Name', username: 'username', domain: 'example.com' }, ].map(&method(:Fabricate).curry(2).call(:account)) - results = Account.search_for('username') + results = described_class.search_for('username') expect(results).to eq matches end end @@ -476,7 +476,7 @@ RSpec.describe Account do ) account.follow!(match) - results = Account.advanced_search_for('A?l\i:c e', account, limit: 10, following: true) + results = described_class.advanced_search_for('A?l\i:c e', account, limit: 10, following: true) expect(results).to eq [match] end @@ -488,7 +488,7 @@ RSpec.describe Account do domain: 'example.com' ) - results = Account.advanced_search_for('A?l\i:c e', account, limit: 10, following: true) + results = described_class.advanced_search_for('A?l\i:c e', account, limit: 10, following: true) expect(results).to eq [] end @@ -501,7 +501,7 @@ RSpec.describe Account do suspended: true ) - results = Account.advanced_search_for('username', account, limit: 10, following: true) + results = described_class.advanced_search_for('username', account, limit: 10, following: true) expect(results).to eq [] end @@ -514,7 +514,7 @@ RSpec.describe Account do match.user.update(approved: false) - results = Account.advanced_search_for('username', account, limit: 10, following: true) + results = described_class.advanced_search_for('username', account, limit: 10, following: true) expect(results).to eq [] end @@ -527,7 +527,7 @@ RSpec.describe Account do match.user.update(confirmed_at: nil) - results = Account.advanced_search_for('username', account, limit: 10, following: true) + results = described_class.advanced_search_for('username', account, limit: 10, following: true) expect(results).to eq [] end end @@ -541,7 +541,7 @@ RSpec.describe Account do suspended: true ) - results = Account.advanced_search_for('username', account) + results = described_class.advanced_search_for('username', account) expect(results).to eq [] end @@ -554,7 +554,7 @@ RSpec.describe Account do match.user.update(approved: false) - results = Account.advanced_search_for('username', account) + results = described_class.advanced_search_for('username', account) expect(results).to eq [] end @@ -567,7 +567,7 @@ RSpec.describe Account do match.user.update(confirmed_at: nil) - results = Account.advanced_search_for('username', account) + results = described_class.advanced_search_for('username', account) expect(results).to eq [] end @@ -579,19 +579,19 @@ RSpec.describe Account do domain: 'example.com' ) - results = Account.advanced_search_for('A?l\i:c e', account) + results = described_class.advanced_search_for('A?l\i:c e', account) expect(results).to eq [match] end it 'limits by 10 by default' do 11.times { Fabricate(:account, display_name: 'Display Name') } - results = Account.advanced_search_for('display', account) + results = described_class.advanced_search_for('display', account) expect(results.size).to eq 10 end it 'accepts arbitrary limits' do 2.times { Fabricate(:account, display_name: 'Display Name') } - results = Account.advanced_search_for('display', account, limit: 1) + results = described_class.advanced_search_for('display', account, limit: 1) expect(results.size).to eq 1 end @@ -600,7 +600,7 @@ RSpec.describe Account do followed_match = Fabricate(:account, username: 'Matcher') Fabricate(:follow, account: account, target_account: followed_match) - results = Account.advanced_search_for('match', account) + results = described_class.advanced_search_for('match', account) expect(results).to eq [followed_match, match] expect(results.first.rank).to be > results.last.rank end @@ -639,31 +639,31 @@ RSpec.describe Account do describe '.following_map' do it 'returns an hash' do - expect(Account.following_map([], 1)).to be_a Hash + expect(described_class.following_map([], 1)).to be_a Hash end end describe '.followed_by_map' do it 'returns an hash' do - expect(Account.followed_by_map([], 1)).to be_a Hash + expect(described_class.followed_by_map([], 1)).to be_a Hash end end describe '.blocking_map' do it 'returns an hash' do - expect(Account.blocking_map([], 1)).to be_a Hash + expect(described_class.blocking_map([], 1)).to be_a Hash end end describe '.requested_map' do it 'returns an hash' do - expect(Account.requested_map([], 1)).to be_a Hash + expect(described_class.requested_map([], 1)).to be_a Hash end end describe '.requested_by_map' do it 'returns an hash' do - expect(Account.requested_by_map([], 1)).to be_a Hash + expect(described_class.requested_by_map([], 1)).to be_a Hash end end @@ -834,7 +834,7 @@ RSpec.describe Account do { username: 'b', domain: 'b' }, ].map(&method(:Fabricate).curry(2).call(:account)) - expect(Account.where('id > 0').alphabetic).to eq matches + expect(described_class.where('id > 0').alphabetic).to eq matches end end @@ -843,7 +843,7 @@ RSpec.describe Account do match = Fabricate(:account, display_name: 'pattern and suffix') Fabricate(:account, display_name: 'prefix and pattern') - expect(Account.matches_display_name('pattern')).to eq [match] + expect(described_class.matches_display_name('pattern')).to eq [match] end end @@ -852,24 +852,24 @@ RSpec.describe Account do match = Fabricate(:account, username: 'pattern_and_suffix') Fabricate(:account, username: 'prefix_and_pattern') - expect(Account.matches_username('pattern')).to eq [match] + expect(described_class.matches_username('pattern')).to eq [match] end end describe 'by_domain_and_subdomains' do it 'returns exact domain matches' do account = Fabricate(:account, domain: 'example.com') - expect(Account.by_domain_and_subdomains('example.com')).to eq [account] + expect(described_class.by_domain_and_subdomains('example.com')).to eq [account] end it 'returns subdomains' do account = Fabricate(:account, domain: 'foo.example.com') - expect(Account.by_domain_and_subdomains('example.com')).to eq [account] + expect(described_class.by_domain_and_subdomains('example.com')).to eq [account] end it 'does not return partially matching domains' do account = Fabricate(:account, domain: 'grexample.com') - expect(Account.by_domain_and_subdomains('example.com')).to_not eq [account] + expect(described_class.by_domain_and_subdomains('example.com')).to_not eq [account] end end @@ -877,7 +877,7 @@ RSpec.describe Account do it 'returns an array of accounts who have a domain' do account_1 = Fabricate(:account, domain: nil) account_2 = Fabricate(:account, domain: 'example.com') - expect(Account.remote).to contain_exactly(account_2) + expect(described_class.remote).to contain_exactly(account_2) end end @@ -885,7 +885,7 @@ RSpec.describe Account do it 'returns an array of accounts who do not have a domain' do account_1 = Fabricate(:account, domain: nil) account_2 = Fabricate(:account, domain: 'example.com') - expect(Account.where('id > 0').local).to contain_exactly(account_1) + expect(described_class.where('id > 0').local).to contain_exactly(account_1) end end @@ -896,14 +896,14 @@ RSpec.describe Account do matches[index] = Fabricate(:account, domain: matches[index]) end - expect(Account.where('id > 0').partitioned).to match_array(matches) + expect(described_class.where('id > 0').partitioned).to match_array(matches) end end describe 'recent' do it 'returns a relation of accounts sorted by recent creation' do matches = Array.new(2) { Fabricate(:account) } - expect(Account.where('id > 0').recent).to match_array(matches) + expect(described_class.where('id > 0').recent).to match_array(matches) end end @@ -911,7 +911,7 @@ RSpec.describe Account do it 'returns an array of accounts who are silenced' do account_1 = Fabricate(:account, silenced: true) account_2 = Fabricate(:account, silenced: false) - expect(Account.silenced).to contain_exactly(account_1) + expect(described_class.silenced).to contain_exactly(account_1) end end @@ -919,7 +919,7 @@ RSpec.describe Account do it 'returns an array of accounts who are suspended' do account_1 = Fabricate(:account, suspended: true) account_2 = Fabricate(:account, suspended: false) - expect(Account.suspended).to contain_exactly(account_1) + expect(described_class.suspended).to contain_exactly(account_1) end end @@ -941,18 +941,18 @@ RSpec.describe Account do end it 'returns every usable non-suspended account' do - expect(Account.searchable).to contain_exactly(silenced_local, silenced_remote, local_account, remote_account) + expect(described_class.searchable).to contain_exactly(silenced_local, silenced_remote, local_account, remote_account) end it 'does not mess with previously-applied scopes' do - expect(Account.where.not(id: remote_account.id).searchable).to contain_exactly(silenced_local, silenced_remote, local_account) + expect(described_class.where.not(id: remote_account.id).searchable).to contain_exactly(silenced_local, silenced_remote, local_account) end end end context 'when is local' do it 'generates keys' do - account = Account.create!(domain: nil, username: Faker::Internet.user_name(separators: ['_'])) + account = described_class.create!(domain: nil, username: Faker::Internet.user_name(separators: ['_'])) expect(account.keypair).to be_private expect(account.keypair).to be_public end @@ -961,12 +961,12 @@ RSpec.describe Account do context 'when is remote' do it 'does not generate keys' do key = OpenSSL::PKey::RSA.new(1024).public_key - account = Account.create!(domain: 'remote', username: Faker::Internet.user_name(separators: ['_']), public_key: key.to_pem) + account = described_class.create!(domain: 'remote', username: Faker::Internet.user_name(separators: ['_']), public_key: key.to_pem) expect(account.keypair.params).to eq key.params end it 'normalizes domain' do - account = Account.create!(domain: 'にゃん', username: Faker::Internet.user_name(separators: ['_'])) + account = described_class.create!(domain: 'にゃん', username: Faker::Internet.user_name(separators: ['_'])) expect(account.domain).to eq 'xn--r9j5b5b' end end @@ -986,7 +986,7 @@ RSpec.describe Account do threads = Array.new(increment_by) do Thread.new do true while wait_for_start - Account.find(subject.id).increment_count!(:followers_count) + described_class.find(subject.id).increment_count!(:followers_count) end end diff --git a/spec/models/block_spec.rb b/spec/models/block_spec.rb index de3410fd583..8249503c592 100644 --- a/spec/models/block_spec.rb +++ b/spec/models/block_spec.rb @@ -23,7 +23,7 @@ RSpec.describe Block do Rails.cache.write("exclude_account_ids_for:#{account.id}", []) Rails.cache.write("exclude_account_ids_for:#{target_account.id}", []) - Block.create!(account: account, target_account: target_account) + described_class.create!(account: account, target_account: target_account) expect(Rails.cache.exist?("exclude_account_ids_for:#{account.id}")).to be false expect(Rails.cache.exist?("exclude_account_ids_for:#{target_account.id}")).to be false @@ -32,7 +32,7 @@ RSpec.describe Block do it 'removes blocking cache after destruction' do account = Fabricate(:account) target_account = Fabricate(:account) - block = Block.cr |