0
0
Fork 0

Fix RSpec/DescribedClass cop (#25104)

This commit is contained in:
Matt Jankowski 2023-06-06 07:58:33 -04:00 committed by GitHub
parent 1e243e2df7
commit c42591356d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
66 changed files with 347 additions and 414 deletions

View file

@ -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

View file

@ -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!

View file

@ -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') }

View file

@ -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

View file

@ -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.create!(account: account, target_account: target_account)
block = described_class.create!(account: account, target_account: target_account)
Rails.cache.write("exclude_account_ids_for:#{account.id}", [target_account.id])
Rails.cache.write("exclude_account_ids_for:#{target_account.id}", [account.id])

View file

@ -21,73 +21,73 @@ RSpec.describe DomainBlock do
describe '.blocked?' do
it 'returns true if the domain is suspended' do
Fabricate(:domain_block, domain: 'example.com', severity: :suspend)
expect(DomainBlock.blocked?('example.com')).to be true
expect(described_class.blocked?('example.com')).to be true
end
it 'returns false even if the domain is silenced' do
Fabricate(:domain_block, domain: 'example.com', severity: :silence)
expect(DomainBlock.blocked?('example.com')).to be false
expect(described_class.blocked?('example.com')).to be false
end
it 'returns false if the domain is not suspended nor silenced' do
expect(DomainBlock.blocked?('example.com')).to be false
expect(described_class.blocked?('example.com')).to be false
end
end
describe '.rule_for' do
it 'returns rule matching a blocked domain' do
block = Fabricate(:domain_block, domain: 'example.com')
expect(DomainBlock.rule_for('example.com')).to eq block
expect(described_class.rule_for('example.com')).to eq block
end
it 'returns a rule matching a subdomain of a blocked domain' do
block = Fabricate(:domain_block, domain: 'example.com')
expect(DomainBlock.rule_for('sub.example.com')).to eq block
expect(described_class.rule_for('sub.example.com')).to eq block
end
it 'returns a rule matching a blocked subdomain' do
block = Fabricate(:domain_block, domain: 'sub.example.com')
expect(DomainBlock.rule_for('sub.example.com')).to eq block
expect(described_class.rule_for('sub.example.com')).to eq block
end
it 'returns a rule matching a blocked TLD' do
block = Fabricate(:domain_block, domain: 'google')
expect(DomainBlock.rule_for('google')).to eq block
expect(described_class.rule_for('google')).to eq block
end
it 'returns a rule matching a subdomain of a blocked TLD' do
block = Fabricate(:domain_block, domain: 'google')
expect(DomainBlock.rule_for('maps.google')).to eq block
expect(described_class.rule_for('maps.google')).to eq block
end
end
describe '#stricter_than?' do
it 'returns true if the new block has suspend severity while the old has lower severity' do
suspend = DomainBlock.new(domain: 'domain', severity: :suspend)
silence = DomainBlock.new(domain: 'domain', severity: :silence)
noop = DomainBlock.new(domain: 'domain', severity: :noop)
suspend = described_class.new(domain: 'domain', severity: :suspend)
silence = described_class.new(domain: 'domain', severity: :silence)
noop = described_class.new(domain: 'domain', severity: :noop)
expect(suspend.stricter_than?(silence)).to be true
expect(suspend.stricter_than?(noop)).to be true
end
it 'returns false if the new block has lower severity than the old one' do
suspend = DomainBlock.new(domain: 'domain', severity: :suspend)
silence = DomainBlock.new(domain: 'domain', severity: :silence)
noop = DomainBlock.new(domain: 'domain', severity: :noop)
suspend = described_class.new(domain: 'domain', severity: :suspend)
silence = described_class.new(domain: 'domain', severity: :silence)
noop = described_class.new(domain: 'domain', severity: :noop)
expect(silence.stricter_than?(suspend)).to be false
expect(noop.stricter_than?(suspend)).to be false
expect(noop.stricter_than?(silence)).to be false
end
it 'returns false if the new block does is less strict regarding reports' do
older = DomainBlock.new(domain: 'domain', severity: :silence, reject_reports: true)
newer = DomainBlock.new(domain: 'domain', severity: :silence, reject_reports: false)
older = described_class.new(domain: 'domain', severity: :silence, reject_reports: true)
newer = described_class.new(domain: 'domain', severity: :silence, reject_reports: false)
expect(newer.stricter_than?(older)).to be false
end
it 'returns false if the new block does is less strict regarding media' do
older = DomainBlock.new(domain: 'domain', severity: :silence, reject_media: true)
newer = DomainBlock.new(domain: 'domain', severity: :silence, reject_media: false)
older = described_class.new(domain: 'domain', severity: :silence, reject_media: true)
newer = described_class.new(domain: 'domain', severity: :silence, reject_media: false)
expect(newer.stricter_than?(older)).to be false
end
end

View file

@ -14,12 +14,12 @@ RSpec.describe EmailDomainBlock do
it 'returns true if the domain is blocked' do
Fabricate(:email_domain_block, domain: 'example.com')
expect(EmailDomainBlock.block?(input)).to be true
expect(described_class.block?(input)).to be true
end
it 'returns false if the domain is not blocked' do
Fabricate(:email_domain_block, domain: 'other-example.com')
expect(EmailDomainBlock.block?(input)).to be false
expect(described_class.block?(input)).to be false
end
end
@ -38,7 +38,7 @@ RSpec.describe EmailDomainBlock do
it 'returns true if the domain is blocked' do
Fabricate(:email_domain_block, domain: 'mail.foo.com')
expect(EmailDomainBlock.block?(input)).to be true
expect(described_class.block?(input)).to be true
end
end
end

View file

@ -12,7 +12,7 @@ describe Export do
it 'returns a csv of the blocked accounts' do
target_accounts.each { |target_account| account.block!(target_account) }
export = Export.new(account).to_blocked_accounts_csv
export = described_class.new(account).to_blocked_accounts_csv
results = export.strip.split
expect(results.size).to eq 2
@ -22,7 +22,7 @@ describe Export do
it 'returns a csv of the muted accounts' do
target_accounts.each { |target_account| account.mute!(target_account) }
export = Export.new(account).to_muted_accounts_csv
export = described_class.new(account).to_muted_accounts_csv
results = export.strip.split("\n")
expect(results.size).to eq 3
@ -33,7 +33,7 @@ describe Export do
it 'returns a csv of the following accounts' do
target_accounts.each { |target_account| account.follow!(target_account) }
export = Export.new(account).to_following_accounts_csv
export = described_class.new(account).to_following_accounts_csv
results = export.strip.split("\n")
expect(results.size).to eq 3
@ -45,24 +45,24 @@ describe Export do
describe 'total_storage' do
it 'returns the total size of the media attachments' do
media_attachment = Fabricate(:media_attachment, account: account)
expect(Export.new(account).total_storage).to eq media_attachment.file_file_size || 0
expect(described_class.new(account).total_storage).to eq media_attachment.file_file_size || 0
end
end
describe 'total_follows' do
it 'returns the total number of the followed accounts' do
target_accounts.each { |target_account| account.follow!(target_account) }
expect(Export.new(account.reload).total_follows).to eq 2
expect(described_class.new(account.reload).total_follows).to eq 2
end
it 'returns the total number of the blocked accounts' do
target_accounts.each { |target_account| account.block!(target_account) }
expect(Export.new(account.reload).total_blocks).to eq 2
expect(described_class.new(account.reload).total_blocks).to eq 2
end
it 'returns the total number of the muted accounts' do
target_accounts.each { |target_account| account.mute!(target_account) }
expect(Export.new(account.reload).total_mutes).to eq 2
expect(described_class.new(account.reload).total_mutes).to eq 2
end
end
end

View file

@ -10,12 +10,12 @@ RSpec.describe Favourite do
let(:status) { Fabricate(:status, reblog: reblog) }
it 'invalidates if the reblogged status is already a favourite' do
Favourite.create!(account: account, status: reblog)
expect(Favourite.new(account: account, status: status).valid?).to be false
described_class.create!(account: account, status: reblog)
expect(described_class.new(account: account, status: status).valid?).to be false
end
it 'replaces status with the reblogged one if it is a reblog' do
favourite = Favourite.create!(account: account, status: status)
favourite = described_class.create!(account: account, status: status)
expect(favourite.status).to eq reblog
end
end
@ -24,7 +24,7 @@ RSpec.describe Favourite do
let(:status) { Fabricate(:status, reblog: nil) }
it 'saves with the specified status' do
favourite = Favourite.create!(account: account, status: status)
favourite = described_class.create!(account: account, status: status)
expect(favourite.status).to eq status
end
end

View file

@ -7,7 +7,7 @@ RSpec.describe Follow do
let(:bob) { Fabricate(:account, username: 'bob') }
describe 'validations' do
subject { Follow.new(account: alice, target_account: bob, rate_limit: true) }
subject { described_class.new(account: alice, target_account: bob, rate_limit: true) }
it 'is invalid without an account' do
follow = Fabricate.build(:follow, account: nil)
@ -38,10 +38,10 @@ RSpec.describe Follow do
describe 'recent' do
it 'sorts so that more recent follows comes earlier' do
follow0 = Follow.create!(account: alice, target_account: bob)
follow1 = Follow.create!(account: bob, target_account: alice)
follow0 = described_class.create!(account: alice, target_account: bob)
follow1 = described_class.create!(account: bob, target_account: alice)
a = Follow.recent.to_a
a = described_class.recent.to_a
expect(a.size).to eq 2
expect(a[0]).to eq follow1

View file

@ -12,7 +12,7 @@ RSpec.describe Identity do
end
it 'returns an instance of Identity' do
expect(described_class.find_for_oauth(auth)).to be_instance_of Identity
expect(described_class.find_for_oauth(auth)).to be_instance_of described_class
end
end
end

View file

@ -9,17 +9,17 @@ RSpec.describe Import do
describe 'validations' do
it 'has a valid parameters' do
import = Import.create(account: account, type: type, data: data)
import = described_class.create(account: account, type: type, data: data)
expect(import).to be_valid
end
it 'is invalid without an type' do
import = Import.create(account: account, data: data)
import = described_class.create(account: account, data: data)
expect(import).to model_have_error_on_field(:type)
end
it 'is invalid without a data' do
import = Import.create(account: account, type: type)
import = described_class.create(account: account, type: type)
expect(import).to model_have_error_on_field(:data)
end
end

View file

@ -85,7 +85,7 @@ RSpec.describe MediaAttachment do
end
describe 'animated gif conversion' do
let(:media) { MediaAttachment.create(account: Fabricate(:account), file: attachment_fixture('avatar.gif')) }
let(:media) { described_class.create(account: Fabricate(:account), file: attachment_fixture('avatar.gif')) }
it 'sets type to gifv' do
expect(media.type).to eq 'gifv'
@ -109,7 +109,7 @@ RSpec.describe MediaAttachment do
fixtures.each do |fixture|
context fixture[:filename] do
let(:media) { MediaAttachment.create(account: Fabricate(:account), file: attachment_fixture(fixture[:filename])) }
let(:media) { described_class.create(account: Fabricate(:account), file: attachment_fixture(fixture[:filename])) }
it 'sets type to image' do
expect(media.type).to eq 'image'
@ -129,7 +129,7 @@ RSpec.describe MediaAttachment do
end
describe 'ogg with cover art' do
let(:media) { MediaAttachment.create(account: Fabricate(:account), file: attachment_fixture('boop.ogg')) }
let(:media) { described_class.create(account: Fabricate(:account), file: attachment_fixture('boop.ogg')) }
it 'detects it as an audio file' do
expect(media.type).to eq 'audio'
@ -153,7 +153,7 @@ RSpec.describe MediaAttachment do
end
describe 'jpeg' do
let(:media) { MediaAttachment.create(account: Fabricate(:account), file: attachment_fixture('attachment.jpg')) }
let(:media) { described_class.create(account: Fabricate(:account), file: attachment_fixture('attachment.jpg')) }
it 'sets meta for different style' do
expect(media.file.meta['original']['width']).to eq 600
@ -171,7 +171,7 @@ RSpec.describe MediaAttachment do
describe 'base64-encoded jpeg' do
let(:base64_attachment) { "data:image/jpeg;base64,#{Base64.encode64(attachment_fixture('attachment.jpg').read)}" }
let(:media) { MediaAttachment.create(account: Fabricate(:account), file: base64_attachment) }
let(:media) { described_class.create(account: Fabricate(:account), file: base64_attachment) }
it 'saves media attachment' do
expect(media.persisted?).to be true
@ -184,7 +184,7 @@ RSpec.describe MediaAttachment do
end
it 'is invalid without file' do
media = MediaAttachment.new(account: Fabricate(:account))
media = described_class.new(account: Fabricate(:account))
expect(media.valid?).to be false
end
@ -192,26 +192,26 @@ RSpec.describe MediaAttachment do
it 'rejects video files that are too large' do
stub_const 'MediaAttachment::IMAGE_LIMIT', 100.megabytes
stub_const 'MediaAttachment::VIDEO_LIMIT', 1.kilobyte
expect { MediaAttachment.create!(account: Fabricate(:account), file: attachment_fixture('attachment.webm')) }.to raise_error(ActiveRecord::RecordInvalid)
expect { described_class.create!(account: Fabricate(:account), file: attachment_fixture('attachment.webm')) }.to raise_error(ActiveRecord::RecordInvalid)
end
it 'accepts video files that are small enough' do
stub_const 'MediaAttachment::IMAGE_LIMIT', 1.kilobyte
stub_const 'MediaAttachment::VIDEO_LIMIT', 100.megabytes
media = MediaAttachment.create!(account: Fabricate(:account), file: attachment_fixture('attachment.webm'))
media = described_class.create!(account: Fabricate(:account), file: attachment_fixture('attachment.webm'))
expect(media.valid?).to be true
end
it 'rejects image files that are too large' do
stub_const 'MediaAttachment::IMAGE_LIMIT', 1.kilobyte
stub_const 'MediaAttachment::VIDEO_LIMIT', 100.megabytes
expect { MediaAttachment.create!(account: Fabricate(:account), file: attachment_fixture('attachment.jpg')) }.to raise_error(ActiveRecord::RecordInvalid)
expect { described_class.create!(account: Fabricate(:account), file: attachment_fixture('attachment.jpg')) }.to raise_error(ActiveRecord::RecordInvalid)
end
it 'accepts image files that are small enough' do
stub_const 'MediaAttachment::IMAGE_LIMIT', 100.megabytes
stub_const 'MediaAttachment::VIDEO_LIMIT', 1.kilobyte
media = MediaAttachment.create!(account: Fabricate(:account), file: attachment_fixture('attachment.jpg'))
media = described_class.create!(account: Fabricate(:account), file: attachment_fixture('attachment.jpg'))
expect(media.valid?).to be true
end
end

View file

@ -38,22 +38,22 @@ RSpec.describe Notification do
describe '#type' do
it 'returns :reblog for a Status' do
notification = Notification.new(activity: Status.new)
notification = described_class.new(activity: Status.new)
expect(notification.type).to eq :reblog
end
it 'returns :mention for a Mention' do
notification = Notification.new(activity: Mention.new)
notification = described_class.new(activity: Mention.new)
expect(notification.type).to eq :mention
end
it 'returns :favourite for a Favourite' do
notification = Notification.new(activity: Favourite.new)
notification = described_class.new(activity: Favourite.new)
expect(notification.type).to eq :favourite
end
it 'returns :follow for a Follow' do
notification = Notification.new(activity: Follow.new)
notification = described_class.new(activity: Follow.new)
expect(notification.type).to eq :follow
end
end

View file

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

View file

@ -5,7 +5,7 @@ require 'rails_helper'
describe ReportFilter do
describe 'with empty params' do
it 'defaults to unresolved reports list' do
filter = ReportFilter.new({})
filter = described_class.new({})
expect(filter.results).to eq Report.unresolved
end
@ -13,7 +13,7 @@ describe ReportFilter do
describe 'with invalid params' do
it 'raises with key error' do
filter = ReportFilter.new(wrong: true)
filter = described_class.new(wrong: true)
expect { filter.results }.to raise_error(/wrong/)
end
@ -21,7 +21,7 @@ describe ReportFilter do
describe 'with valid params' do
it 'combines filters on Report' do
filter = ReportFilter.new(account_id: '123', resolved: true, target_account_id: '456')
filter = described_class.new(account_id: '123', resolved: true, target_account_id: '456')
allow(Report).to receive(:where).and_return(Report.none)
allow(Report).to receive(:resolved).and_return(Report.none)

View file

@ -80,7 +80,7 @@ RSpec.describe SessionActivation do
end
it 'returns an instance of SessionActivation' do
expect(described_class.activate(**options)).to be_a SessionActivation
expect(described_class.activate(**options)).to be_a described_class
end
end

View file

@ -146,7 +146,7 @@ RSpec.describe Setting do
it 'includes Setting with value of default_value' do
setting = described_class.all_as_records[key]
expect(setting).to be_a Setting
expect(setting).to be_a described_class
expect(setting).to have_attributes(var: key)
expect(setting).to have_attributes(value: 'default_value')
end

View file

@ -4,7 +4,7 @@ require 'rails_helper'
RSpec.describe SiteUpload do
describe '#cache_key' do
let(:site_upload) { SiteUpload.new(var: 'var') }
let(:site_upload) { described_class.new(var: 'var') }
it 'returns cache_key' do
expect(site_upload.cache_key).to eq 'site_uploads/var'

View file

@ -8,14 +8,14 @@ RSpec.describe StatusPin do
account = Fabricate(:account)
status = Fabricate(:status, account: account)
expect(StatusPin.new(account: account, status: status).save).to be true
expect(described_class.new(account: account, status: status).save).to be true
end
it 'does not allow pins of statuses by someone else' do
account = Fabricate(:account)
status = Fabricate(:status)
expect(StatusPin.new(account: account, status: status).save).to be false
expect(described_class.new(account: account, status: status).save).to be false
end
it 'does not allow pins of reblogs' do
@ -23,21 +23,21 @@ RSpec.describe StatusPin do
status = Fabricate(:status, account: account)
reblog = Fabricate(:status, reblog: status)
expect(StatusPin.new(account: account, status: reblog).save).to be false
expect(described_class.new(account: account, status: reblog).save).to be false
end
it 'does allow pins of direct statuses' do
account = Fabricate(:account)
status = Fabricate(:status, account: account, visibility: :private)
expect(StatusPin.new(account: account, status: status).save).to be true
expect(described_class.new(account: account, status: status).save).to be true
end
it 'does not allow pins of direct statuses' do
account = Fabricate(:account)
status = Fabricate(:status, account: account, visibility: :direct)
expect(StatusPin.new(account: account, status: status).save).to be false
expect(described_class.new(account: account, status: status).save).to be false
end
max_pins = 5
@ -50,10 +50,10 @@ RSpec.describe StatusPin do
end
max_pins.times do |i|
expect(StatusPin.new(account: account, status: status[i]).save).to be true
expect(described_class.new(account: account, status: status[i]).save).to be true
end
expect(StatusPin.new(account: account, status: status[max_pins]).save).to be false
expect(described_class.new(account: account, status: status[max_pins]).save).to be false
end
it 'allows pins above the max for remote accounts' do
@ -65,10 +65,10 @@ RSpec.describe StatusPin do
end
max_pins.times do |i|
expect(StatusPin.new(account: account, status: status[i]).save).to be true
expect(described_class.new(account: account, status: status[i]).save).to be true
end
expect(StatusPin.new(account: account, status: status[max_pins]).save).to be true
expect(described_class.new(account: account, status: status[max_pins]).save).to be true
end
end
end

View file

@ -160,7 +160,7 @@ RSpec.describe Status do
reblog = Fabricate(:status, account: bob, reblog: subject)
expect(subject.reblogs_count).to eq 1
expect { subject.destroy }.to_not raise_error
expect(Status.find_by(id: reblog.id)).to be_nil
expect(described_class.find_by(id: reblog.id)).to be_nil
end
end
@ -206,7 +206,7 @@ RSpec.describe Status do
end
describe '.mutes_map' do
subject { Status.mutes_map([status.conversation.id], account) }
subject { described_class.mutes_map([status.conversation.id], account) }
let(:status) { Fabricate(:status) }
let(:account) { Fabricate(:account) }
@ -222,7 +222,7 @@ RSpec.describe Status do
end
describe '.favourites_map' do
subject { Status.favourites_map([status], account) }
subject { described_class.favourites_map([status], account) }
let(:status) { Fabricate(:status) }
let(:account) { Fabricate(:account) }
@ -238,7 +238,7 @@ RSpec.describe Status do
end
describe '.reblogs_map' do
subject { Status.reblogs_map([status], account) }
subject { described_class.reblogs_map([status], account) }
let(:status) { Fabricate(:status) }
let(:account) { Fabricate(:account) }
@ -265,17 +265,17 @@ RSpec.describe Status do
context 'when given one tag' do
it 'returns the expected statuses' do
expect(Status.tagged_with([tag1.id]).reorder(:id).pluck(:id).uniq).to contain_exactly(status1.id, status5.id)
expect(Status.tagged_with([tag2.id]).reorder(:id).pluck(:id).uniq).to contain_exactly(status2.id, status5.id)
expect(Status.tagged_with([tag3.id]).reorder(:id).pluck(:id).uniq).to contain_exactly(status3.id, status5.id)
expect(described_class.tagged_with([tag1.id]).reorder(:id).pluck(:id).uniq).to contain_exactly(status1.id, status5.id)
expect(described_class.tagged_with([tag2.id]).reorder(:id).pluck(:id).uniq).to contain_exactly(status2.id, status5.id)
expect(described_class.tagged_with([tag3.id]).reorder(:id).pluck(:id).uniq).to contain_exactly(status3.id, status5.id)
end
end
context 'when given multiple tags' do
it 'returns the expected statuses' do
expect(Status.tagged_with([tag1.id, tag2.id]).reorder(:id).pluck(:id).uniq).to contain_exactly(status1.id, status2.id, status5.id)
expect(Status.tagged_with([tag1.id, tag3.id]).reorder(:id).pluck(:id).uniq).to contain_exactly(status1.id, status3.id, status5.id)
expect(Status.tagged_with([tag2.id, tag3.id]).reorder(:id).pluck(:id).uniq).to contain_exactly(status2.id, status3.id, status5.id)
expect(described_class.tagged_with([tag1.id, tag2.id]).reorder(:id).pluck(:id).uniq).to contain_exactly(status1.id, status2.id, status5.id)
expect(described_class.tagged_with([tag1.id, tag3.id]).reorder(:id).pluck(:id).uniq).to contain_exactly(status1.id, status3.id, status5.id)
expect(described_class.tagged_with([tag2.id, tag3.id]).reorder(:id).pluck(:id).uniq).to contain_exactly(status2.id, status3.id, status5.id)
end
end
end
@ -292,17 +292,17 @@ RSpec.describe Status do
context 'when given one tag' do
it 'returns the expected statuses' do
expect(Status.tagged_with_all([tag1.id]).reorder(:id).pluck(:id).uniq).to contain_exactly(status1.id, status5.id)
expect(Status.tagged_with_all([tag2.id]).reorder(:id).pluck(:id).uniq).to contain_exactly(status2.id, status5.id)
expect(Status.tagged_with_all([tag3.id]).reorder(:id).pluck(:id).uniq).to contain_exactly(status3.id)
expect(described_class.tagged_with_all([tag1.id]).reorder(:id).pluck(:id).uniq).to contain_exactly(status1.id, status5.id)
expect(described_class.tagged_with_all([tag2.id]).reorder(:id).pluck(:id).uniq).to contain_exactly(status2.id, status5.id)
expect(described_class.tagged_with_all([tag3.id]).reorder(:id).pluck(:id).uniq).to contain_exactly(status3.id)
end
end
context 'when given multiple tags' do
it 'returns the expected statuses' do
expect(Status.tagged_with_all([tag1.id, tag2.id]).reorder(:id).pluck(:id).uniq).to contain_exactly(status5.id)
expect(Status.tagged_with_all([tag1.id, tag3.id]).reorder(:id).pluck(:id).uniq).to eq []
expect(Status.tagged_with_all([tag2.id, tag3.id]).reorder(:id).pluck(:id).uniq).to eq []
expect(described_class.tagged_with_all([tag1.id, tag2.id]).reorder(:id).pluck(:id).uniq).to contain_exactly(status5.id)
expect(described_class.tagged_with_all([tag1.id, tag3.id]).reorder(:id).pluck(:id).uniq).to eq []
expect(described_class.tagged_with_all([tag2.id, tag3.id]).reorder(:id).pluck(:id).uniq).to eq []
end
end
end
@ -319,17 +319,17 @@ RSpec.describe Status do
context 'when given one tag' do
it 'returns the expected statuses' do
expect(Status.tagged_with_none([tag1.id]).reorder(:id).pluck(:id).uniq).to contain_exactly(status2.id, status3.id, status4.id)
expect(Status.tagged_with_none([tag2.id]).reorder(:id).pluck(:id).uniq).to contain_exactly(status1.id, status3.id, status4.id)
expect(Status.tagged_with_none([tag3.id]).reorder(:id).pluck(:id).uniq).to contain_exactly(status1.id, status2.id, status4.id)
expect(described_class.tagged_with_none([tag1.id]).reorder(:id).pluck(:id).uniq).to contain_exactly(status2.id, status3.id, status4.id)
expect(described_class.tagged_with_none([tag2.id]).reorder(:id).pluck(:id).uniq).to contain_exactly(status1.id, status3.id, status4.id)
expect(described_class.tagged_with_none([tag3.id]).reorder(:id).pluck(:id).uniq).to contain_exactly(status1.id, status2.id, status4.id)
end
end
context 'when given multiple tags' do
it 'returns the expected statuses' do
expect(Status.tagged_with_none([tag1.id, tag2.id]).reorder(:id).pluck(:id).uniq).to contain_exactly(status3.id, status4.id)
expect(Status.tagged_with_none([tag1.id, tag3.id]).reorder(:id).pluck(:id).uniq).to contain_exactly(status2.id, status4.id)
expect(Status.tagged_with_none([tag2.id, tag3.id]).reorder(:id).pluck(:id).uniq).to contain_exactly(status1.id, status4.id)
expect(described_class.tagged_with_none([tag1.id, tag2.id]).reorder(:id).pluck(:id).uniq).to contain_exactly(status3.id, status4.id)
expect(described_class.tagged_with_none([tag1.id, tag3.id]).reorder(:id).pluck(:id).uniq).to contain_exactly(status2.id, status4.id)
expect(described_class.tagged_with_none([tag2.id, tag3.id]).reorder(:id).pluck(:id).uniq).to contain_exactly(status1.id, status4.id)
end
end
end
@ -344,21 +344,21 @@ RSpec.describe Status do
end
it 'creates new conversation for stand-alone status' do
expect(Status.create(account: alice, text: 'First').conversation_id).to_not be_nil
expect(described_class.create(account: alice, text: 'First').conversation_id).to_not be_nil
end
it 'keeps conversation of parent node' do
parent = Fabricate(:status, text: 'First')
expect(Status.create(account: alice, thread: parent, text: 'Response').conversation_id).to eq parent.conversation_id
expect(described_class.create(account: alice, thread: parent, text: 'Response').conversation_id).to eq parent.conversation_id
end
it 'sets `local` to true for status by local account' do
expect(Status.create(account: alice, text: 'foo').local).to be true
expect(described_class.create(account: alice, text: 'foo').local).to be true
end
it 'sets `local` to false for status by remote account' do
alice.update(domain: 'example.com')
expect(Status.create(account: alice, text: 'foo').local).to be false
expect(described_class.create(account: alice, text: 'foo').local).to be false
end
end
@ -372,7 +372,7 @@ RSpec.describe Status do
describe 'after_create' do
it 'saves ActivityPub uri as uri for local status' do
status = Status.create(account: alice, text: 'foo')
status = described_class.create(account: alice, text: 'foo')
status.reload
expect(status.uri).to start_with('https://')
end

View file

@ -57,7 +57,7 @@ RSpec.describe User do
it 'returns an array of recent users ordered by id' do
user_1 = Fabricate(:user)
user_2 = Fabricate(:user)
expect(User.recent).to eq [user_2, user_1]
expect(described_class.recent).to eq [user_2, user_1]
end
end
@ -65,7 +65,7 @@ RSpec.describe User do
it 'returns an array of users who are confirmed' do
user_1 = Fabricate(:user, confirmed_at: nil)
user_2 = Fabricate(:user, confirmed_at: Time.zone.now)
expect(User.confirmed).to contain_exactly(user_2)
expect(described_class.confirmed).to contain_exactly(user_2)
end
end
@ -74,7 +74,7 @@ RSpec.describe User do
specified = Fabricate(:user, current_sign_in_at: 15.days.ago)
Fabricate(:user, current_sign_in_at: 6.days.ago)
expect(User.inactive).to contain_exactly(specified)
expect(described_class.inactive).to contain_exactly(specified)
end
end
@ -83,7 +83,7 @@ RSpec.describe User do
specified = Fabricate(:user, email: 'specified@spec')
Fabricate(:user, email: 'unspecified@spec')
expect(User.matches_email('specified')).to contain_exactly(specified)
expect(described_class.matches_email('specified')).to contain_exactly(specified)
end
end
@ -96,7 +96,7 @@ RSpec.describe User do
Fabricate(:session_activation, user: user2, ip: '2160:8888::24', session_id: '3')
Fabricate(:session_activation, user: user2, ip: '2160:8888::25', session_id: '4')
expect(User.matches_ip('2160:2160::/32')).to contain_exactly(user1)
expect(described_class.matches_ip('2160:2160::/32')).to contain_exactly(user1)
end
end
end
@ -113,19 +113,19 @@ RSpec.describe User do
end
it 'allows a non-blacklisted user to be created' do
user = User.new(email: 'foo@example.com', account: account, password: password, agreement: true)
user = described_class.new(email: 'foo@example.com', account: account, password: password, agreement: true)
expect(user).to be_valid
end
it 'does not allow a blacklisted user to be created' do
user = User.new(email: 'foo@mvrht.com', account: account, password: password, agreement: true)
user = described_class.new(email: 'foo@mvrht.com', account: account, password: password, agreement: true)
expect(user).to_not be_valid
end
it 'does not allow a subdomain blacklisted user to be created' do
user = User.new(email: 'foo@mvrht.com.topdomain.tld', account: account, password: password, agreement: true)
user = described_class.new(email: 'foo@mvrht.com.topdomain.tld', account: account, password: password, agreement: true)
expect(user).to_not be_valid
end
@ -349,17 +349,17 @@ RSpec.describe User do
end
it 'does not allow a user to be created unless they are whitelisted' do
user = User.new(email: 'foo@example.com', account: account, password: password, agreement: true)
user = described_class.new(email: 'foo@example.com', account: account, password: password, agreement: true)
expect(user).to_not be_valid
end
it 'allows a user to be created if they are whitelisted' do
user = User.new(email: 'foo@mastodon.space', account: account, password: password, agreement: true)
user = described_class.new(email: 'foo@mastodon.space', account: account, password: password, agreement: true)
expect(user).to be_valid
end
it 'does not allow a user with a whitelisted top domain as subdomain in their email address to be created' do
user = User.new(email: 'foo@mastodon.space.userdomain.com', account: account, password: password, agreement: true)
user = described_class.new(email: 'foo@mastodon.space.userdomain.com', account: account, password: password, agreement: true)
expect(user).to_not be_valid
end
@ -373,7 +373,7 @@ RSpec.describe User do
it 'does not allow a user to be created with a specific blacklisted subdomain even if the top domain is whitelisted' do
Rails.configuration.x.email_domains_blacklist = 'blacklisted.mastodon.space'
user = User.new(email: 'foo@blacklisted.mastodon.space', account: account, password: password)
user = described_class.new(email: 'foo@blacklisted.mastodon.space', account: account, password: password)
expect(user).to_not be_valid
end
end
@ -527,19 +527,19 @@ RSpec.describe User do
end
describe '.those_who_can' do
let!(:moderator_user) { Fabricate(:user, role: UserRole.find_by(name: 'Moderator')) }
before { Fabricate(:user, role: UserRole.find_by(name: 'Moderator')) }
context 'when there are not any user roles' do
before { UserRole.destroy_all }
it 'returns an empty list' do
expect(User.those_who_can(:manage_blocks)).to eq([])
expect(described_class.those_who_can(:manage_blocks)).to eq([])
end
end
context 'when there are not users with the needed role' do
it 'returns an empty list' do
expect(User.those_who_can(:manage_blocks)).to eq([])
expect(described_class.those_who_can(:manage_blocks)).to eq([])
end
end
@ -547,7 +547,7 @@ RSpec.describe User do
let!(:admin_user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
it 'returns the users with the role' do
expect(User.those_who_can(:manage_blocks)).to eq([admin_user])
expect(described_class.those_who_can(:manage_blocks)).to eq([admin_user])
end
end
end