From ff168ef2024626f37fa776fde5739dcd58ecb9f2 Mon Sep 17 00:00:00 2001 From: Claire Date: Sun, 9 Apr 2023 11:25:30 +0200 Subject: Fix most rubocop issues (#2165) * Run rubocop --autocorrect on app/, config/ and lib/, also manually fix some remaining style issues * Run rubocop --autocorrect-all on db/ * Run rubocop --autocorrect-all on `spec/` and fix remaining issues --- spec/models/concerns/account_interactions_spec.rb | 39 +-------------------- spec/models/public_feed_spec.rb | 12 +++---- spec/models/status_spec.rb | 42 +++++++++++------------ spec/models/tag_feed_spec.rb | 2 +- 4 files changed, 29 insertions(+), 66 deletions(-) (limited to 'spec/models') diff --git a/spec/models/concerns/account_interactions_spec.rb b/spec/models/concerns/account_interactions_spec.rb index 863b025af..32e08d5f7 100644 --- a/spec/models/concerns/account_interactions_spec.rb +++ b/spec/models/concerns/account_interactions_spec.rb @@ -23,7 +23,7 @@ describe AccountInteractions do context 'account with Follow but with reblogs disabled' do it 'returns { target_account_id => { reblogs: false } }' do Fabricate(:follow, account: account, target_account: target_account, show_reblogs: false) - is_expected.to eq(target_account_id => { reblogs: false, notify: false, languages: nil }) + expect(subject).to eq(target_account_id => { reblogs: false, notify: false, languages: nil }) end end @@ -690,41 +690,4 @@ describe AccountInteractions do end end end - - describe 'ignoring reblogs from an account' do - before do - @me = Fabricate(:account, username: 'Me') - @you = Fabricate(:account, username: 'You') - end - - context 'with the reblogs option unspecified' do - before do - @me.follow!(@you) - end - - it 'defaults to showing reblogs' do - 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) - end - - it 'does mute reblogs' do - 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) - end - - it 'does not mute reblogs' do - expect(@me.muting_reblogs?(@you)).to be(false) - end - end - end end diff --git a/spec/models/public_feed_spec.rb b/spec/models/public_feed_spec.rb index f607f10ec..d31aba084 100644 --- a/spec/models/public_feed_spec.rb +++ b/spec/models/public_feed_spec.rb @@ -64,7 +64,7 @@ RSpec.describe PublicFeed, type: :model do end it 'does not include local-only statuses' do - expect(subject).not_to include(local_only_status.id) + expect(subject).to_not include(local_only_status.id) end end @@ -80,12 +80,14 @@ RSpec.describe PublicFeed, type: :model do end it 'does not include local-only statuses' do - expect(subject).not_to include(local_only_status.id) + expect(subject).to_not include(local_only_status.id) end end end context 'without local_only option but allow_local_only' do + subject { described_class.new(viewer, allow_local_only: true).get(20).map(&:id) } + let(:viewer) { nil } let!(:local_account) { Fabricate(:account, domain: nil) } @@ -94,8 +96,6 @@ RSpec.describe PublicFeed, type: :model do let!(:remote_status) { Fabricate(:status, account: remote_account) } let!(:local_only_status) { Fabricate(:status, account: local_account, local_only: true) } - subject { described_class.new(viewer, allow_local_only: true).get(20).map(&:id) } - context 'without a viewer' do let(:viewer) { nil } @@ -108,7 +108,7 @@ RSpec.describe PublicFeed, type: :model do end it 'does not include local-only statuses' do - expect(subject).not_to include(local_only_status.id) + expect(subject).to_not include(local_only_status.id) end end @@ -147,7 +147,7 @@ RSpec.describe PublicFeed, type: :model do end it 'does not include local-only statuses' do - expect(subject).not_to include(local_only_status.id) + expect(subject).to_not include(local_only_status.id) end end diff --git a/spec/models/status_spec.rb b/spec/models/status_spec.rb index 7022c5f00..04e5c26af 100644 --- a/spec/models/status_spec.rb +++ b/spec/models/status_spec.rb @@ -206,14 +206,14 @@ RSpec.describe Status, type: :model do end describe 'on create' do + subject { Status.new } + let(:local_account) { Fabricate(:account, username: 'local', domain: nil) } let(:remote_account) { Fabricate(:account, username: 'remote', domain: 'example.com') } - subject { Status.new } - describe 'on a status that ends with the local-only emoji' do before do - subject.text = 'A toot ' + subject.local_only_emoji + subject.text = "A toot #{subject.local_only_emoji}" end context 'if the status originates from this instance' do @@ -291,52 +291,52 @@ RSpec.describe Status, type: :model do end describe '.as_direct_timeline' do + subject(:results) { Status.as_direct_timeline(account) } + let(:account) { Fabricate(:account) } let(:followed) { Fabricate(:account) } let(:not_followed) { Fabricate(:account) } - before do - Fabricate(:follow, account: account, target_account: followed) - - @self_public_status = Fabricate(:status, account: account, visibility: :public) - @self_direct_status = Fabricate(:status, account: account, visibility: :direct) - @followed_public_status = Fabricate(:status, account: followed, visibility: :public) - @followed_direct_status = Fabricate(:status, account: followed, visibility: :direct) - @not_followed_direct_status = Fabricate(:status, account: not_followed, visibility: :direct) + let!(:self_public_status) { Fabricate(:status, account: account, visibility: :public) } + let!(:self_direct_status) { Fabricate(:status, account: account, visibility: :direct) } + let!(:followed_public_status) { Fabricate(:status, account: followed, visibility: :public) } + let!(:followed_direct_status) { Fabricate(:status, account: followed, visibility: :direct) } + let!(:not_followed_direct_status) { Fabricate(:status, account: not_followed, visibility: :direct) } - @results = Status.as_direct_timeline(account) + before do + account.follow!(followed) end it 'does not include public statuses from self' do - expect(@results).to_not include(@self_public_status) + expect(results).to_not include(self_public_status) end it 'includes direct statuses from self' do - expect(@results).to include(@self_direct_status) + expect(results).to include(self_direct_status) end it 'does not include public statuses from followed' do - expect(@results).to_not include(@followed_public_status) + expect(results).to_not include(followed_public_status) end it 'does not include direct statuses not mentioning recipient from followed' do - expect(@results).to_not include(@followed_direct_status) + expect(results).to_not include(followed_direct_status) end it 'does not include direct statuses not mentioning recipient from non-followed' do - expect(@results).to_not include(@not_followed_direct_status) + expect(results).to_not include(not_followed_direct_status) end it 'includes direct statuses mentioning recipient from followed' do - Fabricate(:mention, account: account, status: @followed_direct_status) + Fabricate(:mention, account: account, status: followed_direct_status) results2 = Status.as_direct_timeline(account) - expect(results2).to include(@followed_direct_status) + expect(results2).to include(followed_direct_status) end it 'includes direct statuses mentioning recipient from non-followed' do - Fabricate(:mention, account: account, status: @not_followed_direct_status) + Fabricate(:mention, account: account, status: not_followed_direct_status) results2 = Status.as_direct_timeline(account) - expect(results2).to include(@not_followed_direct_status) + expect(results2).to include(not_followed_direct_status) end end diff --git a/spec/models/tag_feed_spec.rb b/spec/models/tag_feed_spec.rb index b961481c8..d8683b86f 100644 --- a/spec/models/tag_feed_spec.rb +++ b/spec/models/tag_feed_spec.rb @@ -67,7 +67,7 @@ describe TagFeed, type: :service do expect(results).to include(status) end - context 'on a local-only status' do + context 'when the feed contains a local-only status' do let!(:status) { Fabricate(:status, tags: [tag1], local_only: true) } it 'does not show local-only statuses without a viewer' do -- cgit