0
0
Fork 0

Fix RSpec/InstanceVariable cop (#27766)

This commit is contained in:
Matt Jankowski 2023-11-08 10:42:30 -05:00 committed by GitHub
parent 4329616c53
commit 69d00e2721
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 97 additions and 124 deletions

View file

@ -4,17 +4,15 @@ require 'rails_helper'
describe AccountFinderConcern do
describe 'local finders' do
before do
@account = Fabricate(:account, username: 'Alice')
end
let!(:account) { Fabricate(:account, username: 'Alice') }
describe '.find_local' do
it 'returns case-insensitive result' do
expect(Account.find_local('alice')).to eq(@account)
expect(Account.find_local('alice')).to eq(account)
end
it 'returns correctly cased result' do
expect(Account.find_local('Alice')).to eq(@account)
expect(Account.find_local('Alice')).to eq(account)
end
it 'returns nil without a match' do
@ -36,7 +34,7 @@ describe AccountFinderConcern do
describe '.find_local!' do
it 'returns matching result' do
expect(Account.find_local!('alice')).to eq(@account)
expect(Account.find_local!('alice')).to eq(account)
end
it 'raises on non-matching result' do
@ -54,17 +52,15 @@ describe AccountFinderConcern do
end
describe 'remote finders' do
before do
@account = Fabricate(:account, username: 'Alice', domain: 'mastodon.social')
end
let!(:account) { Fabricate(:account, username: 'Alice', domain: 'mastodon.social') }
describe '.find_remote' do
it 'returns exact match result' do
expect(Account.find_remote('alice', 'mastodon.social')).to eq(@account)
expect(Account.find_remote('alice', 'mastodon.social')).to eq(account)
end
it 'returns case-insensitive result' do
expect(Account.find_remote('ALICE', 'MASTODON.SOCIAL')).to eq(@account)
expect(Account.find_remote('ALICE', 'MASTODON.SOCIAL')).to eq(account)
end
it 'returns nil when username does not match' do
@ -90,7 +86,7 @@ describe AccountFinderConcern do
describe '.find_remote!' do
it 'returns matching result' do
expect(Account.find_remote!('alice', 'mastodon.social')).to eq(@account)
expect(Account.find_remote!('alice', 'mastodon.social')).to eq(account)
end
it 'raises on non-matching result' do

View file

@ -648,38 +648,36 @@ describe AccountInteractions do
end
describe 'ignoring reblogs from an account' do
before do
@me = Fabricate(:account, username: 'Me')
@you = Fabricate(:account, username: 'You')
end
let!(:me) { Fabricate(:account, username: 'Me') }
let!(:you) { Fabricate(:account, username: 'You') }
context 'with the reblogs option unspecified' do
before do
@me.follow!(@you)
me.follow!(you)
end
it 'defaults to showing reblogs' do
expect(@me.muting_reblogs?(@you)).to be(false)
expect(me.muting_reblogs?(you)).to be(false)
end
end
context 'with the reblogs option set to false' do
before do
@me.follow!(@you, reblogs: false)
me.follow!(you, reblogs: false)
end
it 'does mute reblogs' do
expect(@me.muting_reblogs?(@you)).to be(true)
expect(me.muting_reblogs?(you)).to be(true)
end
end
context 'with the reblogs option set to true' do
before do
@me.follow!(@you, reblogs: true)
me.follow!(you, reblogs: true)
end
it 'does not mute reblogs' do
expect(@me.muting_reblogs?(@you)).to be(false)
expect(me.muting_reblogs?(you)).to be(false)
end
end
end

View file

@ -137,15 +137,13 @@ RSpec.describe PublicFeed do
end
describe 'with an account passed in' do
subject { described_class.new(@account).get(20).map(&:id) }
subject { described_class.new(account).get(20).map(&:id) }
before do
@account = Fabricate(:account)
end
let!(:account) { Fabricate(:account) }
it 'excludes statuses from accounts blocked by the account' do
blocked = Fabricate(:account)
@account.block!(blocked)
account.block!(blocked)
blocked_status = Fabricate(:status, account: blocked)
expect(subject).to_not include(blocked_status.id)
@ -153,7 +151,7 @@ RSpec.describe PublicFeed do
it 'excludes statuses from accounts who have blocked the account' do
blocker = Fabricate(:account)
blocker.block!(@account)
blocker.block!(account)
blocked_status = Fabricate(:status, account: blocker)
expect(subject).to_not include(blocked_status.id)
@ -161,7 +159,7 @@ RSpec.describe PublicFeed do
it 'excludes statuses from accounts muted by the account' do
muted = Fabricate(:account)
@account.mute!(muted)
account.mute!(muted)
muted_status = Fabricate(:status, account: muted)
expect(subject).to_not include(muted_status.id)
@ -169,7 +167,7 @@ RSpec.describe PublicFeed do
it 'excludes statuses from accounts from personally blocked domains' do
blocked = Fabricate(:account, domain: 'example.com')
@account.block_domain!(blocked.domain)
account.block_domain!(blocked.domain)
blocked_status = Fabricate(:status, account: blocked)
expect(subject).to_not include(blocked_status.id)
@ -177,7 +175,7 @@ RSpec.describe PublicFeed do
context 'with language preferences' do
it 'excludes statuses in languages not allowed by the account user' do
@account.user.update(chosen_languages: [:en, :es])
account.user.update(chosen_languages: [:en, :es])
en_status = Fabricate(:status, language: 'en')
es_status = Fabricate(:status, language: 'es')
fr_status = Fabricate(:status, language: 'fr')
@ -188,7 +186,7 @@ RSpec.describe PublicFeed do
end
it 'includes all languages when user does not have a setting' do
@account.user.update(chosen_languages: nil)
account.user.update(chosen_languages: nil)
en_status = Fabricate(:status, language: 'en')
es_status = Fabricate(:status, language: 'es')
@ -198,7 +196,7 @@ RSpec.describe PublicFeed do
end
it 'includes all languages when account does not have a user' do
@account.update(user: nil)
account.update(user: nil)
en_status = Fabricate(:status, language: 'en')
es_status = Fabricate(:status, language: 'es')