Autofix Rubocop RSpec/LeadingSubject (#23670)
This commit is contained in:
parent
4ea1e0fceb
commit
4552685f6b
78 changed files with 256 additions and 338 deletions
|
@ -1,6 +1,8 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe ActivityPub::FetchFeaturedCollectionService, type: :service do
|
||||
subject { described_class.new }
|
||||
|
||||
let(:actor) { Fabricate(:account, domain: 'example.com', uri: 'https://example.com/account', featured_collection_url: 'https://example.com/account/pinned') }
|
||||
|
||||
let!(:known_status) { Fabricate(:status, account: actor, uri: 'https://example.com/account/pinned/1') }
|
||||
|
@ -56,8 +58,6 @@ RSpec.describe ActivityPub::FetchFeaturedCollectionService, type: :service do
|
|||
}.with_indifferent_access
|
||||
end
|
||||
|
||||
subject { described_class.new }
|
||||
|
||||
shared_examples 'sets pinned posts' do
|
||||
before do
|
||||
stub_request(:get, 'https://example.com/account/pinned/1').to_return(status: 200, body: Oj.dump(status_json_1))
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe ActivityPub::FetchFeaturedTagsCollectionService, type: :service do
|
||||
subject { described_class.new }
|
||||
|
||||
let(:collection_url) { 'https://example.com/account/tags' }
|
||||
let(:actor) { Fabricate(:account, domain: 'example.com', uri: 'https://example.com/account') }
|
||||
|
||||
|
@ -21,8 +23,6 @@ RSpec.describe ActivityPub::FetchFeaturedTagsCollectionService, type: :service d
|
|||
}.with_indifferent_access
|
||||
end
|
||||
|
||||
subject { described_class.new }
|
||||
|
||||
shared_examples 'sets featured tags' do
|
||||
before do
|
||||
subject.call(actor, collection_url)
|
||||
|
|
|
@ -3,6 +3,8 @@ require 'rails_helper'
|
|||
RSpec.describe ActivityPub::FetchRemoteStatusService, type: :service do
|
||||
include ActionView::Helpers::TextHelper
|
||||
|
||||
subject { described_class.new }
|
||||
|
||||
let!(:sender) { Fabricate(:account, domain: 'foo.bar', uri: 'https://foo.bar') }
|
||||
let!(:recipient) { Fabricate(:account) }
|
||||
|
||||
|
@ -18,8 +20,6 @@ RSpec.describe ActivityPub::FetchRemoteStatusService, type: :service do
|
|||
}
|
||||
end
|
||||
|
||||
subject { described_class.new }
|
||||
|
||||
before do
|
||||
stub_request(:get, 'https://foo.bar/watch?v=12345').to_return(status: 404, body: '')
|
||||
stub_request(:get, object[:id]).to_return(body: Oj.dump(object))
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe ActivityPub::FetchRepliesService, type: :service do
|
||||
subject { described_class.new }
|
||||
|
||||
let(:actor) { Fabricate(:account, domain: 'example.com', uri: 'http://example.com/account') }
|
||||
let(:status) { Fabricate(:status, account: actor) }
|
||||
let(:collection_uri) { 'http://example.com/replies/1' }
|
||||
|
@ -28,8 +30,6 @@ RSpec.describe ActivityPub::FetchRepliesService, type: :service do
|
|||
}.with_indifferent_access
|
||||
end
|
||||
|
||||
subject { described_class.new }
|
||||
|
||||
describe '#call' do
|
||||
context 'when the payload is a Collection with inlined replies' do
|
||||
context 'when passing the collection itself' do
|
||||
|
|
|
@ -31,6 +31,8 @@ RSpec.describe ActivityPub::ProcessAccountService, type: :service do
|
|||
end
|
||||
|
||||
context 'when account is not suspended' do
|
||||
subject { described_class.new.call('alice', 'example.com', payload) }
|
||||
|
||||
let!(:account) { Fabricate(:account, username: 'alice', domain: 'example.com') }
|
||||
|
||||
let(:payload) do
|
||||
|
@ -46,8 +48,6 @@ RSpec.describe ActivityPub::ProcessAccountService, type: :service do
|
|||
allow(Admin::SuspensionWorker).to receive(:perform_async)
|
||||
end
|
||||
|
||||
subject { described_class.new.call('alice', 'example.com', payload) }
|
||||
|
||||
it 'suspends account remotely' do
|
||||
expect(subject.suspended?).to be true
|
||||
expect(subject.suspension_origin_remote?).to be true
|
||||
|
@ -60,6 +60,8 @@ RSpec.describe ActivityPub::ProcessAccountService, type: :service do
|
|||
end
|
||||
|
||||
context 'when account is suspended' do
|
||||
subject { described_class.new.call('alice', 'example.com', payload) }
|
||||
|
||||
let!(:account) { Fabricate(:account, username: 'alice', domain: 'example.com', display_name: '') }
|
||||
|
||||
let(:payload) do
|
||||
|
@ -78,8 +80,6 @@ RSpec.describe ActivityPub::ProcessAccountService, type: :service do
|
|||
account.suspend!(origin: suspension_origin)
|
||||
end
|
||||
|
||||
subject { described_class.new.call('alice', 'example.com', payload) }
|
||||
|
||||
context 'locally' do
|
||||
let(:suspension_origin) { :local }
|
||||
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe ActivityPub::ProcessCollectionService, type: :service do
|
||||
subject { described_class.new }
|
||||
|
||||
let(:actor) { Fabricate(:account, domain: 'example.com', uri: 'http://example.com/account') }
|
||||
|
||||
let(:payload) do
|
||||
|
@ -19,8 +21,6 @@ RSpec.describe ActivityPub::ProcessCollectionService, type: :service do
|
|||
|
||||
let(:json) { Oj.dump(payload) }
|
||||
|
||||
subject { described_class.new }
|
||||
|
||||
describe '#call' do
|
||||
context 'when actor is suspended' do
|
||||
before do
|
||||
|
|
|
@ -5,6 +5,8 @@ def poll_option_json(name, votes)
|
|||
end
|
||||
|
||||
RSpec.describe ActivityPub::ProcessStatusUpdateService, type: :service do
|
||||
subject { described_class.new }
|
||||
|
||||
let!(:status) { Fabricate(:status, text: 'Hello world', account: Fabricate(:account, domain: 'example.com')) }
|
||||
let(:payload) do
|
||||
{
|
||||
|
@ -35,8 +37,6 @@ RSpec.describe ActivityPub::ProcessStatusUpdateService, type: :service do
|
|||
media_attachments.each { |m| status.media_attachments << m }
|
||||
end
|
||||
|
||||
subject { described_class.new }
|
||||
|
||||
describe '#call' do
|
||||
it 'updates text' do
|
||||
subject.call(status, json)
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe ActivityPub::SynchronizeFollowersService, type: :service do
|
||||
subject { described_class.new }
|
||||
|
||||
let(:actor) { Fabricate(:account, domain: 'example.com', uri: 'http://example.com/account', inbox_url: 'http://example.com/inbox') }
|
||||
let(:alice) { Fabricate(:account, username: 'alice') }
|
||||
let(:bob) { Fabricate(:account, username: 'bob') }
|
||||
|
@ -25,8 +27,6 @@ RSpec.describe ActivityPub::SynchronizeFollowersService, type: :service do
|
|||
}.with_indifferent_access
|
||||
end
|
||||
|
||||
subject { described_class.new }
|
||||
|
||||
shared_examples 'synchronizes followers' do
|
||||
before do
|
||||
alice.follow!(actor)
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe AfterBlockDomainFromAccountService, type: :service do
|
||||
subject { AfterBlockDomainFromAccountService.new }
|
||||
|
||||
let!(:wolf) { Fabricate(:account, username: 'wolf', domain: 'evil.org', inbox_url: 'https://evil.org/inbox', protocol: :activitypub) }
|
||||
let!(:alice) { Fabricate(:account, username: 'alice') }
|
||||
|
||||
subject { AfterBlockDomainFromAccountService.new }
|
||||
|
||||
before do
|
||||
stub_jsonld_contexts!
|
||||
allow(ActivityPub::DeliveryWorker).to receive(:perform_async)
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe AppSignUpService, type: :service do
|
||||
subject { described_class.new }
|
||||
|
||||
let(:app) { Fabricate(:application, scopes: 'read write') }
|
||||
let(:good_params) { { username: 'alice', password: '12345678', email: 'good@email.com', agreement: true } }
|
||||
let(:remote_ip) { IPAddr.new('198.0.2.1') }
|
||||
|
||||
subject { described_class.new }
|
||||
|
||||
describe '#call' do
|
||||
it 'returns nil when registrations are closed' do
|
||||
tmp = Setting.registrations_mode
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe AuthorizeFollowService, type: :service do
|
||||
let(:sender) { Fabricate(:account, username: 'alice') }
|
||||
|
||||
subject { AuthorizeFollowService.new }
|
||||
|
||||
let(:sender) { Fabricate(:account, username: 'alice') }
|
||||
|
||||
describe 'local' do
|
||||
let(:bob) { Fabricate(:account, username: 'bob') }
|
||||
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe BlockDomainService, type: :service do
|
||||
subject { BlockDomainService.new }
|
||||
|
||||
let!(:bad_account) { Fabricate(:account, username: 'badguy666', domain: 'evil.org') }
|
||||
let!(:bad_status1) { Fabricate(:status, account: bad_account, text: 'You suck') }
|
||||
let!(:bad_status2) { Fabricate(:status, account: bad_account, text: 'Hahaha') }
|
||||
let!(:bad_attachment) { Fabricate(:media_attachment, account: bad_account, status: bad_status2, file: attachment_fixture('attachment.jpg')) }
|
||||
let!(:already_banned_account) { Fabricate(:account, username: 'badguy', domain: 'evil.org', suspended: true, silenced: true) }
|
||||
|
||||
subject { BlockDomainService.new }
|
||||
|
||||
describe 'for a suspension' do
|
||||
before do
|
||||
subject.call(DomainBlock.create!(domain: 'evil.org', severity: :suspend))
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe BlockService, type: :service do
|
||||
let(:sender) { Fabricate(:account, username: 'alice') }
|
||||
|
||||
subject { BlockService.new }
|
||||
|
||||
let(:sender) { Fabricate(:account, username: 'alice') }
|
||||
|
||||
describe 'local' do
|
||||
let(:bob) { Fabricate(:account, username: 'bob') }
|
||||
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe ClearDomainMediaService, type: :service do
|
||||
subject { ClearDomainMediaService.new }
|
||||
|
||||
let!(:bad_account) { Fabricate(:account, username: 'badguy666', domain: 'evil.org') }
|
||||
let!(:bad_status1) { Fabricate(:status, account: bad_account, text: 'You suck') }
|
||||
let!(:bad_status2) { Fabricate(:status, account: bad_account, text: 'Hahaha') }
|
||||
let!(:bad_attachment) { Fabricate(:media_attachment, account: bad_account, status: bad_status2, file: attachment_fixture('attachment.jpg')) }
|
||||
|
||||
subject { ClearDomainMediaService.new }
|
||||
|
||||
describe 'for a silence with reject media' do
|
||||
before do
|
||||
subject.call(DomainBlock.create!(domain: 'evil.org', severity: :silence, reject_media: true))
|
||||
|
|
|
@ -2,6 +2,8 @@ require 'rails_helper'
|
|||
|
||||
RSpec.describe DeleteAccountService, type: :service do
|
||||
shared_examples 'common behavior' do
|
||||
subject { described_class.new.call(account) }
|
||||
|
||||
let!(:status) { Fabricate(:status, account: account) }
|
||||
let!(:mention) { Fabricate(:mention, account: local_follower) }
|
||||
let!(:status_with_mention) { Fabricate(:status, account: account, mentions: [mention]) }
|
||||
|
@ -23,8 +25,6 @@ RSpec.describe DeleteAccountService, type: :service do
|
|||
|
||||
let!(:account_note) { Fabricate(:account_note, account: account) }
|
||||
|
||||
subject { described_class.new.call(account) }
|
||||
|
||||
it 'deletes associated owned records' do
|
||||
expect { subject }.to change {
|
||||
[
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe FanOutOnWriteService, type: :service do
|
||||
subject { described_class.new }
|
||||
|
||||
let(:last_active_at) { Time.now.utc }
|
||||
let(:status) { Fabricate(:status, account: alice, visibility: visibility, text: 'Hello @bob #hoge') }
|
||||
|
||||
|
@ -8,8 +10,6 @@ RSpec.describe FanOutOnWriteService, type: :service do
|
|||
let!(:bob) { Fabricate(:user, current_sign_in_at: last_active_at, account_attributes: { username: 'bob' }).account }
|
||||
let!(:tom) { Fabricate(:user, current_sign_in_at: last_active_at).account }
|
||||
|
||||
subject { described_class.new }
|
||||
|
||||
before do
|
||||
bob.follow!(alice)
|
||||
tom.follow!(alice)
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe FavouriteService, type: :service do
|
||||
let(:sender) { Fabricate(:account, username: 'alice') }
|
||||
|
||||
subject { FavouriteService.new }
|
||||
|
||||
let(:sender) { Fabricate(:account, username: 'alice') }
|
||||
|
||||
describe 'local' do
|
||||
let(:bob) { Fabricate(:account) }
|
||||
let(:status) { Fabricate(:status, account: bob) }
|
||||
|
|
|
@ -2,10 +2,10 @@ require 'rails_helper'
|
|||
|
||||
RSpec.describe FetchResourceService, type: :service do
|
||||
describe '#call' do
|
||||
let(:url) { 'http://example.com' }
|
||||
|
||||
subject { described_class.new.call(url) }
|
||||
|
||||
let(:url) { 'http://example.com' }
|
||||
|
||||
context 'with blank url' do
|
||||
let(:url) { '' }
|
||||
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe FollowService, type: :service do
|
||||
let(:sender) { Fabricate(:account, username: 'alice') }
|
||||
|
||||
subject { FollowService.new }
|
||||
|
||||
let(:sender) { Fabricate(:account, username: 'alice') }
|
||||
|
||||
context 'local account' do
|
||||
describe 'locked account' do
|
||||
let(:bob) { Fabricate(:account, locked: true, username: 'bob') }
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe ProcessMentionsService, type: :service do
|
||||
let(:account) { Fabricate(:account, username: 'alice') }
|
||||
|
||||
subject { ProcessMentionsService.new }
|
||||
|
||||
let(:account) { Fabricate(:account, username: 'alice') }
|
||||
|
||||
context 'when mentions contain blocked accounts' do
|
||||
let(:non_blocked_account) { Fabricate(:account) }
|
||||
let(:individually_blocked_account) { Fabricate(:account) }
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe PurgeDomainService, type: :service do
|
||||
subject { PurgeDomainService.new }
|
||||
|
||||
let!(:old_account) { Fabricate(:account, domain: 'obsolete.org') }
|
||||
let!(:old_status1) { Fabricate(:status, account: old_account) }
|
||||
let!(:old_status2) { Fabricate(:status, account: old_account) }
|
||||
let!(:old_attachment) { Fabricate(:media_attachment, account: old_account, status: old_status2, file: attachment_fixture('attachment.jpg')) }
|
||||
|
||||
subject { PurgeDomainService.new }
|
||||
|
||||
describe 'for a suspension' do
|
||||
before do
|
||||
subject.call('obsolete.org')
|
||||
|
|
|
@ -4,12 +4,12 @@ RSpec.describe ReblogService, type: :service do
|
|||
let(:alice) { Fabricate(:account, username: 'alice') }
|
||||
|
||||
context 'creates a reblog with appropriate visibility' do
|
||||
subject { ReblogService.new }
|
||||
|
||||
let(:visibility) { :public }
|
||||
let(:reblog_visibility) { :public }
|
||||
let(:status) { Fabricate(:status, account: alice, visibility: visibility) }
|
||||
|
||||
subject { ReblogService.new }
|
||||
|
||||
before do
|
||||
subject.call(alice, status, visibility: reblog_visibility)
|
||||
end
|
||||
|
@ -45,11 +45,11 @@ RSpec.describe ReblogService, type: :service do
|
|||
end
|
||||
|
||||
context 'ActivityPub' do
|
||||
subject { ReblogService.new }
|
||||
|
||||
let(:bob) { Fabricate(:account, username: 'bob', protocol: :activitypub, domain: 'example.com', inbox_url: 'http://example.com/inbox') }
|
||||
let(:status) { Fabricate(:status, account: bob) }
|
||||
|
||||
subject { ReblogService.new }
|
||||
|
||||
before do
|
||||
stub_request(:post, bob.inbox_url)
|
||||
allow(ActivityPub::DistributionWorker).to receive(:perform_async)
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe RejectFollowService, type: :service do
|
||||
let(:sender) { Fabricate(:account, username: 'alice') }
|
||||
|
||||
subject { RejectFollowService.new }
|
||||
|
||||
let(:sender) { Fabricate(:account, username: 'alice') }
|
||||
|
||||
describe 'local' do
|
||||
let(:bob) { Fabricate(:account) }
|
||||
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe RemoveFromFollowersService, type: :service do
|
||||
let(:bob) { Fabricate(:account, username: 'bob') }
|
||||
|
||||
subject { RemoveFromFollowersService.new }
|
||||
|
||||
let(:bob) { Fabricate(:account, username: 'bob') }
|
||||
|
||||
describe 'local' do
|
||||
let(:sender) { Fabricate(:account, username: 'alice') }
|
||||
|
||||
|
|
|
@ -29,13 +29,13 @@ RSpec.describe ReportService, type: :service do
|
|||
end
|
||||
|
||||
context 'when the reported status is a DM' do
|
||||
let(:target_account) { Fabricate(:account) }
|
||||
let(:status) { Fabricate(:status, account: target_account, visibility: :direct) }
|
||||
|
||||
subject do
|
||||
-> { described_class.new.call(source_account, target_account, status_ids: [status.id]) }
|
||||
end
|
||||
|
||||
let(:target_account) { Fabricate(:account) }
|
||||
let(:status) { Fabricate(:status, account: target_account, visibility: :direct) }
|
||||
|
||||
context 'when it is addressed to the reporter' do
|
||||
before do
|
||||
status.mentions.create(account: source_account)
|
||||
|
@ -85,13 +85,13 @@ RSpec.describe ReportService, type: :service do
|
|||
end
|
||||
|
||||
context 'when other reports already exist for the same target' do
|
||||
let!(:target_account) { Fabricate(:account) }
|
||||
let!(:other_report) { Fabricate(:report, target_account: target_account) }
|
||||
|
||||
subject do
|
||||
-> { described_class.new.call(source_account, target_account) }
|
||||
end
|
||||
|
||||
let!(:target_account) { Fabricate(:account) }
|
||||
let!(:other_report) { Fabricate(:report, target_account: target_account) }
|
||||
|
||||
before do
|
||||
ActionMailer::Base.deliveries.clear
|
||||
source_account.user.settings.notification_emails['report'] = true
|
||||
|
|
|
@ -2,11 +2,11 @@ require 'rails_helper'
|
|||
|
||||
RSpec.describe SuspendAccountService, type: :service do
|
||||
shared_examples 'common behavior' do
|
||||
subject { described_class.new.call(account) }
|
||||
|
||||
let!(:local_follower) { Fabricate(:user, current_sign_in_at: 1.hour.ago).account }
|
||||
let!(:list) { Fabricate(:list, account: local_follower) }
|
||||
|
||||
subject { described_class.new.call(account) }
|
||||
|
||||
before do
|
||||
allow(FeedManager.instance).to receive(:unmerge_from_home).and_return(nil)
|
||||
allow(FeedManager.instance).to receive(:unmerge_from_list).and_return(nil)
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe UnallowDomainService, type: :service do
|
||||
subject { UnallowDomainService.new }
|
||||
|
||||
let!(:bad_account) { Fabricate(:account, username: 'badguy666', domain: 'evil.org') }
|
||||
let!(:bad_status1) { Fabricate(:status, account: bad_account, text: 'You suck') }
|
||||
let!(:bad_status2) { Fabricate(:status, account: bad_account, text: 'Hahaha') }
|
||||
|
@ -8,8 +10,6 @@ RSpec.describe UnallowDomainService, type: :service do
|
|||
let!(:already_banned_account) { Fabricate(:account, username: 'badguy', domain: 'evil.org', suspended: true, silenced: true) }
|
||||
let!(:domain_allow) { Fabricate(:domain_allow, domain: 'evil.org') }
|
||||
|
||||
subject { UnallowDomainService.new }
|
||||
|
||||
context 'in limited federation mode' do
|
||||
before do
|
||||
allow(subject).to receive(:whitelist_mode?).and_return(true)
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe UnblockService, type: :service do
|
||||
let(:sender) { Fabricate(:account, username: 'alice') }
|
||||
|
||||
subject { UnblockService.new }
|
||||
|
||||
let(:sender) { Fabricate(:account, username: 'alice') }
|
||||
|
||||
describe 'local' do
|
||||
let(:bob) { Fabricate(:account) }
|
||||
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe UnfollowService, type: :service do
|
||||
let(:sender) { Fabricate(:account, username: 'alice') }
|
||||
|
||||
subject { UnfollowService.new }
|
||||
|
||||
let(:sender) { Fabricate(:account, username: 'alice') }
|
||||
|
||||
describe 'local' do
|
||||
let(:bob) { Fabricate(:account, username: 'bob') }
|
||||
|
||||
|
|
|
@ -2,11 +2,11 @@ require 'rails_helper'
|
|||
|
||||
RSpec.describe UnsuspendAccountService, type: :service do
|
||||
shared_examples 'common behavior' do
|
||||
subject { described_class.new.call(account) }
|
||||
|
||||
let!(:local_follower) { Fabricate(:user, current_sign_in_at: 1.hour.ago).account }
|
||||
let!(:list) { Fabricate(:list, account: local_follower) }
|
||||
|
||||
subject { described_class.new.call(account) }
|
||||
|
||||
before do
|
||||
allow(FeedManager.instance).to receive(:merge_into_home).and_return(nil)
|
||||
allow(FeedManager.instance).to receive(:merge_into_list).and_return(nil)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue