mirror of
https://github.com/funamitech/mastodon
synced 2024-11-27 14:29:03 +09:00
Autofix Rubocop RSpec/LeadingSubject (#23670)
This commit is contained in:
parent
4ea1e0fceb
commit
4552685f6b
@ -952,88 +952,6 @@ RSpec/InstanceVariable:
|
|||||||
- 'spec/services/search_service_spec.rb'
|
- 'spec/services/search_service_spec.rb'
|
||||||
- 'spec/services/unblock_domain_service_spec.rb'
|
- 'spec/services/unblock_domain_service_spec.rb'
|
||||||
|
|
||||||
# Offense count: 118
|
|
||||||
# This cop supports safe autocorrection (--autocorrect).
|
|
||||||
RSpec/LeadingSubject:
|
|
||||||
Exclude:
|
|
||||||
- 'spec/controllers/activitypub/collections_controller_spec.rb'
|
|
||||||
- 'spec/controllers/activitypub/followers_synchronizations_controller_spec.rb'
|
|
||||||
- 'spec/controllers/activitypub/inboxes_controller_spec.rb'
|
|
||||||
- 'spec/controllers/activitypub/outboxes_controller_spec.rb'
|
|
||||||
- 'spec/controllers/admin/invites_controller_spec.rb'
|
|
||||||
- 'spec/controllers/auth/registrations_controller_spec.rb'
|
|
||||||
- 'spec/controllers/well_known/webfinger_controller_spec.rb'
|
|
||||||
- 'spec/lib/activitypub/activity/accept_spec.rb'
|
|
||||||
- 'spec/lib/activitypub/activity/announce_spec.rb'
|
|
||||||
- 'spec/lib/activitypub/activity/create_spec.rb'
|
|
||||||
- 'spec/lib/activitypub/activity/reject_spec.rb'
|
|
||||||
- 'spec/lib/activitypub/activity/undo_spec.rb'
|
|
||||||
- 'spec/lib/activitypub/activity/update_spec.rb'
|
|
||||||
- 'spec/lib/activitypub/adapter_spec.rb'
|
|
||||||
- 'spec/lib/activitypub/dereferencer_spec.rb'
|
|
||||||
- 'spec/lib/activitypub/linked_data_signature_spec.rb'
|
|
||||||
- 'spec/lib/link_details_extractor_spec.rb'
|
|
||||||
- 'spec/lib/status_filter_spec.rb'
|
|
||||||
- 'spec/lib/status_reach_finder_spec.rb'
|
|
||||||
- 'spec/lib/suspicious_sign_in_detector_spec.rb'
|
|
||||||
- 'spec/lib/text_formatter_spec.rb'
|
|
||||||
- 'spec/lib/vacuum/backups_vacuum_spec.rb'
|
|
||||||
- 'spec/lib/vacuum/media_attachments_vacuum_spec.rb'
|
|
||||||
- 'spec/lib/vacuum/preview_cards_vacuum_spec.rb'
|
|
||||||
- 'spec/lib/vacuum/statuses_vacuum_spec.rb'
|
|
||||||
- 'spec/models/account/field_spec.rb'
|
|
||||||
- 'spec/models/account_spec.rb'
|
|
||||||
- 'spec/models/account_statuses_cleanup_policy_spec.rb'
|
|
||||||
- 'spec/models/account_statuses_filter_spec.rb'
|
|
||||||
- 'spec/models/concerns/account_interactions_spec.rb'
|
|
||||||
- 'spec/models/custom_emoji_filter_spec.rb'
|
|
||||||
- 'spec/models/custom_emoji_spec.rb'
|
|
||||||
- 'spec/models/home_feed_spec.rb'
|
|
||||||
- 'spec/models/media_attachment_spec.rb'
|
|
||||||
- 'spec/models/public_feed_spec.rb'
|
|
||||||
- 'spec/models/remote_follow_spec.rb'
|
|
||||||
- 'spec/models/setting_spec.rb'
|
|
||||||
- 'spec/models/status_spec.rb'
|
|
||||||
- 'spec/models/user_spec.rb'
|
|
||||||
- 'spec/models/web/push_subscription_spec.rb'
|
|
||||||
- 'spec/presenters/familiar_followers_presenter_spec.rb'
|
|
||||||
- 'spec/serializers/activitypub/note_spec.rb'
|
|
||||||
- 'spec/serializers/activitypub/update_poll_spec.rb'
|
|
||||||
- 'spec/serializers/rest/account_serializer_spec.rb'
|
|
||||||
- 'spec/services/activitypub/fetch_featured_collection_service_spec.rb'
|
|
||||||
- 'spec/services/activitypub/fetch_featured_tags_collection_service_spec.rb'
|
|
||||||
- 'spec/services/activitypub/fetch_remote_status_service_spec.rb'
|
|
||||||
- 'spec/services/activitypub/fetch_replies_service_spec.rb'
|
|
||||||
- 'spec/services/activitypub/process_account_service_spec.rb'
|
|
||||||
- 'spec/services/activitypub/process_collection_service_spec.rb'
|
|
||||||
- 'spec/services/activitypub/process_status_update_service_spec.rb'
|
|
||||||
- 'spec/services/activitypub/synchronize_followers_service_spec.rb'
|
|
||||||
- 'spec/services/after_block_domain_from_account_service_spec.rb'
|
|
||||||
- 'spec/services/app_sign_up_service_spec.rb'
|
|
||||||
- 'spec/services/authorize_follow_service_spec.rb'
|
|
||||||
- 'spec/services/block_domain_service_spec.rb'
|
|
||||||
- 'spec/services/block_service_spec.rb'
|
|
||||||
- 'spec/services/clear_domain_media_service_spec.rb'
|
|
||||||
- 'spec/services/delete_account_service_spec.rb'
|
|
||||||
- 'spec/services/fan_out_on_write_service_spec.rb'
|
|
||||||
- 'spec/services/favourite_service_spec.rb'
|
|
||||||
- 'spec/services/fetch_resource_service_spec.rb'
|
|
||||||
- 'spec/services/follow_service_spec.rb'
|
|
||||||
- 'spec/services/process_mentions_service_spec.rb'
|
|
||||||
- 'spec/services/purge_domain_service_spec.rb'
|
|
||||||
- 'spec/services/reblog_service_spec.rb'
|
|
||||||
- 'spec/services/reject_follow_service_spec.rb'
|
|
||||||
- 'spec/services/remove_from_follwers_service_spec.rb'
|
|
||||||
- 'spec/services/report_service_spec.rb'
|
|
||||||
- 'spec/services/suspend_account_service_spec.rb'
|
|
||||||
- 'spec/services/unallow_domain_service_spec.rb'
|
|
||||||
- 'spec/services/unblock_service_spec.rb'
|
|
||||||
- 'spec/services/unfollow_service_spec.rb'
|
|
||||||
- 'spec/services/unsuspend_account_service_spec.rb'
|
|
||||||
- 'spec/validators/blacklisted_email_validator_spec.rb'
|
|
||||||
- 'spec/workers/move_worker_spec.rb'
|
|
||||||
- 'spec/workers/unfollow_follow_worker_spec.rb'
|
|
||||||
|
|
||||||
# Offense count: 15
|
# Offense count: 15
|
||||||
RSpec/LeakyConstantDeclaration:
|
RSpec/LeakyConstantDeclaration:
|
||||||
Exclude:
|
Exclude:
|
||||||
|
@ -35,11 +35,11 @@ RSpec.describe ActivityPub::CollectionsController, type: :controller do
|
|||||||
describe 'GET #show' do
|
describe 'GET #show' do
|
||||||
context 'when id is "featured"' do
|
context 'when id is "featured"' do
|
||||||
context 'without signature' do
|
context 'without signature' do
|
||||||
let(:remote_account) { nil }
|
subject(:body) { body_as_json }
|
||||||
|
|
||||||
subject(:response) { get :show, params: { id: 'featured', account_username: account.username } }
|
subject(:response) { get :show, params: { id: 'featured', account_username: account.username } }
|
||||||
|
|
||||||
subject(:body) { body_as_json }
|
let(:remote_account) { nil }
|
||||||
|
|
||||||
it 'returns http success' do
|
it 'returns http success' do
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(200)
|
||||||
|
@ -32,11 +32,11 @@ RSpec.describe ActivityPub::FollowersSynchronizationsController, type: :controll
|
|||||||
end
|
end
|
||||||
|
|
||||||
context 'with signature from example.com' do
|
context 'with signature from example.com' do
|
||||||
let(:remote_account) { Fabricate(:account, domain: 'example.com', uri: 'https://example.com/instance') }
|
subject(:body) { body_as_json }
|
||||||
|
|
||||||
subject(:response) { get :show, params: { account_username: account.username } }
|
subject(:response) { get :show, params: { account_username: account.username } }
|
||||||
|
|
||||||
subject(:body) { body_as_json }
|
let(:remote_account) { Fabricate(:account, domain: 'example.com', uri: 'https://example.com/instance') }
|
||||||
|
|
||||||
it 'returns http success' do
|
it 'returns http success' do
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(200)
|
||||||
|
@ -22,10 +22,10 @@ RSpec.describe ActivityPub::InboxesController, type: :controller do
|
|||||||
end
|
end
|
||||||
|
|
||||||
context 'for a specific account' do
|
context 'for a specific account' do
|
||||||
let(:account) { Fabricate(:account) }
|
|
||||||
|
|
||||||
subject(:response) { post :create, params: { account_username: account.username }, body: '{}' }
|
subject(:response) { post :create, params: { account_username: account.username }, body: '{}' }
|
||||||
|
|
||||||
|
let(:account) { Fabricate(:account) }
|
||||||
|
|
||||||
context 'when account is permanently suspended' do
|
context 'when account is permanently suspended' do
|
||||||
before do
|
before do
|
||||||
account.suspend!
|
account.suspend!
|
||||||
|
@ -33,11 +33,11 @@ RSpec.describe ActivityPub::OutboxesController, type: :controller do
|
|||||||
|
|
||||||
describe 'GET #show' do
|
describe 'GET #show' do
|
||||||
context 'without signature' do
|
context 'without signature' do
|
||||||
let(:remote_account) { nil }
|
subject(:body) { body_as_json }
|
||||||
|
|
||||||
subject(:response) { get :show, params: { account_username: account.username, page: page } }
|
subject(:response) { get :show, params: { account_username: account.username, page: page } }
|
||||||
|
|
||||||
subject(:body) { body_as_json }
|
let(:remote_account) { nil }
|
||||||
|
|
||||||
context 'with page not requested' do
|
context 'with page not requested' do
|
||||||
let(:page) { nil }
|
let(:page) { nil }
|
||||||
|
@ -33,10 +33,10 @@ describe Admin::InvitesController do
|
|||||||
end
|
end
|
||||||
|
|
||||||
describe 'DELETE #destroy' do
|
describe 'DELETE #destroy' do
|
||||||
let!(:invite) { Fabricate(:invite, expires_at: nil) }
|
|
||||||
|
|
||||||
subject { delete :destroy, params: { id: invite.id } }
|
subject { delete :destroy, params: { id: invite.id } }
|
||||||
|
|
||||||
|
let!(:invite) { Fabricate(:invite, expires_at: nil) }
|
||||||
|
|
||||||
it 'expires invite' do
|
it 'expires invite' do
|
||||||
expect(subject).to redirect_to admin_invites_path
|
expect(subject).to redirect_to admin_invites_path
|
||||||
expect(invite.reload).to be_expired
|
expect(invite.reload).to be_expired
|
||||||
|
@ -95,18 +95,18 @@ RSpec.describe Auth::RegistrationsController, type: :controller do
|
|||||||
before { request.env['devise.mapping'] = Devise.mappings[:user] }
|
before { request.env['devise.mapping'] = Devise.mappings[:user] }
|
||||||
|
|
||||||
context do
|
context do
|
||||||
around do |example|
|
|
||||||
registrations_mode = Setting.registrations_mode
|
|
||||||
example.run
|
|
||||||
Setting.registrations_mode = registrations_mode
|
|
||||||
end
|
|
||||||
|
|
||||||
subject do
|
subject do
|
||||||
Setting.registrations_mode = 'open'
|
Setting.registrations_mode = 'open'
|
||||||
request.headers['Accept-Language'] = accept_language
|
request.headers['Accept-Language'] = accept_language
|
||||||
post :create, params: { user: { account_attributes: { username: 'test' }, email: 'test@example.com', password: '12345678', password_confirmation: '12345678', agreement: 'true' } }
|
post :create, params: { user: { account_attributes: { username: 'test' }, email: 'test@example.com', password: '12345678', password_confirmation: '12345678', agreement: 'true' } }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
around do |example|
|
||||||
|
registrations_mode = Setting.registrations_mode
|
||||||
|
example.run
|
||||||
|
Setting.registrations_mode = registrations_mode
|
||||||
|
end
|
||||||
|
|
||||||
it 'redirects to setup' do
|
it 'redirects to setup' do
|
||||||
subject
|
subject
|
||||||
expect(response).to redirect_to auth_setup_path
|
expect(response).to redirect_to auth_setup_path
|
||||||
@ -121,18 +121,18 @@ RSpec.describe Auth::RegistrationsController, type: :controller do
|
|||||||
end
|
end
|
||||||
|
|
||||||
context 'when user has not agreed to terms of service' do
|
context 'when user has not agreed to terms of service' do
|
||||||
around do |example|
|
|
||||||
registrations_mode = Setting.registrations_mode
|
|
||||||
example.run
|
|
||||||
Setting.registrations_mode = registrations_mode
|
|
||||||
end
|
|
||||||
|
|
||||||
subject do
|
subject do
|
||||||
Setting.registrations_mode = 'open'
|
Setting.registrations_mode = 'open'
|
||||||
request.headers['Accept-Language'] = accept_language
|
request.headers['Accept-Language'] = accept_language
|
||||||
post :create, params: { user: { account_attributes: { username: 'test' }, email: 'test@example.com', password: '12345678', password_confirmation: '12345678', agreement: 'false' } }
|
post :create, params: { user: { account_attributes: { username: 'test' }, email: 'test@example.com', password: '12345678', password_confirmation: '12345678', agreement: 'false' } }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
around do |example|
|
||||||
|
registrations_mode = Setting.registrations_mode
|
||||||
|
example.run
|
||||||
|
Setting.registrations_mode = registrations_mode
|
||||||
|
end
|
||||||
|
|
||||||
it 'does not create user' do
|
it 'does not create user' do
|
||||||
subject
|
subject
|
||||||
user = User.find_by(email: 'test@example.com')
|
user = User.find_by(email: 'test@example.com')
|
||||||
@ -141,18 +141,18 @@ RSpec.describe Auth::RegistrationsController, type: :controller do
|
|||||||
end
|
end
|
||||||
|
|
||||||
context 'approval-based registrations without invite' do
|
context 'approval-based registrations without invite' do
|
||||||
around do |example|
|
|
||||||
registrations_mode = Setting.registrations_mode
|
|
||||||
example.run
|
|
||||||
Setting.registrations_mode = registrations_mode
|
|
||||||
end
|
|
||||||
|
|
||||||
subject do
|
subject do
|
||||||
Setting.registrations_mode = 'approved'
|
Setting.registrations_mode = 'approved'
|
||||||
request.headers['Accept-Language'] = accept_language
|
request.headers['Accept-Language'] = accept_language
|
||||||
post :create, params: { user: { account_attributes: { username: 'test' }, email: 'test@example.com', password: '12345678', password_confirmation: '12345678', agreement: 'true' } }
|
post :create, params: { user: { account_attributes: { username: 'test' }, email: 'test@example.com', password: '12345678', password_confirmation: '12345678', agreement: 'true' } }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
around do |example|
|
||||||
|
registrations_mode = Setting.registrations_mode
|
||||||
|
example.run
|
||||||
|
Setting.registrations_mode = registrations_mode
|
||||||
|
end
|
||||||
|
|
||||||
it 'redirects to setup' do
|
it 'redirects to setup' do
|
||||||
subject
|
subject
|
||||||
expect(response).to redirect_to auth_setup_path
|
expect(response).to redirect_to auth_setup_path
|
||||||
@ -168,12 +168,6 @@ RSpec.describe Auth::RegistrationsController, type: :controller do
|
|||||||
end
|
end
|
||||||
|
|
||||||
context 'approval-based registrations with expired invite' do
|
context 'approval-based registrations with expired invite' do
|
||||||
around do |example|
|
|
||||||
registrations_mode = Setting.registrations_mode
|
|
||||||
example.run
|
|
||||||
Setting.registrations_mode = registrations_mode
|
|
||||||
end
|
|
||||||
|
|
||||||
subject do
|
subject do
|
||||||
Setting.registrations_mode = 'approved'
|
Setting.registrations_mode = 'approved'
|
||||||
request.headers['Accept-Language'] = accept_language
|
request.headers['Accept-Language'] = accept_language
|
||||||
@ -181,6 +175,12 @@ RSpec.describe Auth::RegistrationsController, type: :controller do
|
|||||||
post :create, params: { user: { account_attributes: { username: 'test' }, email: 'test@example.com', password: '12345678', password_confirmation: '12345678', invite_code: invite.code, agreement: 'true' } }
|
post :create, params: { user: { account_attributes: { username: 'test' }, email: 'test@example.com', password: '12345678', password_confirmation: '12345678', invite_code: invite.code, agreement: 'true' } }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
around do |example|
|
||||||
|
registrations_mode = Setting.registrations_mode
|
||||||
|
example.run
|
||||||
|
Setting.registrations_mode = registrations_mode
|
||||||
|
end
|
||||||
|
|
||||||
it 'redirects to setup' do
|
it 'redirects to setup' do
|
||||||
subject
|
subject
|
||||||
expect(response).to redirect_to auth_setup_path
|
expect(response).to redirect_to auth_setup_path
|
||||||
@ -196,14 +196,6 @@ RSpec.describe Auth::RegistrationsController, type: :controller do
|
|||||||
end
|
end
|
||||||
|
|
||||||
context 'approval-based registrations with valid invite and required invite text' do
|
context 'approval-based registrations with valid invite and required invite text' do
|
||||||
around do |example|
|
|
||||||
registrations_mode = Setting.registrations_mode
|
|
||||||
require_invite_text = Setting.require_invite_text
|
|
||||||
example.run
|
|
||||||
Setting.require_invite_text = require_invite_text
|
|
||||||
Setting.registrations_mode = registrations_mode
|
|
||||||
end
|
|
||||||
|
|
||||||
subject do
|
subject do
|
||||||
inviter = Fabricate(:user, confirmed_at: 2.days.ago)
|
inviter = Fabricate(:user, confirmed_at: 2.days.ago)
|
||||||
Setting.registrations_mode = 'approved'
|
Setting.registrations_mode = 'approved'
|
||||||
@ -213,6 +205,14 @@ RSpec.describe Auth::RegistrationsController, type: :controller do
|
|||||||
post :create, params: { user: { account_attributes: { username: 'test' }, email: 'test@example.com', password: '12345678', password_confirmation: '12345678', invite_code: invite.code, agreement: 'true' } }
|
post :create, params: { user: { account_attributes: { username: 'test' }, email: 'test@example.com', password: '12345678', password_confirmation: '12345678', invite_code: invite.code, agreement: 'true' } }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
around do |example|
|
||||||
|
registrations_mode = Setting.registrations_mode
|
||||||
|
require_invite_text = Setting.require_invite_text
|
||||||
|
example.run
|
||||||
|
Setting.require_invite_text = require_invite_text
|
||||||
|
Setting.registrations_mode = registrations_mode
|
||||||
|
end
|
||||||
|
|
||||||
it 'redirects to setup' do
|
it 'redirects to setup' do
|
||||||
subject
|
subject
|
||||||
expect(response).to redirect_to auth_setup_path
|
expect(response).to redirect_to auth_setup_path
|
||||||
|
@ -4,6 +4,10 @@ describe WellKnown::WebfingerController, type: :controller do
|
|||||||
render_views
|
render_views
|
||||||
|
|
||||||
describe 'GET #show' do
|
describe 'GET #show' do
|
||||||
|
subject do
|
||||||
|
get :show, params: { resource: resource }, format: :json
|
||||||
|
end
|
||||||
|
|
||||||
let(:alternate_domains) { [] }
|
let(:alternate_domains) { [] }
|
||||||
let(:alice) { Fabricate(:account, username: 'alice') }
|
let(:alice) { Fabricate(:account, username: 'alice') }
|
||||||
let(:resource) { nil }
|
let(:resource) { nil }
|
||||||
@ -15,10 +19,6 @@ describe WellKnown::WebfingerController, type: :controller do
|
|||||||
Rails.configuration.x.alternate_domains = tmp
|
Rails.configuration.x.alternate_domains = tmp
|
||||||
end
|
end
|
||||||
|
|
||||||
subject do
|
|
||||||
get :show, params: { resource: resource }, format: :json
|
|
||||||
end
|
|
||||||
|
|
||||||
shared_examples 'a successful response' do
|
shared_examples 'a successful response' do
|
||||||
it 'returns http success' do
|
it 'returns http success' do
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(200)
|
||||||
|
@ -42,6 +42,8 @@ RSpec.describe ActivityPub::Activity::Accept do
|
|||||||
end
|
end
|
||||||
|
|
||||||
context 'given a relay' do
|
context 'given a relay' do
|
||||||
|
subject { described_class.new(json, sender) }
|
||||||
|
|
||||||
let!(:relay) { Fabricate(:relay, state: :pending, follow_activity_id: 'https://abc-123/456') }
|
let!(:relay) { Fabricate(:relay, state: :pending, follow_activity_id: 'https://abc-123/456') }
|
||||||
|
|
||||||
let(:json) do
|
let(:json) do
|
||||||
@ -59,8 +61,6 @@ RSpec.describe ActivityPub::Activity::Accept do
|
|||||||
}.with_indifferent_access
|
}.with_indifferent_access
|
||||||
end
|
end
|
||||||
|
|
||||||
subject { described_class.new(json, sender) }
|
|
||||||
|
|
||||||
it 'marks the relay as accepted' do
|
it 'marks the relay as accepted' do
|
||||||
subject.perform
|
subject.perform
|
||||||
expect(relay.reload.accepted?).to be true
|
expect(relay.reload.accepted?).to be true
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
RSpec.describe ActivityPub::Activity::Announce do
|
RSpec.describe ActivityPub::Activity::Announce do
|
||||||
|
subject { described_class.new(json, sender) }
|
||||||
|
|
||||||
let(:sender) { Fabricate(:account, followers_url: 'http://example.com/followers', uri: 'https://example.com/actor') }
|
let(:sender) { Fabricate(:account, followers_url: 'http://example.com/followers', uri: 'https://example.com/actor') }
|
||||||
let(:recipient) { Fabricate(:account) }
|
let(:recipient) { Fabricate(:account) }
|
||||||
let(:status) { Fabricate(:status, account: recipient) }
|
let(:status) { Fabricate(:status, account: recipient) }
|
||||||
@ -27,8 +29,6 @@ RSpec.describe ActivityPub::Activity::Announce do
|
|||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
subject { described_class.new(json, sender) }
|
|
||||||
|
|
||||||
describe '#perform' do
|
describe '#perform' do
|
||||||
context 'when sender is followed by a local account' do
|
context 'when sender is followed by a local account' do
|
||||||
before do
|
before do
|
||||||
@ -110,13 +110,13 @@ RSpec.describe ActivityPub::Activity::Announce do
|
|||||||
end
|
end
|
||||||
|
|
||||||
context 'when the sender is relayed' do
|
context 'when the sender is relayed' do
|
||||||
|
subject { described_class.new(json, sender, relayed_through_actor: relay_account) }
|
||||||
|
|
||||||
let!(:relay_account) { Fabricate(:account, inbox_url: 'https://relay.example.com/inbox') }
|
let!(:relay_account) { Fabricate(:account, inbox_url: 'https://relay.example.com/inbox') }
|
||||||
let!(:relay) { Fabricate(:relay, inbox_url: 'https://relay.example.com/inbox') }
|
let!(:relay) { Fabricate(:relay, inbox_url: 'https://relay.example.com/inbox') }
|
||||||
|
|
||||||
let(:object_json) { 'https://example.com/actor/hello-world' }
|
let(:object_json) { 'https://example.com/actor/hello-world' }
|
||||||
|
|
||||||
subject { described_class.new(json, sender, relayed_through_actor: relay_account) }
|
|
||||||
|
|
||||||
before do
|
before do
|
||||||
stub_request(:get, 'https://example.com/actor/hello-world').to_return(body: Oj.dump(unknown_object_json))
|
stub_request(:get, 'https://example.com/actor/hello-world').to_return(body: Oj.dump(unknown_object_json))
|
||||||
end
|
end
|
||||||
|
@ -752,6 +752,8 @@ RSpec.describe ActivityPub::Activity::Create do
|
|||||||
end
|
end
|
||||||
|
|
||||||
context 'with an encrypted message' do
|
context 'with an encrypted message' do
|
||||||
|
subject { described_class.new(json, sender, delivery: true, delivered_to_account_id: recipient.id) }
|
||||||
|
|
||||||
let(:recipient) { Fabricate(:account) }
|
let(:recipient) { Fabricate(:account) }
|
||||||
let(:object_json) do
|
let(:object_json) do
|
||||||
{
|
{
|
||||||
@ -776,8 +778,6 @@ RSpec.describe ActivityPub::Activity::Create do
|
|||||||
end
|
end
|
||||||
let(:target_device) { Fabricate(:device, account: recipient) }
|
let(:target_device) { Fabricate(:device, account: recipient) }
|
||||||
|
|
||||||
subject { described_class.new(json, sender, delivery: true, delivered_to_account_id: recipient.id) }
|
|
||||||
|
|
||||||
before do
|
before do
|
||||||
subject.perform
|
subject.perform
|
||||||
end
|
end
|
||||||
@ -831,6 +831,8 @@ RSpec.describe ActivityPub::Activity::Create do
|
|||||||
end
|
end
|
||||||
|
|
||||||
context 'when sender replies to local status' do
|
context 'when sender replies to local status' do
|
||||||
|
subject { described_class.new(json, sender, delivery: true) }
|
||||||
|
|
||||||
let!(:local_status) { Fabricate(:status) }
|
let!(:local_status) { Fabricate(:status) }
|
||||||
let(:object_json) do
|
let(:object_json) do
|
||||||
{
|
{
|
||||||
@ -841,8 +843,6 @@ RSpec.describe ActivityPub::Activity::Create do
|
|||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
subject { described_class.new(json, sender, delivery: true) }
|
|
||||||
|
|
||||||
before do
|
before do
|
||||||
subject.perform
|
subject.perform
|
||||||
end
|
end
|
||||||
@ -856,6 +856,8 @@ RSpec.describe ActivityPub::Activity::Create do
|
|||||||
end
|
end
|
||||||
|
|
||||||
context 'when sender targets a local user' do
|
context 'when sender targets a local user' do
|
||||||
|
subject { described_class.new(json, sender, delivery: true) }
|
||||||
|
|
||||||
let!(:local_account) { Fabricate(:account) }
|
let!(:local_account) { Fabricate(:account) }
|
||||||
let(:object_json) do
|
let(:object_json) do
|
||||||
{
|
{
|
||||||
@ -866,8 +868,6 @@ RSpec.describe ActivityPub::Activity::Create do
|
|||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
subject { described_class.new(json, sender, delivery: true) }
|
|
||||||
|
|
||||||
before do
|
before do
|
||||||
subject.perform
|
subject.perform
|
||||||
end
|
end
|
||||||
@ -881,6 +881,8 @@ RSpec.describe ActivityPub::Activity::Create do
|
|||||||
end
|
end
|
||||||
|
|
||||||
context 'when sender cc\'s a local user' do
|
context 'when sender cc\'s a local user' do
|
||||||
|
subject { described_class.new(json, sender, delivery: true) }
|
||||||
|
|
||||||
let!(:local_account) { Fabricate(:account) }
|
let!(:local_account) { Fabricate(:account) }
|
||||||
let(:object_json) do
|
let(:object_json) do
|
||||||
{
|
{
|
||||||
@ -891,8 +893,6 @@ RSpec.describe ActivityPub::Activity::Create do
|
|||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
subject { described_class.new(json, sender, delivery: true) }
|
|
||||||
|
|
||||||
before do
|
before do
|
||||||
subject.perform
|
subject.perform
|
||||||
end
|
end
|
||||||
|
@ -121,6 +121,8 @@ RSpec.describe ActivityPub::Activity::Reject do
|
|||||||
end
|
end
|
||||||
|
|
||||||
context 'given a relay' do
|
context 'given a relay' do
|
||||||
|
subject { described_class.new(json, sender) }
|
||||||
|
|
||||||
let!(:relay) { Fabricate(:relay, state: :pending, follow_activity_id: 'https://abc-123/456') }
|
let!(:relay) { Fabricate(:relay, state: :pending, follow_activity_id: 'https://abc-123/456') }
|
||||||
|
|
||||||
let(:json) do
|
let(:json) do
|
||||||
@ -138,8 +140,6 @@ RSpec.describe ActivityPub::Activity::Reject do
|
|||||||
}.with_indifferent_access
|
}.with_indifferent_access
|
||||||
end
|
end
|
||||||
|
|
||||||
subject { described_class.new(json, sender) }
|
|
||||||
|
|
||||||
it 'marks the relay as rejected' do
|
it 'marks the relay as rejected' do
|
||||||
subject.perform
|
subject.perform
|
||||||
expect(relay.reload.rejected?).to be true
|
expect(relay.reload.rejected?).to be true
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
RSpec.describe ActivityPub::Activity::Undo do
|
RSpec.describe ActivityPub::Activity::Undo do
|
||||||
|
subject { described_class.new(json, sender) }
|
||||||
|
|
||||||
let(:sender) { Fabricate(:account, domain: 'example.com') }
|
let(:sender) { Fabricate(:account, domain: 'example.com') }
|
||||||
|
|
||||||
let(:json) do
|
let(:json) do
|
||||||
@ -13,8 +15,6 @@ RSpec.describe ActivityPub::Activity::Undo do
|
|||||||
}.with_indifferent_access
|
}.with_indifferent_access
|
||||||
end
|
end
|
||||||
|
|
||||||
subject { described_class.new(json, sender) }
|
|
||||||
|
|
||||||
describe '#perform' do
|
describe '#perform' do
|
||||||
context 'with Announce' do
|
context 'with Announce' do
|
||||||
let(:status) { Fabricate(:status) }
|
let(:status) { Fabricate(:status) }
|
||||||
|
@ -1,14 +1,14 @@
|
|||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
RSpec.describe ActivityPub::Activity::Update do
|
RSpec.describe ActivityPub::Activity::Update do
|
||||||
|
subject { described_class.new(json, sender) }
|
||||||
|
|
||||||
let!(:sender) { Fabricate(:account) }
|
let!(:sender) { Fabricate(:account) }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
sender.update!(uri: ActivityPub::TagManager.instance.uri_for(sender))
|
sender.update!(uri: ActivityPub::TagManager.instance.uri_for(sender))
|
||||||
end
|
end
|
||||||
|
|
||||||
subject { described_class.new(json, sender) }
|
|
||||||
|
|
||||||
describe '#perform' do
|
describe '#perform' do
|
||||||
context 'with an Actor object' do
|
context 'with an Actor object' do
|
||||||
let(:modified_sender) do
|
let(:modified_sender) do
|
||||||
|
@ -41,10 +41,10 @@ RSpec.describe ActivityPub::Adapter do
|
|||||||
end
|
end
|
||||||
|
|
||||||
describe '#serializable_hash' do
|
describe '#serializable_hash' do
|
||||||
let(:serializer_class) {}
|
|
||||||
|
|
||||||
subject { ActiveModelSerializers::SerializableResource.new(TestObject.new(foo: 'bar'), serializer: serializer_class, adapter: described_class).as_json }
|
subject { ActiveModelSerializers::SerializableResource.new(TestObject.new(foo: 'bar'), serializer: serializer_class, adapter: described_class).as_json }
|
||||||
|
|
||||||
|
let(:serializer_class) {}
|
||||||
|
|
||||||
context 'when serializer defines no context' do
|
context 'when serializer defines no context' do
|
||||||
let(:serializer_class) { TestWithBasicContextSerializer }
|
let(:serializer_class) { TestWithBasicContextSerializer }
|
||||||
|
|
||||||
|
@ -2,13 +2,13 @@ require 'rails_helper'
|
|||||||
|
|
||||||
RSpec.describe ActivityPub::Dereferencer do
|
RSpec.describe ActivityPub::Dereferencer do
|
||||||
describe '#object' do
|
describe '#object' do
|
||||||
|
subject { described_class.new(uri, permitted_origin: permitted_origin, signature_actor: signature_actor).object }
|
||||||
|
|
||||||
let(:object) { { '@context': 'https://www.w3.org/ns/activitystreams', id: 'https://example.com/foo', type: 'Note', content: 'Hoge' } }
|
let(:object) { { '@context': 'https://www.w3.org/ns/activitystreams', id: 'https://example.com/foo', type: 'Note', content: 'Hoge' } }
|
||||||
let(:permitted_origin) { 'https://example.com' }
|
let(:permitted_origin) { 'https://example.com' }
|
||||||
let(:signature_actor) { nil }
|
let(:signature_actor) { nil }
|
||||||
let(:uri) { nil }
|
let(:uri) { nil }
|
||||||
|
|
||||||
subject { described_class.new(uri, permitted_origin: permitted_origin, signature_actor: signature_actor).object }
|
|
||||||
|
|
||||||
before do
|
before do
|
||||||
stub_request(:get, 'https://example.com/foo').to_return(body: Oj.dump(object), headers: { 'Content-Type' => 'application/activity+json' })
|
stub_request(:get, 'https://example.com/foo').to_return(body: Oj.dump(object), headers: { 'Content-Type' => 'application/activity+json' })
|
||||||
end
|
end
|
||||||
|
@ -3,6 +3,8 @@ require 'rails_helper'
|
|||||||
RSpec.describe ActivityPub::LinkedDataSignature do
|
RSpec.describe ActivityPub::LinkedDataSignature do
|
||||||
include JsonLdHelper
|
include JsonLdHelper
|
||||||
|
|
||||||
|
subject { described_class.new(json) }
|
||||||
|
|
||||||
let!(:sender) { Fabricate(:account, uri: 'http://example.com/alice') }
|
let!(:sender) { Fabricate(:account, uri: 'http://example.com/alice') }
|
||||||
|
|
||||||
let(:raw_json) do
|
let(:raw_json) do
|
||||||
@ -14,8 +16,6 @@ RSpec.describe ActivityPub::LinkedDataSignature do
|
|||||||
|
|
||||||
let(:json) { raw_json.merge('signature' => signature) }
|
let(:json) { raw_json.merge('signature' => signature) }
|
||||||
|
|
||||||
subject { described_class.new(json) }
|
|
||||||
|
|
||||||
before do
|
before do
|
||||||
stub_jsonld_contexts!
|
stub_jsonld_contexts!
|
||||||
end
|
end
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
RSpec.describe LinkDetailsExtractor do
|
RSpec.describe LinkDetailsExtractor do
|
||||||
|
subject { described_class.new(original_url, html, html_charset) }
|
||||||
|
|
||||||
let(:original_url) { '' }
|
let(:original_url) { '' }
|
||||||
let(:html) { '' }
|
let(:html) { '' }
|
||||||
let(:html_charset) { nil }
|
let(:html_charset) { nil }
|
||||||
|
|
||||||
subject { described_class.new(original_url, html, html_charset) }
|
|
||||||
|
|
||||||
describe '#canonical_url' do
|
describe '#canonical_url' do
|
||||||
let(:original_url) { 'https://foo.com/article?bar=baz123' }
|
let(:original_url) { 'https://foo.com/article?bar=baz123' }
|
||||||
|
|
||||||
|
@ -31,10 +31,10 @@ describe StatusFilter do
|
|||||||
end
|
end
|
||||||
|
|
||||||
context 'with real account' do
|
context 'with real account' do
|
||||||
let(:account) { Fabricate(:account) }
|
|
||||||
|
|
||||||
subject { described_class.new(status, account) }
|
subject { described_class.new(status, account) }
|
||||||
|
|
||||||
|
let(:account) { Fabricate(:account) }
|
||||||
|
|
||||||
context 'when there are no connections' do
|
context 'when there are no connections' do
|
||||||
it { is_expected.to_not be_filtered }
|
it { is_expected.to_not be_filtered }
|
||||||
end
|
end
|
||||||
|
@ -5,13 +5,13 @@ require 'rails_helper'
|
|||||||
describe StatusReachFinder do
|
describe StatusReachFinder do
|
||||||
describe '#inboxes' do
|
describe '#inboxes' do
|
||||||
context 'for a local status' do
|
context 'for a local status' do
|
||||||
|
subject { described_class.new(status) }
|
||||||
|
|
||||||
let(:parent_status) { nil }
|
let(:parent_status) { nil }
|
||||||
let(:visibility) { :public }
|
let(:visibility) { :public }
|
||||||
let(:alice) { Fabricate(:account, username: 'alice') }
|
let(:alice) { Fabricate(:account, username: 'alice') }
|
||||||
let(:status) { Fabricate(:status, account: alice, thread: parent_status, visibility: visibility) }
|
let(:status) { Fabricate(:status, account: alice, thread: parent_status, visibility: visibility) }
|
||||||
|
|
||||||
subject { described_class.new(status) }
|
|
||||||
|
|
||||||
context 'when it contains mentions of remote accounts' do
|
context 'when it contains mentions of remote accounts' do
|
||||||
let(:bob) { Fabricate(:account, username: 'bob', domain: 'foo.bar', protocol: :activitypub, inbox_url: 'https://foo.bar/inbox') }
|
let(:bob) { Fabricate(:account, username: 'bob', domain: 'foo.bar', protocol: :activitypub, inbox_url: 'https://foo.bar/inbox') }
|
||||||
|
|
||||||
|
@ -2,12 +2,12 @@ require 'rails_helper'
|
|||||||
|
|
||||||
RSpec.describe SuspiciousSignInDetector do
|
RSpec.describe SuspiciousSignInDetector do
|
||||||
describe '#suspicious?' do
|
describe '#suspicious?' do
|
||||||
|
subject { described_class.new(user).suspicious?(request) }
|
||||||
|
|
||||||
let(:user) { Fabricate(:user, current_sign_in_at: 1.day.ago) }
|
let(:user) { Fabricate(:user, current_sign_in_at: 1.day.ago) }
|
||||||
let(:request) { double(remote_ip: remote_ip) }
|
let(:request) { double(remote_ip: remote_ip) }
|
||||||
let(:remote_ip) { nil }
|
let(:remote_ip) { nil }
|
||||||
|
|
||||||
subject { described_class.new(user).suspicious?(request) }
|
|
||||||
|
|
||||||
context 'when user has 2FA enabled' do
|
context 'when user has 2FA enabled' do
|
||||||
before do
|
before do
|
||||||
user.update!(otp_required_for_login: true)
|
user.update!(otp_required_for_login: true)
|
||||||
|
@ -2,10 +2,10 @@ require 'rails_helper'
|
|||||||
|
|
||||||
RSpec.describe TextFormatter do
|
RSpec.describe TextFormatter do
|
||||||
describe '#to_s' do
|
describe '#to_s' do
|
||||||
let(:preloaded_accounts) { nil }
|
|
||||||
|
|
||||||
subject { described_class.new(text, preloaded_accounts: preloaded_accounts).to_s }
|
subject { described_class.new(text, preloaded_accounts: preloaded_accounts).to_s }
|
||||||
|
|
||||||
|
let(:preloaded_accounts) { nil }
|
||||||
|
|
||||||
context 'given text containing plain text' do
|
context 'given text containing plain text' do
|
||||||
let(:text) { 'text' }
|
let(:text) { 'text' }
|
||||||
|
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
RSpec.describe Vacuum::BackupsVacuum do
|
RSpec.describe Vacuum::BackupsVacuum do
|
||||||
let(:retention_period) { 7.days }
|
|
||||||
|
|
||||||
subject { described_class.new(retention_period) }
|
subject { described_class.new(retention_period) }
|
||||||
|
|
||||||
|
let(:retention_period) { 7.days }
|
||||||
|
|
||||||
describe '#perform' do
|
describe '#perform' do
|
||||||
let!(:expired_backup) { Fabricate(:backup, created_at: (retention_period + 1.day).ago) }
|
let!(:expired_backup) { Fabricate(:backup, created_at: (retention_period + 1.day).ago) }
|
||||||
let!(:current_backup) { Fabricate(:backup) }
|
let!(:current_backup) { Fabricate(:backup) }
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
RSpec.describe Vacuum::MediaAttachmentsVacuum do
|
RSpec.describe Vacuum::MediaAttachmentsVacuum do
|
||||||
|
subject { described_class.new(retention_period) }
|
||||||
|
|
||||||
let(:retention_period) { 7.days }
|
let(:retention_period) { 7.days }
|
||||||
let(:remote_status) { Fabricate(:status, account: Fabricate(:account, domain: 'example.com')) }
|
let(:remote_status) { Fabricate(:status, account: Fabricate(:account, domain: 'example.com')) }
|
||||||
let(:local_status) { Fabricate(:status) }
|
let(:local_status) { Fabricate(:status) }
|
||||||
|
|
||||||
subject { described_class.new(retention_period) }
|
|
||||||
|
|
||||||
describe '#perform' do
|
describe '#perform' do
|
||||||
let!(:old_remote_media) { Fabricate(:media_attachment, remote_url: 'https://example.com/foo.png', status: remote_status, created_at: (retention_period + 1.day).ago, updated_at: (retention_period + 1.day).ago) }
|
let!(:old_remote_media) { Fabricate(:media_attachment, remote_url: 'https://example.com/foo.png', status: remote_status, created_at: (retention_period + 1.day).ago, updated_at: (retention_period + 1.day).ago) }
|
||||||
let!(:old_local_media) { Fabricate(:media_attachment, status: local_status, created_at: (retention_period + 1.day).ago, updated_at: (retention_period + 1.day).ago) }
|
let!(:old_local_media) { Fabricate(:media_attachment, status: local_status, created_at: (retention_period + 1.day).ago, updated_at: (retention_period + 1.day).ago) }
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
RSpec.describe Vacuum::PreviewCardsVacuum do
|
RSpec.describe Vacuum::PreviewCardsVacuum do
|
||||||
let(:retention_period) { 7.days }
|
|
||||||
|
|
||||||
subject { described_class.new(retention_period) }
|
subject { described_class.new(retention_period) }
|
||||||
|
|
||||||
|
let(:retention_period) { 7.days }
|
||||||
|
|
||||||
describe '#perform' do
|
describe '#perform' do
|
||||||
let!(:orphaned_preview_card) { Fabricate(:preview_card, created_at: 2.days.ago) }
|
let!(:orphaned_preview_card) { Fabricate(:preview_card, created_at: 2.days.ago) }
|
||||||
let!(:old_preview_card) { Fabricate(:preview_card, updated_at: (retention_period + 1.day).ago) }
|
let!(:old_preview_card) { Fabricate(:preview_card, updated_at: (retention_period + 1.day).ago) }
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
RSpec.describe Vacuum::StatusesVacuum do
|
RSpec.describe Vacuum::StatusesVacuum do
|
||||||
|
subject { described_class.new(retention_period) }
|
||||||
|
|
||||||
let(:retention_period) { 7.days }
|
let(:retention_period) { 7.days }
|
||||||
|
|
||||||
let(:remote_account) { Fabricate(:account, domain: 'example.com') }
|
let(:remote_account) { Fabricate(:account, domain: 'example.com') }
|
||||||
|
|
||||||
subject { described_class.new(retention_period) }
|
|
||||||
|
|
||||||
describe '#perform' do
|
describe '#perform' do
|
||||||
let!(:remote_status_old) { Fabricate(:status, account: remote_account, created_at: (retention_period + 2.days).ago) }
|
let!(:remote_status_old) { Fabricate(:status, account: remote_account, created_at: (retention_period + 2.days).ago) }
|
||||||
let!(:remote_status_recent) { Fabricate(:status, account: remote_account, created_at: (retention_period - 2.days).ago) }
|
let!(:remote_status_recent) { Fabricate(:status, account: remote_account, created_at: (retention_period - 2.days).ago) }
|
||||||
|
@ -2,10 +2,10 @@ require 'rails_helper'
|
|||||||
|
|
||||||
RSpec.describe Account::Field, type: :model do
|
RSpec.describe Account::Field, type: :model do
|
||||||
describe '#verified?' do
|
describe '#verified?' do
|
||||||
let(:account) { double('Account', local?: true) }
|
|
||||||
|
|
||||||
subject { described_class.new(account, 'name' => 'Foo', 'value' => 'Bar', 'verified_at' => verified_at) }
|
subject { described_class.new(account, 'name' => 'Foo', 'value' => 'Bar', 'verified_at' => verified_at) }
|
||||||
|
|
||||||
|
let(:account) { double('Account', local?: true) }
|
||||||
|
|
||||||
context 'when verified_at is set' do
|
context 'when verified_at is set' do
|
||||||
let(:verified_at) { Time.now.utc.iso8601 }
|
let(:verified_at) { Time.now.utc.iso8601 }
|
||||||
|
|
||||||
@ -24,11 +24,11 @@ RSpec.describe Account::Field, type: :model do
|
|||||||
end
|
end
|
||||||
|
|
||||||
describe '#mark_verified!' do
|
describe '#mark_verified!' do
|
||||||
|
subject { described_class.new(account, original_hash) }
|
||||||
|
|
||||||
let(:account) { double('Account', local?: true) }
|
let(:account) { double('Account', local?: true) }
|
||||||
let(:original_hash) { { 'name' => 'Foo', 'value' => 'Bar' } }
|
let(:original_hash) { { 'name' => 'Foo', 'value' => 'Bar' } }
|
||||||
|
|
||||||
subject { described_class.new(account, original_hash) }
|
|
||||||
|
|
||||||
before do
|
before do
|
||||||
subject.mark_verified!
|
subject.mark_verified!
|
||||||
end
|
end
|
||||||
@ -43,10 +43,10 @@ RSpec.describe Account::Field, type: :model do
|
|||||||
end
|
end
|
||||||
|
|
||||||
describe '#verifiable?' do
|
describe '#verifiable?' do
|
||||||
let(:account) { double('Account', local?: local) }
|
|
||||||
|
|
||||||
subject { described_class.new(account, 'name' => 'Foo', 'value' => value) }
|
subject { described_class.new(account, 'name' => 'Foo', 'value' => value) }
|
||||||
|
|
||||||
|
let(:account) { double('Account', local?: local) }
|
||||||
|
|
||||||
context 'for local accounts' do
|
context 'for local accounts' do
|
||||||
let(:local) { true }
|
let(:local) { true }
|
||||||
|
|
||||||
|
@ -2,10 +2,10 @@ require 'rails_helper'
|
|||||||
|
|
||||||
RSpec.describe Account, type: :model do
|
RSpec.describe Account, type: :model do
|
||||||
context do
|
context do
|
||||||
let(:bob) { Fabricate(:account, username: 'bob') }
|
|
||||||
|
|
||||||
subject { Fabricate(:account) }
|
subject { Fabricate(:account) }
|
||||||
|
|
||||||
|
let(:bob) { Fabricate(:account, username: 'bob') }
|
||||||
|
|
||||||
describe '#suspend!' do
|
describe '#suspend!' do
|
||||||
it 'marks the account as suspended' do
|
it 'marks the account as suspended' do
|
||||||
subject.suspend!
|
subject.suspend!
|
||||||
@ -87,14 +87,14 @@ RSpec.describe Account, type: :model do
|
|||||||
end
|
end
|
||||||
|
|
||||||
describe 'Local domain user methods' do
|
describe 'Local domain user methods' do
|
||||||
|
subject { Fabricate(:account, domain: nil, username: 'alice') }
|
||||||
|
|
||||||
around do |example|
|
around do |example|
|
||||||
before = Rails.configuration.x.local_domain
|
before = Rails.configuration.x.local_domain
|
||||||
example.run
|
example.run
|
||||||
Rails.configuration.x.local_domain = before
|
Rails.configuration.x.local_domain = before
|
||||||
end
|
end
|
||||||
|
|
||||||
subject { Fabricate(:account, domain: nil, username: 'alice') }
|
|
||||||
|
|
||||||
describe '#to_webfinger_s' do
|
describe '#to_webfinger_s' do
|
||||||
it 'returns a webfinger string for the account' do
|
it 'returns a webfinger string for the account' do
|
||||||
Rails.configuration.x.local_domain = 'example.com'
|
Rails.configuration.x.local_domain = 'example.com'
|
||||||
@ -243,13 +243,13 @@ RSpec.describe Account, type: :model do
|
|||||||
end
|
end
|
||||||
|
|
||||||
describe '#favourited?' do
|
describe '#favourited?' do
|
||||||
|
subject { Fabricate(:account) }
|
||||||
|
|
||||||
let(:original_status) do
|
let(:original_status) do
|
||||||
author = Fabricate(:account, username: 'original')
|
author = Fabricate(:account, username: 'original')
|
||||||
Fabricate(:status, account: author)
|
Fabricate(:status, account: author)
|
||||||
end
|
end
|
||||||
|
|
||||||
subject { Fabricate(:account) }
|
|
||||||
|
|
||||||
context 'when the status is a reblog of another status' do
|
context 'when the status is a reblog of another status' do
|
||||||
let(:original_reblog) do
|
let(:original_reblog) do
|
||||||
author = Fabricate(:account, username: 'original_reblogger')
|
author = Fabricate(:account, username: 'original_reblogger')
|
||||||
@ -281,13 +281,13 @@ RSpec.describe Account, type: :model do
|
|||||||
end
|
end
|
||||||
|
|
||||||
describe '#reblogged?' do
|
describe '#reblogged?' do
|
||||||
|
subject { Fabricate(:account) }
|
||||||
|
|
||||||
let(:original_status) do
|
let(:original_status) do
|
||||||
author = Fabricate(:account, username: 'original')
|
author = Fabricate(:account, username: 'original')
|
||||||
Fabricate(:status, account: author)
|
Fabricate(:status, account: author)
|
||||||
end
|
end
|
||||||
|
|
||||||
subject { Fabricate(:account) }
|
|
||||||
|
|
||||||
context 'when the status is a reblog of another status' do
|
context 'when the status is a reblog of another status' do
|
||||||
let(:original_reblog) do
|
let(:original_reblog) do
|
||||||
author = Fabricate(:account, username: 'original_reblogger')
|
author = Fabricate(:account, username: 'original_reblogger')
|
||||||
|
@ -132,11 +132,11 @@ RSpec.describe AccountStatusesCleanupPolicy, type: :model do
|
|||||||
end
|
end
|
||||||
|
|
||||||
describe '#invalidate_last_inspected' do
|
describe '#invalidate_last_inspected' do
|
||||||
|
subject { account_statuses_cleanup_policy.invalidate_last_inspected(status, action) }
|
||||||
|
|
||||||
let(:account_statuses_cleanup_policy) { Fabricate(:account_statuses_cleanup_policy, account: account) }
|
let(:account_statuses_cleanup_policy) { Fabricate(:account_statuses_cleanup_policy, account: account) }
|
||||||
let(:status) { Fabricate(:status, id: 10, account: account) }
|
let(:status) { Fabricate(:status, id: 10, account: account) }
|
||||||
|
|
||||||
subject { account_statuses_cleanup_policy.invalidate_last_inspected(status, action) }
|
|
||||||
|
|
||||||
before do
|
before do
|
||||||
account_statuses_cleanup_policy.record_last_inspected(42)
|
account_statuses_cleanup_policy.record_last_inspected(42)
|
||||||
end
|
end
|
||||||
@ -231,11 +231,11 @@ RSpec.describe AccountStatusesCleanupPolicy, type: :model do
|
|||||||
end
|
end
|
||||||
|
|
||||||
describe '#compute_cutoff_id' do
|
describe '#compute_cutoff_id' do
|
||||||
|
subject { account_statuses_cleanup_policy.compute_cutoff_id }
|
||||||
|
|
||||||
let!(:unrelated_status) { Fabricate(:status, created_at: 3.years.ago) }
|
let!(:unrelated_status) { Fabricate(:status, created_at: 3.years.ago) }
|
||||||
let(:account_statuses_cleanup_policy) { Fabricate(:account_statuses_cleanup_policy, account: account) }
|
let(:account_statuses_cleanup_policy) { Fabricate(:account_statuses_cleanup_policy, account: account) }
|
||||||
|
|
||||||
subject { account_statuses_cleanup_policy.compute_cutoff_id }
|
|
||||||
|
|
||||||
context 'when the account has posted multiple toots' do
|
context 'when the account has posted multiple toots' do
|
||||||
let!(:very_old_status) { Fabricate(:status, created_at: 3.years.ago, account: account) }
|
let!(:very_old_status) { Fabricate(:status, created_at: 3.years.ago, account: account) }
|
||||||
let!(:old_status) { Fabricate(:status, created_at: 3.weeks.ago, account: account) }
|
let!(:old_status) { Fabricate(:status, created_at: 3.weeks.ago, account: account) }
|
||||||
@ -254,6 +254,8 @@ RSpec.describe AccountStatusesCleanupPolicy, type: :model do
|
|||||||
end
|
end
|
||||||
|
|
||||||
describe '#statuses_to_delete' do
|
describe '#statuses_to_delete' do
|
||||||
|
subject { account_statuses_cleanup_policy.statuses_to_delete }
|
||||||
|
|
||||||
let!(:unrelated_status) { Fabricate(:status, created_at: 3.years.ago) }
|
let!(:unrelated_status) { Fabricate(:status, created_at: 3.years.ago) }
|
||||||
let!(:very_old_status) { Fabricate(:status, created_at: 3.years.ago, account: account) }
|
let!(:very_old_status) { Fabricate(:status, created_at: 3.years.ago, account: account) }
|
||||||
let!(:pinned_status) { Fabricate(:status, created_at: 1.year.ago, account: account) }
|
let!(:pinned_status) { Fabricate(:status, created_at: 1.year.ago, account: account) }
|
||||||
@ -275,8 +277,6 @@ RSpec.describe AccountStatusesCleanupPolicy, type: :model do
|
|||||||
|
|
||||||
let(:account_statuses_cleanup_policy) { Fabricate(:account_statuses_cleanup_policy, account: account) }
|
let(:account_statuses_cleanup_policy) { Fabricate(:account_statuses_cleanup_policy, account: account) }
|
||||||
|
|
||||||
subject { account_statuses_cleanup_policy.statuses_to_delete }
|
|
||||||
|
|
||||||
before do
|
before do
|
||||||
4.times { faved4.increment_count!(:favourites_count) }
|
4.times { faved4.increment_count!(:favourites_count) }
|
||||||
5.times { faved5.increment_count!(:favourites_count) }
|
5.times { faved5.increment_count!(:favourites_count) }
|
||||||
@ -285,11 +285,11 @@ RSpec.describe AccountStatusesCleanupPolicy, type: :model do
|
|||||||
end
|
end
|
||||||
|
|
||||||
context 'when passed a max_id' do
|
context 'when passed a max_id' do
|
||||||
|
subject { account_statuses_cleanup_policy.statuses_to_delete(50, old_status.id).pluck(:id) }
|
||||||
|
|
||||||
let!(:old_status) { Fabricate(:status, created_at: 1.year.ago, account: account) }
|
let!(:old_status) { Fabricate(:status, created_at: 1.year.ago, account: account) }
|
||||||
let!(:slightly_less_old_status) { Fabricate(:status, created_at: 6.months.ago, account: account) }
|
let!(:slightly_less_old_status) { Fabricate(:status, created_at: 6.months.ago, account: account) }
|
||||||
|
|
||||||
subject { account_statuses_cleanup_policy.statuses_to_delete(50, old_status.id).pluck(:id) }
|
|
||||||
|
|
||||||
it 'returns statuses including max_id' do
|
it 'returns statuses including max_id' do
|
||||||
expect(subject).to include(old_status.id)
|
expect(subject).to include(old_status.id)
|
||||||
end
|
end
|
||||||
@ -304,11 +304,11 @@ RSpec.describe AccountStatusesCleanupPolicy, type: :model do
|
|||||||
end
|
end
|
||||||
|
|
||||||
context 'when passed a min_id' do
|
context 'when passed a min_id' do
|
||||||
|
subject { account_statuses_cleanup_policy.statuses_to_delete(50, recent_status.id, old_status.id).pluck(:id) }
|
||||||
|
|
||||||
let!(:old_status) { Fabricate(:status, created_at: 1.year.ago, account: account) }
|
let!(:old_status) { Fabricate(:status, created_at: 1.year.ago, account: account) }
|
||||||
let!(:slightly_less_old_status) { Fabricate(:status, created_at: 6.months.ago, account: account) }
|
let!(:slightly_less_old_status) { Fabricate(:status, created_at: 6.months.ago, account: account) }
|
||||||
|
|
||||||
subject { account_statuses_cleanup_policy.statuses_to_delete(50, recent_status.id, old_status.id).pluck(:id) }
|
|
||||||
|
|
||||||
it 'returns statuses including min_id' do
|
it 'returns statuses including min_id' do
|
||||||
expect(subject).to include(old_status.id)
|
expect(subject).to include(old_status.id)
|
||||||
end
|
end
|
||||||
|
@ -3,12 +3,12 @@
|
|||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
RSpec.describe AccountStatusesFilter do
|
RSpec.describe AccountStatusesFilter do
|
||||||
|
subject { described_class.new(account, current_account, params) }
|
||||||
|
|
||||||
let(:account) { Fabricate(:account) }
|
let(:account) { Fabricate(:account) }
|
||||||
let(:current_account) { nil }
|
let(:current_account) { nil }
|
||||||
let(:params) { {} }
|
let(:params) { {} }
|
||||||
|
|
||||||
subject { described_class.new(account, current_account, params) }
|
|
||||||
|
|
||||||
def status!(visibility)
|
def status!(visibility)
|
||||||
Fabricate(:status, account: account, visibility: visibility)
|
Fabricate(:status, account: account, visibility: visibility)
|
||||||
end
|
end
|
||||||
|
@ -225,10 +225,10 @@ describe AccountInteractions do
|
|||||||
end
|
end
|
||||||
|
|
||||||
describe '#mute_conversation!' do
|
describe '#mute_conversation!' do
|
||||||
let(:conversation) { Fabricate(:conversation) }
|
|
||||||
|
|
||||||
subject { account.mute_conversation!(conversation) }
|
subject { account.mute_conversation!(conversation) }
|
||||||
|
|
||||||
|
let(:conversation) { Fabricate(:conversation) }
|
||||||
|
|
||||||
it 'creates and returns ConversationMute' do
|
it 'creates and returns ConversationMute' do
|
||||||
expect do
|
expect do
|
||||||
expect(subject).to be_a ConversationMute
|
expect(subject).to be_a ConversationMute
|
||||||
@ -237,10 +237,10 @@ describe AccountInteractions do
|
|||||||
end
|
end
|
||||||
|
|
||||||
describe '#block_domain!' do
|
describe '#block_domain!' do
|
||||||
let(:domain) { 'example.com' }
|
|
||||||
|
|
||||||
subject { account.block_domain!(domain) }
|
subject { account.block_domain!(domain) }
|
||||||
|
|
||||||
|
let(:domain) { 'example.com' }
|
||||||
|
|
||||||
it 'creates and returns AccountDomainBlock' do
|
it 'creates and returns AccountDomainBlock' do
|
||||||
expect do
|
expect do
|
||||||
expect(subject).to be_a AccountDomainBlock
|
expect(subject).to be_a AccountDomainBlock
|
||||||
@ -303,10 +303,10 @@ describe AccountInteractions do
|
|||||||
end
|
end
|
||||||
|
|
||||||
describe '#unmute_conversation!' do
|
describe '#unmute_conversation!' do
|
||||||
let(:conversation) { Fabricate(:conversation) }
|
|
||||||
|
|
||||||
subject { account.unmute_conversation!(conversation) }
|
subject { account.unmute_conversation!(conversation) }
|
||||||
|
|
||||||
|
let(:conversation) { Fabricate(:conversation) }
|
||||||
|
|
||||||
context 'muting the conversation' do
|
context 'muting the conversation' do
|
||||||
it 'returns destroyed ConversationMute' do
|
it 'returns destroyed ConversationMute' do
|
||||||
account.conversation_mutes.create(conversation: conversation)
|
account.conversation_mutes.create(conversation: conversation)
|
||||||
@ -323,10 +323,10 @@ describe AccountInteractions do
|
|||||||
end
|
end
|
||||||
|
|
||||||
describe '#unblock_domain!' do
|
describe '#unblock_domain!' do
|
||||||
let(:domain) { 'example.com' }
|
|
||||||
|
|
||||||
subject { account.unblock_domain!(domain) }
|
subject { account.unblock_domain!(domain) }
|
||||||
|
|
||||||
|
let(:domain) { 'example.com' }
|
||||||
|
|
||||||
context 'blocking the domain' do
|
context 'blocking the domain' do
|
||||||
it 'returns destroyed AccountDomainBlock' do
|
it 'returns destroyed AccountDomainBlock' do
|
||||||
account_domain_block = Fabricate(:account_domain_block, domain: domain)
|
account_domain_block = Fabricate(:account_domain_block, domain: domain)
|
||||||
@ -395,10 +395,10 @@ describe AccountInteractions do
|
|||||||
end
|
end
|
||||||
|
|
||||||
describe '#domain_blocking?' do
|
describe '#domain_blocking?' do
|
||||||
let(:domain) { 'example.com' }
|
|
||||||
|
|
||||||
subject { account.domain_blocking?(domain) }
|
subject { account.domain_blocking?(domain) }
|
||||||
|
|
||||||
|
let(:domain) { 'example.com' }
|
||||||
|
|
||||||
context 'blocking the domain' do
|
context 'blocking the domain' do
|
||||||
it 'returns true' do
|
it 'returns true' do
|
||||||
account_domain_block = Fabricate(:account_domain_block, domain: domain)
|
account_domain_block = Fabricate(:account_domain_block, domain: domain)
|
||||||
@ -433,10 +433,10 @@ describe AccountInteractions do
|
|||||||
end
|
end
|
||||||
|
|
||||||
describe '#muting_conversation?' do
|
describe '#muting_conversation?' do
|
||||||
let(:conversation) { Fabricate(:conversation) }
|
|
||||||
|
|
||||||
subject { account.muting_conversation?(conversation) }
|
subject { account.muting_conversation?(conversation) }
|
||||||
|
|
||||||
|
let(:conversation) { Fabricate(:conversation) }
|
||||||
|
|
||||||
context 'muting the conversation' do
|
context 'muting the conversation' do
|
||||||
it 'returns true' do
|
it 'returns true' do
|
||||||
account.conversation_mutes.create(conversation: conversation)
|
account.conversation_mutes.create(conversation: conversation)
|
||||||
@ -452,13 +452,13 @@ describe AccountInteractions do
|
|||||||
end
|
end
|
||||||
|
|
||||||
describe '#muting_notifications?' do
|
describe '#muting_notifications?' do
|
||||||
|
subject { account.muting_notifications?(target_account) }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
mute = Fabricate(:mute, target_account: target_account, account: account, hide_notifications: hide)
|
mute = Fabricate(:mute, target_account: target_account, account: account, hide_notifications: hide)
|
||||||
account.mute_relationships << mute
|
account.mute_relationships << mute
|
||||||
end
|
end
|
||||||
|
|
||||||
subject { account.muting_notifications?(target_account) }
|
|
||||||
|
|
||||||
context 'muting notifications of target_account' do
|
context 'muting notifications of target_account' do
|
||||||
let(:hide) { true }
|
let(:hide) { true }
|
||||||
|
|
||||||
@ -494,10 +494,10 @@ describe AccountInteractions do
|
|||||||
end
|
end
|
||||||
|
|
||||||
describe '#favourited?' do
|
describe '#favourited?' do
|
||||||
let(:status) { Fabricate(:status, account: account, favourites: favourites) }
|
|
||||||
|
|
||||||
subject { account.favourited?(status) }
|
subject { account.favourited?(status) }
|
||||||
|
|
||||||
|
let(:status) { Fabricate(:status, account: account, favourites: favourites) }
|
||||||
|
|
||||||
context 'favorited' do
|
context 'favorited' do
|
||||||
let(:favourites) { [Fabricate(:favourite, account: account)] }
|
let(:favourites) { [Fabricate(:favourite, account: account)] }
|
||||||
|
|
||||||
@ -516,10 +516,10 @@ describe AccountInteractions do
|
|||||||
end
|
end
|
||||||
|
|
||||||
describe '#reblogged?' do
|
describe '#reblogged?' do
|
||||||
let(:status) { Fabricate(:status, account: account, reblogs: reblogs) }
|
|
||||||
|
|
||||||
subject { account.reblogged?(status) }
|
subject { account.reblogged?(status) }
|
||||||
|
|
||||||
|
let(:status) { Fabricate(:status, account: account, reblogs: reblogs) }
|
||||||
|
|
||||||
context 'reblogged' do
|
context 'reblogged' do
|
||||||
let(:reblogs) { [Fabricate(:status, account: account)] }
|
let(:reblogs) { [Fabricate(:status, account: account)] }
|
||||||
|
|
||||||
@ -538,10 +538,10 @@ describe AccountInteractions do
|
|||||||
end
|
end
|
||||||
|
|
||||||
describe '#pinned?' do
|
describe '#pinned?' do
|
||||||
let(:status) { Fabricate(:status, account: account) }
|
|
||||||
|
|
||||||
subject { account.pinned?(status) }
|
subject { account.pinned?(status) }
|
||||||
|
|
||||||
|
let(:status) { Fabricate(:status, account: account) }
|
||||||
|
|
||||||
context 'pinned' do
|
context 'pinned' do
|
||||||
it 'returns true' do
|
it 'returns true' do
|
||||||
Fabricate(:status_pin, account: account, status: status)
|
Fabricate(:status_pin, account: account, status: status)
|
||||||
|
@ -4,12 +4,12 @@ require 'rails_helper'
|
|||||||
|
|
||||||
RSpec.describe CustomEmojiFilter do
|
RSpec.describe CustomEmojiFilter do
|
||||||
describe '#results' do
|
describe '#results' do
|
||||||
|
subject { described_class.new(params).results }
|
||||||
|
|
||||||
let!(:custom_emoji_0) { Fabricate(:custom_emoji, domain: 'a') }
|
let!(:custom_emoji_0) { Fabricate(:custom_emoji, domain: 'a') }
|
||||||
let!(:custom_emoji_1) { Fabricate(:custom_emoji, domain: 'b') }
|
let!(:custom_emoji_1) { Fabricate(:custom_emoji, domain: 'b') }
|
||||||
let!(:custom_emoji_2) { Fabricate(:custom_emoji, domain: nil, shortcode: 'hoge') }
|
let!(:custom_emoji_2) { Fabricate(:custom_emoji, domain: nil, shortcode: 'hoge') }
|
||||||
|
|
||||||
subject { described_class.new(params).results }
|
|
||||||
|
|
||||||
context 'params have values' do
|
context 'params have values' do
|
||||||
context 'local' do
|
context 'local' do
|
||||||
let(:params) { { local: true } }
|
let(:params) { { local: true } }
|
||||||
|
@ -2,10 +2,10 @@ require 'rails_helper'
|
|||||||
|
|
||||||
RSpec.describe CustomEmoji, type: :model do
|
RSpec.describe CustomEmoji, type: :model do
|
||||||
describe '#search' do
|
describe '#search' do
|
||||||
let(:custom_emoji) { Fabricate(:custom_emoji, shortcode: shortcode) }
|
|
||||||
|
|
||||||
subject { described_class.search(search_term) }
|
subject { described_class.search(search_term) }
|
||||||
|
|
||||||
|
let(:custom_emoji) { Fabricate(:custom_emoji, shortcode: shortcode) }
|
||||||
|
|
||||||
context 'shortcode is exact' do
|
context 'shortcode is exact' do
|
||||||
let(:shortcode) { 'blobpats' }
|
let(:shortcode) { 'blobpats' }
|
||||||
let(:search_term) { 'blobpats' }
|
let(:search_term) { 'blobpats' }
|
||||||
@ -26,10 +26,10 @@ RSpec.describe CustomEmoji, type: :model do
|
|||||||
end
|
end
|
||||||
|
|
||||||
describe '#local?' do
|
describe '#local?' do
|
||||||
let(:custom_emoji) { Fabricate(:custom_emoji, domain: domain) }
|
|
||||||
|
|
||||||
subject { custom_emoji.local? }
|
subject { custom_emoji.local? }
|
||||||
|
|
||||||
|
let(:custom_emoji) { Fabricate(:custom_emoji, domain: domain) }
|
||||||
|
|
||||||
context 'domain is nil' do
|
context 'domain is nil' do
|
||||||
let(:domain) { nil }
|
let(:domain) { nil }
|
||||||
|
|
||||||
@ -55,10 +55,10 @@ RSpec.describe CustomEmoji, type: :model do
|
|||||||
end
|
end
|
||||||
|
|
||||||
describe '.from_text' do
|
describe '.from_text' do
|
||||||
let!(:emojo) { Fabricate(:custom_emoji) }
|
|
||||||
|
|
||||||
subject { described_class.from_text(text, nil) }
|
subject { described_class.from_text(text, nil) }
|
||||||
|
|
||||||
|
let!(:emojo) { Fabricate(:custom_emoji) }
|
||||||
|
|
||||||
context 'with plain text' do
|
context 'with plain text' do
|
||||||
let(:text) { 'Hello :coolcat:' }
|
let(:text) { 'Hello :coolcat:' }
|
||||||
|
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
RSpec.describe HomeFeed, type: :model do
|
RSpec.describe HomeFeed, type: :model do
|
||||||
let(:account) { Fabricate(:account) }
|
|
||||||
|
|
||||||
subject { described_class.new(account) }
|
subject { described_class.new(account) }
|
||||||
|
|
||||||
|
let(:account) { Fabricate(:account) }
|
||||||
|
|
||||||
describe '#get' do
|
describe '#get' do
|
||||||
before do
|
before do
|
||||||
Fabricate(:status, account: account, id: 1)
|
Fabricate(:status, account: account, id: 1)
|
||||||
|
@ -2,10 +2,10 @@ require 'rails_helper'
|
|||||||
|
|
||||||
RSpec.describe MediaAttachment, type: :model do
|
RSpec.describe MediaAttachment, type: :model do
|
||||||
describe 'local?' do
|
describe 'local?' do
|
||||||
let(:media_attachment) { Fabricate(:media_attachment, remote_url: remote_url) }
|
|
||||||
|
|
||||||
subject { media_attachment.local? }
|
subject { media_attachment.local? }
|
||||||
|
|
||||||
|
let(:media_attachment) { Fabricate(:media_attachment, remote_url: remote_url) }
|
||||||
|
|
||||||
context 'remote_url is blank' do
|
context 'remote_url is blank' do
|
||||||
let(:remote_url) { '' }
|
let(:remote_url) { '' }
|
||||||
|
|
||||||
@ -24,10 +24,10 @@ RSpec.describe MediaAttachment, type: :model do
|
|||||||
end
|
end
|
||||||
|
|
||||||
describe 'needs_redownload?' do
|
describe 'needs_redownload?' do
|
||||||
let(:media_attachment) { Fabricate(:media_attachment, remote_url: remote_url, file: file) }
|
|
||||||
|
|
||||||
subject { media_attachment.needs_redownload? }
|
subject { media_attachment.needs_redownload? }
|
||||||
|
|
||||||
|
let(:media_attachment) { Fabricate(:media_attachment, remote_url: remote_url, file: file) }
|
||||||
|
|
||||||
context 'file is blank' do
|
context 'file is blank' do
|
||||||
let(:file) { nil }
|
let(:file) { nil }
|
||||||
|
|
||||||
|
@ -40,6 +40,8 @@ RSpec.describe PublicFeed, type: :model do
|
|||||||
end
|
end
|
||||||
|
|
||||||
context 'without local_only option' do
|
context 'without local_only option' do
|
||||||
|
subject { described_class.new(viewer).get(20).map(&:id) }
|
||||||
|
|
||||||
let(:viewer) { nil }
|
let(:viewer) { nil }
|
||||||
|
|
||||||
let!(:local_account) { Fabricate(:account, domain: nil) }
|
let!(:local_account) { Fabricate(:account, domain: nil) }
|
||||||
@ -47,8 +49,6 @@ RSpec.describe PublicFeed, type: :model do
|
|||||||
let!(:local_status) { Fabricate(:status, account: local_account) }
|
let!(:local_status) { Fabricate(:status, account: local_account) }
|
||||||
let!(:remote_status) { Fabricate(:status, account: remote_account) }
|
let!(:remote_status) { Fabricate(:status, account: remote_account) }
|
||||||
|
|
||||||
subject { described_class.new(viewer).get(20).map(&:id) }
|
|
||||||
|
|
||||||
context 'without a viewer' do
|
context 'without a viewer' do
|
||||||
let(:viewer) { nil }
|
let(:viewer) { nil }
|
||||||
|
|
||||||
@ -75,13 +75,13 @@ RSpec.describe PublicFeed, type: :model do
|
|||||||
end
|
end
|
||||||
|
|
||||||
context 'with a local_only option set' do
|
context 'with a local_only option set' do
|
||||||
|
subject { described_class.new(viewer, local: true).get(20).map(&:id) }
|
||||||
|
|
||||||
let!(:local_account) { Fabricate(:account, domain: nil) }
|
let!(:local_account) { Fabricate(:account, domain: nil) }
|
||||||
let!(:remote_account) { Fabricate(:account, domain: 'test.com') }
|
let!(:remote_account) { Fabricate(:account, domain: 'test.com') }
|
||||||
let!(:local_status) { Fabricate(:status, account: local_account) }
|
let!(:local_status) { Fabricate(:status, account: local_account) }
|
||||||
let!(:remote_status) { Fabricate(:status, account: remote_account) }
|
let!(:remote_status) { Fabricate(:status, account: remote_account) }
|
||||||
|
|
||||||
subject { described_class.new(viewer, local: true).get(20).map(&:id) }
|
|
||||||
|
|
||||||
context 'without a viewer' do
|
context 'without a viewer' do
|
||||||
let(:viewer) { nil }
|
let(:viewer) { nil }
|
||||||
|
|
||||||
@ -108,13 +108,13 @@ RSpec.describe PublicFeed, type: :model do
|
|||||||
end
|
end
|
||||||
|
|
||||||
context 'with a remote_only option set' do
|
context 'with a remote_only option set' do
|
||||||
|
subject { described_class.new(viewer, remote: true).get(20).map(&:id) }
|
||||||
|
|
||||||
let!(:local_account) { Fabricate(:account, domain: nil) }
|
let!(:local_account) { Fabricate(:account, domain: nil) }
|
||||||
let!(:remote_account) { Fabricate(:account, domain: 'test.com') }
|
let!(:remote_account) { Fabricate(:account, domain: 'test.com') }
|
||||||
let!(:local_status) { Fabricate(:status, account: local_account) }
|
let!(:local_status) { Fabricate(:status, account: local_account) }
|
||||||
let!(:remote_status) { Fabricate(:status, account: remote_account) }
|
let!(:remote_status) { Fabricate(:status, account: remote_account) }
|
||||||
|
|
||||||
subject { described_class.new(viewer, remote: true).get(20).map(&:id) }
|
|
||||||
|
|
||||||
context 'without a viewer' do
|
context 'without a viewer' do
|
||||||
let(:viewer) { nil }
|
let(:viewer) { nil }
|
||||||
|
|
||||||
@ -135,12 +135,12 @@ RSpec.describe PublicFeed, type: :model do
|
|||||||
end
|
end
|
||||||
|
|
||||||
describe 'with an account passed in' do
|
describe 'with an account passed in' do
|
||||||
|
subject { described_class.new(@account).get(20).map(&:id) }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
@account = Fabricate(:account)
|
@account = Fabricate(:account)
|
||||||
end
|
end
|
||||||
|
|
||||||
subject { described_class.new(@account).get(20).map(&:id) }
|
|
||||||
|
|
||||||
it 'excludes statuses from accounts blocked by the account' do
|
it 'excludes statuses from accounts blocked by the account' do
|
||||||
blocked = Fabricate(:account)
|
blocked = Fabricate(:account)
|
||||||
@account.block!(blocked)
|
@account.block!(blocked)
|
||||||
|
@ -51,6 +51,8 @@ RSpec.describe RemoteFollow do
|
|||||||
end
|
end
|
||||||
|
|
||||||
describe '#subscribe_address_for' do
|
describe '#subscribe_address_for' do
|
||||||
|
subject { remote_follow.subscribe_address_for(account) }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
remote_follow.valid?
|
remote_follow.valid?
|
||||||
end
|
end
|
||||||
@ -58,8 +60,6 @@ RSpec.describe RemoteFollow do
|
|||||||
let(:attrs) { { acct: 'gargron@quitter.no' } }
|
let(:attrs) { { acct: 'gargron@quitter.no' } }
|
||||||
let(:account) { Fabricate(:account, username: 'alice') }
|
let(:account) { Fabricate(:account, username: 'alice') }
|
||||||
|
|
||||||
subject { remote_follow.subscribe_address_for(account) }
|
|
||||||
|
|
||||||
it 'returns subscribe address' do
|
it 'returns subscribe address' do
|
||||||
expect(subject).to eq 'https://quitter.no/main/ostatussub?profile=https%3A%2F%2Fcb6e6126.ngrok.io%2Fusers%2Falice'
|
expect(subject).to eq 'https://quitter.no/main/ostatussub?profile=https%3A%2F%2Fcb6e6126.ngrok.io%2Fusers%2Falice'
|
||||||
end
|
end
|
||||||
|
@ -163,12 +163,12 @@ RSpec.describe Setting, type: :model do
|
|||||||
end
|
end
|
||||||
|
|
||||||
describe '.default_settings' do
|
describe '.default_settings' do
|
||||||
|
subject { described_class.default_settings }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
allow(RailsSettings::Default).to receive(:enabled?).and_return(enabled)
|
allow(RailsSettings::Default).to receive(:enabled?).and_return(enabled)
|
||||||
end
|
end
|
||||||
|
|
||||||
subject { described_class.default_settings }
|
|
||||||
|
|
||||||
context 'RailsSettings::Default.enabled? is false' do
|
context 'RailsSettings::Default.enabled? is false' do
|
||||||
let(:enabled) { false }
|
let(:enabled) { false }
|
||||||
|
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
RSpec.describe Status, type: :model do
|
RSpec.describe Status, type: :model do
|
||||||
|
subject { Fabricate(:status, account: alice) }
|
||||||
|
|
||||||
let(:alice) { Fabricate(:account, username: 'alice') }
|
let(:alice) { Fabricate(:account, username: 'alice') }
|
||||||
let(:bob) { Fabricate(:account, username: 'bob') }
|
let(:bob) { Fabricate(:account, username: 'bob') }
|
||||||
let(:other) { Fabricate(:status, account: bob, text: 'Skulls for the skull god! The enemy\'s gates are sideways!') }
|
let(:other) { Fabricate(:status, account: bob, text: 'Skulls for the skull god! The enemy\'s gates are sideways!') }
|
||||||
|
|
||||||
subject { Fabricate(:status, account: alice) }
|
|
||||||
|
|
||||||
describe '#local?' do
|
describe '#local?' do
|
||||||
it 'returns true when no remote URI is set' do
|
it 'returns true when no remote URI is set' do
|
||||||
expect(subject.local?).to be true
|
expect(subject.local?).to be true
|
||||||
@ -204,11 +204,11 @@ RSpec.describe Status, type: :model do
|
|||||||
end
|
end
|
||||||
|
|
||||||
describe '.mutes_map' do
|
describe '.mutes_map' do
|
||||||
|
subject { Status.mutes_map([status.conversation.id], account) }
|
||||||
|
|
||||||
let(:status) { Fabricate(:status) }
|
let(:status) { Fabricate(:status) }
|
||||||
let(:account) { Fabricate(:account) }
|
let(:account) { Fabricate(:account) }
|
||||||
|
|
||||||
subject { Status.mutes_map([status.conversation.id], account) }
|
|
||||||
|
|
||||||
it 'returns a hash' do
|
it 'returns a hash' do
|
||||||
expect(subject).to be_a Hash
|
expect(subject).to be_a Hash
|
||||||
end
|
end
|
||||||
@ -220,11 +220,11 @@ RSpec.describe Status, type: :model do
|
|||||||
end
|
end
|
||||||
|
|
||||||
describe '.favourites_map' do
|
describe '.favourites_map' do
|
||||||
|
subject { Status.favourites_map([status], account) }
|
||||||
|
|
||||||
let(:status) { Fabricate(:status) }
|
let(:status) { Fabricate(:status) }
|
||||||
let(:account) { Fabricate(:account) }
|
let(:account) { Fabricate(:account) }
|
||||||
|
|
||||||
subject { Status.favourites_map([status], account) }
|
|
||||||
|
|
||||||
it 'returns a hash' do
|
it 'returns a hash' do
|
||||||
expect(subject).to be_a Hash
|
expect(subject).to be_a Hash
|
||||||
end
|
end
|
||||||
@ -236,11 +236,11 @@ RSpec.describe Status, type: :model do
|
|||||||
end
|
end
|
||||||
|
|
||||||
describe '.reblogs_map' do
|
describe '.reblogs_map' do
|
||||||
|
subject { Status.reblogs_map([status], account) }
|
||||||
|
|
||||||
let(:status) { Fabricate(:status) }
|
let(:status) { Fabricate(:status) }
|
||||||
let(:account) { Fabricate(:account) }
|
let(:account) { Fabricate(:account) }
|
||||||
|
|
||||||
subject { Status.reblogs_map([status], account) }
|
|
||||||
|
|
||||||
it 'returns a hash' do
|
it 'returns a hash' do
|
||||||
expect(subject).to be_a Hash
|
expect(subject).to be_a Hash
|
||||||
end
|
end
|
||||||
|
@ -142,10 +142,10 @@ RSpec.describe User, type: :model do
|
|||||||
end
|
end
|
||||||
|
|
||||||
describe '#confirm' do
|
describe '#confirm' do
|
||||||
let(:new_email) { 'new-email@example.com' }
|
|
||||||
|
|
||||||
subject { user.confirm }
|
subject { user.confirm }
|
||||||
|
|
||||||
|
let(:new_email) { 'new-email@example.com' }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
allow(TriggerWebhookWorker).to receive(:perform_async)
|
allow(TriggerWebhookWorker).to receive(:perform_async)
|
||||||
end
|
end
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
RSpec.describe Web::PushSubscription, type: :model do
|
RSpec.describe Web::PushSubscription, type: :model do
|
||||||
|
subject { described_class.new(data: data) }
|
||||||
|
|
||||||
let(:account) { Fabricate(:account) }
|
let(:account) { Fabricate(:account) }
|
||||||
|
|
||||||
let(:policy) { 'all' }
|
let(:policy) { 'all' }
|
||||||
@ -19,8 +21,6 @@ RSpec.describe Web::PushSubscription, type: :model do
|
|||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
subject { described_class.new(data: data) }
|
|
||||||
|
|
||||||
describe '#pushable?' do
|
describe '#pushable?' do
|
||||||
let(:notification_type) { :mention }
|
let(:notification_type) { :mention }
|
||||||
let(:notification) { Fabricate(:notification, account: account, type: notification_type) }
|
let(:notification) { Fabricate(:notification, account: account, type: notification_type) }
|
||||||
|
@ -4,12 +4,12 @@ require 'rails_helper'
|
|||||||
|
|
||||||
RSpec.describe FamiliarFollowersPresenter do
|
RSpec.describe FamiliarFollowersPresenter do
|
||||||
describe '#accounts' do
|
describe '#accounts' do
|
||||||
|
subject { described_class.new(requested_accounts, account.id) }
|
||||||
|
|
||||||
let(:account) { Fabricate(:account) }
|
let(:account) { Fabricate(:account) }
|
||||||
let(:familiar_follower) { Fabricate(:account) }
|
let(:familiar_follower) { Fabricate(:account) }
|
||||||
let(:requested_accounts) { Fabricate.times(2, :account) }
|
let(:requested_accounts) { Fabricate.times(2, :account) }
|
||||||
|
|
||||||
subject { described_class.new(requested_accounts, account.id) }
|
|
||||||
|
|
||||||
before do
|
before do
|
||||||
familiar_follower.follow!(requested_accounts.first)
|
familiar_follower.follow!(requested_accounts.first)
|
||||||
account.follow!(familiar_follower)
|
account.follow!(familiar_follower)
|
||||||
|
@ -3,6 +3,8 @@
|
|||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
describe ActivityPub::NoteSerializer do
|
describe ActivityPub::NoteSerializer do
|
||||||
|
subject { JSON.parse(@serialization.to_json) }
|
||||||
|
|
||||||
let!(:account) { Fabricate(:account) }
|
let!(:account) { Fabricate(:account) }
|
||||||
let!(:other) { Fabricate(:account) }
|
let!(:other) { Fabricate(:account) }
|
||||||
let!(:parent) { Fabricate(:status, account: account, visibility: :public) }
|
let!(:parent) { Fabricate(:status, account: account, visibility: :public) }
|
||||||
@ -16,8 +18,6 @@ describe ActivityPub::NoteSerializer do
|
|||||||
@serialization = ActiveModelSerializers::SerializableResource.new(parent, serializer: ActivityPub::NoteSerializer, adapter: ActivityPub::Adapter)
|
@serialization = ActiveModelSerializers::SerializableResource.new(parent, serializer: ActivityPub::NoteSerializer, adapter: ActivityPub::Adapter)
|
||||||
end
|
end
|
||||||
|
|
||||||
subject { JSON.parse(@serialization.to_json) }
|
|
||||||
|
|
||||||
it 'has a Note type' do
|
it 'has a Note type' do
|
||||||
expect(subject['type']).to eql('Note')
|
expect(subject['type']).to eql('Note')
|
||||||
end
|
end
|
||||||
|
@ -3,6 +3,8 @@
|
|||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
describe ActivityPub::UpdatePollSerializer do
|
describe ActivityPub::UpdatePollSerializer do
|
||||||
|
subject { JSON.parse(@serialization.to_json) }
|
||||||
|
|
||||||
let(:account) { Fabricate(:account) }
|
let(:account) { Fabricate(:account) }
|
||||||
let(:poll) { Fabricate(:poll, account: account) }
|
let(:poll) { Fabricate(:poll, account: account) }
|
||||||
let!(:status) { Fabricate(:status, account: account, poll: poll) }
|
let!(:status) { Fabricate(:status, account: account, poll: poll) }
|
||||||
@ -11,8 +13,6 @@ describe ActivityPub::UpdatePollSerializer do
|
|||||||
@serialization = ActiveModelSerializers::SerializableResource.new(status, serializer: ActivityPub::UpdatePollSerializer, adapter: ActivityPub::Adapter)
|
@serialization = ActiveModelSerializers::SerializableResource.new(status, serializer: ActivityPub::UpdatePollSerializer, adapter: ActivityPub::Adapter)
|
||||||
end
|
end
|
||||||
|
|
||||||
subject { JSON.parse(@serialization.to_json) }
|
|
||||||
|
|
||||||
it 'has a Update type' do
|
it 'has a Update type' do
|
||||||
expect(subject['type']).to eql('Update')
|
expect(subject['type']).to eql('Update')
|
||||||
end
|
end
|
||||||
|
@ -3,12 +3,12 @@
|
|||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
describe REST::AccountSerializer do
|
describe REST::AccountSerializer do
|
||||||
|
subject { JSON.parse(ActiveModelSerializers::SerializableResource.new(account, serializer: REST::AccountSerializer).to_json) }
|
||||||
|
|
||||||
let(:role) { Fabricate(:user_role, name: 'Role', highlighted: true) }
|
let(:role) { Fabricate(:user_role, name: 'Role', highlighted: true) }
|
||||||
let(:user) { Fabricate(:user, role: role) }
|
let(:user) { Fabricate(:user, role: role) }
|
||||||
let(:account) { user.account }
|
let(:account) { user.account }
|
||||||
|
|
||||||
subject { JSON.parse(ActiveModelSerializers::SerializableResource.new(account, serializer: REST::AccountSerializer).to_json) }
|
|
||||||
|
|
||||||
context 'when the account is suspended' do
|
context 'when the account is suspended' do
|
||||||
before do
|
before do
|
||||||
account.suspend!
|
account.suspend!
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
RSpec.describe ActivityPub::FetchFeaturedCollectionService, type: :service do
|
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(: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') }
|
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
|
}.with_indifferent_access
|
||||||
end
|
end
|
||||||
|
|
||||||
subject { described_class.new }
|
|
||||||
|
|
||||||
shared_examples 'sets pinned posts' do
|
shared_examples 'sets pinned posts' do
|
||||||
before do
|
before do
|
||||||
stub_request(:get, 'https://example.com/account/pinned/1').to_return(status: 200, body: Oj.dump(status_json_1))
|
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'
|
require 'rails_helper'
|
||||||
|
|
||||||
RSpec.describe ActivityPub::FetchFeaturedTagsCollectionService, type: :service do
|
RSpec.describe ActivityPub::FetchFeaturedTagsCollectionService, type: :service do
|
||||||
|
subject { described_class.new }
|
||||||
|
|
||||||
let(:collection_url) { 'https://example.com/account/tags' }
|
let(:collection_url) { 'https://example.com/account/tags' }
|
||||||
let(:actor) { Fabricate(:account, domain: 'example.com', uri: 'https://example.com/account') }
|
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
|
}.with_indifferent_access
|
||||||
end
|
end
|
||||||
|
|
||||||
subject { described_class.new }
|
|
||||||
|
|
||||||
shared_examples 'sets featured tags' do
|
shared_examples 'sets featured tags' do
|
||||||
before do
|
before do
|
||||||
subject.call(actor, collection_url)
|
subject.call(actor, collection_url)
|
||||||
|
@ -3,6 +3,8 @@ require 'rails_helper'
|
|||||||
RSpec.describe ActivityPub::FetchRemoteStatusService, type: :service do
|
RSpec.describe ActivityPub::FetchRemoteStatusService, type: :service do
|
||||||
include ActionView::Helpers::TextHelper
|
include ActionView::Helpers::TextHelper
|
||||||
|
|
||||||
|
subject { described_class.new }
|
||||||
|
|
||||||
let!(:sender) { Fabricate(:account, domain: 'foo.bar', uri: 'https://foo.bar') }
|
let!(:sender) { Fabricate(:account, domain: 'foo.bar', uri: 'https://foo.bar') }
|
||||||
let!(:recipient) { Fabricate(:account) }
|
let!(:recipient) { Fabricate(:account) }
|
||||||
|
|
||||||
@ -18,8 +20,6 @@ RSpec.describe ActivityPub::FetchRemoteStatusService, type: :service do
|
|||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
subject { described_class.new }
|
|
||||||
|
|
||||||
before do
|
before do
|
||||||
stub_request(:get, 'https://foo.bar/watch?v=12345').to_return(status: 404, body: '')
|
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))
|
stub_request(:get, object[:id]).to_return(body: Oj.dump(object))
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
RSpec.describe ActivityPub::FetchRepliesService, type: :service do
|
RSpec.describe ActivityPub::FetchRepliesService, type: :service do
|
||||||
|
subject { described_class.new }
|
||||||
|
|
||||||
let(:actor) { Fabricate(:account, domain: 'example.com', uri: 'http://example.com/account') }
|
let(:actor) { Fabricate(:account, domain: 'example.com', uri: 'http://example.com/account') }
|
||||||
let(:status) { Fabricate(:status, account: actor) }
|
let(:status) { Fabricate(:status, account: actor) }
|
||||||
let(:collection_uri) { 'http://example.com/replies/1' }
|
let(:collection_uri) { 'http://example.com/replies/1' }
|
||||||
@ -28,8 +30,6 @@ RSpec.describe ActivityPub::FetchRepliesService, type: :service do
|
|||||||
}.with_indifferent_access
|
}.with_indifferent_access
|
||||||
end
|
end
|
||||||
|
|
||||||
subject { described_class.new }
|
|
||||||
|
|
||||||
describe '#call' do
|
describe '#call' do
|
||||||
context 'when the payload is a Collection with inlined replies' do
|
context 'when the payload is a Collection with inlined replies' do
|
||||||
context 'when passing the collection itself' do
|
context 'when passing the collection itself' do
|
||||||
|
@ -31,6 +31,8 @@ RSpec.describe ActivityPub::ProcessAccountService, type: :service do
|
|||||||
end
|
end
|
||||||
|
|
||||||
context 'when account is not suspended' do
|
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!(:account) { Fabricate(:account, username: 'alice', domain: 'example.com') }
|
||||||
|
|
||||||
let(:payload) do
|
let(:payload) do
|
||||||
@ -46,8 +48,6 @@ RSpec.describe ActivityPub::ProcessAccountService, type: :service do
|
|||||||
allow(Admin::SuspensionWorker).to receive(:perform_async)
|
allow(Admin::SuspensionWorker).to receive(:perform_async)
|
||||||
end
|
end
|
||||||
|
|
||||||
subject { described_class.new.call('alice', 'example.com', payload) }
|
|
||||||
|
|
||||||
it 'suspends account remotely' do
|
it 'suspends account remotely' do
|
||||||
expect(subject.suspended?).to be true
|
expect(subject.suspended?).to be true
|
||||||
expect(subject.suspension_origin_remote?).to be true
|
expect(subject.suspension_origin_remote?).to be true
|
||||||
@ -60,6 +60,8 @@ RSpec.describe ActivityPub::ProcessAccountService, type: :service do
|
|||||||
end
|
end
|
||||||
|
|
||||||
context 'when account is suspended' do
|
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!(:account) { Fabricate(:account, username: 'alice', domain: 'example.com', display_name: '') }
|
||||||
|
|
||||||
let(:payload) do
|
let(:payload) do
|
||||||
@ -78,8 +80,6 @@ RSpec.describe ActivityPub::ProcessAccountService, type: :service do
|
|||||||
account.suspend!(origin: suspension_origin)
|
account.suspend!(origin: suspension_origin)
|
||||||
end
|
end
|
||||||
|
|
||||||
subject { described_class.new.call('alice', 'example.com', payload) }
|
|
||||||
|
|
||||||
context 'locally' do
|
context 'locally' do
|
||||||
let(:suspension_origin) { :local }
|
let(:suspension_origin) { :local }
|
||||||
|
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
RSpec.describe ActivityPub::ProcessCollectionService, type: :service do
|
RSpec.describe ActivityPub::ProcessCollectionService, type: :service do
|
||||||
|
subject { described_class.new }
|
||||||
|
|
||||||
let(:actor) { Fabricate(:account, domain: 'example.com', uri: 'http://example.com/account') }
|
let(:actor) { Fabricate(:account, domain: 'example.com', uri: 'http://example.com/account') }
|
||||||
|
|
||||||
let(:payload) do
|
let(:payload) do
|
||||||
@ -19,8 +21,6 @@ RSpec.describe ActivityPub::ProcessCollectionService, type: :service do
|
|||||||
|
|
||||||
let(:json) { Oj.dump(payload) }
|
let(:json) { Oj.dump(payload) }
|
||||||
|
|
||||||
subject { described_class.new }
|
|
||||||
|
|
||||||
describe '#call' do
|
describe '#call' do
|
||||||
context 'when actor is suspended' do
|
context 'when actor is suspended' do
|
||||||
before do
|
before do
|
||||||
|
@ -5,6 +5,8 @@ def poll_option_json(name, votes)
|
|||||||
end
|
end
|
||||||
|
|
||||||
RSpec.describe ActivityPub::ProcessStatusUpdateService, type: :service do
|
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!(:status) { Fabricate(:status, text: 'Hello world', account: Fabricate(:account, domain: 'example.com')) }
|
||||||
let(:payload) do
|
let(:payload) do
|
||||||
{
|
{
|
||||||
@ -35,8 +37,6 @@ RSpec.describe ActivityPub::ProcessStatusUpdateService, type: :service do
|
|||||||
media_attachments.each { |m| status.media_attachments << m }
|
media_attachments.each { |m| status.media_attachments << m }
|
||||||
end
|
end
|
||||||
|
|
||||||
subject { described_class.new }
|
|
||||||
|
|
||||||
describe '#call' do
|
describe '#call' do
|
||||||
it 'updates text' do
|
it 'updates text' do
|
||||||
subject.call(status, json)
|
subject.call(status, json)
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
RSpec.describe ActivityPub::SynchronizeFollowersService, type: :service do
|
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(:actor) { Fabricate(:account, domain: 'example.com', uri: 'http://example.com/account', inbox_url: 'http://example.com/inbox') }
|
||||||
let(:alice) { Fabricate(:account, username: 'alice') }
|
let(:alice) { Fabricate(:account, username: 'alice') }
|
||||||
let(:bob) { Fabricate(:account, username: 'bob') }
|
let(:bob) { Fabricate(:account, username: 'bob') }
|
||||||
@ -25,8 +27,6 @@ RSpec.describe ActivityPub::SynchronizeFollowersService, type: :service do
|
|||||||
}.with_indifferent_access
|
}.with_indifferent_access
|
||||||
end
|
end
|
||||||
|
|
||||||
subject { described_class.new }
|
|
||||||
|
|
||||||
shared_examples 'synchronizes followers' do
|
shared_examples 'synchronizes followers' do
|
||||||
before do
|
before do
|
||||||
alice.follow!(actor)
|
alice.follow!(actor)
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
RSpec.describe AfterBlockDomainFromAccountService, type: :service do
|
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!(:wolf) { Fabricate(:account, username: 'wolf', domain: 'evil.org', inbox_url: 'https://evil.org/inbox', protocol: :activitypub) }
|
||||||
let!(:alice) { Fabricate(:account, username: 'alice') }
|
let!(:alice) { Fabricate(:account, username: 'alice') }
|
||||||
|
|
||||||
subject { AfterBlockDomainFromAccountService.new }
|
|
||||||
|
|
||||||
before do
|
before do
|
||||||
stub_jsonld_contexts!
|
stub_jsonld_contexts!
|
||||||
allow(ActivityPub::DeliveryWorker).to receive(:perform_async)
|
allow(ActivityPub::DeliveryWorker).to receive(:perform_async)
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
RSpec.describe AppSignUpService, type: :service do
|
RSpec.describe AppSignUpService, type: :service do
|
||||||
|
subject { described_class.new }
|
||||||
|
|
||||||
let(:app) { Fabricate(:application, scopes: 'read write') }
|
let(:app) { Fabricate(:application, scopes: 'read write') }
|
||||||
let(:good_params) { { username: 'alice', password: '12345678', email: 'good@email.com', agreement: true } }
|
let(:good_params) { { username: 'alice', password: '12345678', email: 'good@email.com', agreement: true } }
|
||||||
let(:remote_ip) { IPAddr.new('198.0.2.1') }
|
let(:remote_ip) { IPAddr.new('198.0.2.1') }
|
||||||
|
|
||||||
subject { described_class.new }
|
|
||||||
|
|
||||||
describe '#call' do
|
describe '#call' do
|
||||||
it 'returns nil when registrations are closed' do
|
it 'returns nil when registrations are closed' do
|
||||||
tmp = Setting.registrations_mode
|
tmp = Setting.registrations_mode
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
RSpec.describe AuthorizeFollowService, type: :service do
|
RSpec.describe AuthorizeFollowService, type: :service do
|
||||||
let(:sender) { Fabricate(:account, username: 'alice') }
|
|
||||||
|
|
||||||
subject { AuthorizeFollowService.new }
|
subject { AuthorizeFollowService.new }
|
||||||
|
|
||||||
|
let(:sender) { Fabricate(:account, username: 'alice') }
|
||||||
|
|
||||||
describe 'local' do
|
describe 'local' do
|
||||||
let(:bob) { Fabricate(:account, username: 'bob') }
|
let(:bob) { Fabricate(:account, username: 'bob') }
|
||||||
|
|
||||||
|
@ -1,14 +1,14 @@
|
|||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
RSpec.describe BlockDomainService, type: :service do
|
RSpec.describe BlockDomainService, type: :service do
|
||||||
|
subject { BlockDomainService.new }
|
||||||
|
|
||||||
let!(:bad_account) { Fabricate(:account, username: 'badguy666', domain: 'evil.org') }
|
let!(:bad_account) { Fabricate(:account, username: 'badguy666', domain: 'evil.org') }
|
||||||
let!(:bad_status1) { Fabricate(:status, account: bad_account, text: 'You suck') }
|
let!(:bad_status1) { Fabricate(:status, account: bad_account, text: 'You suck') }
|
||||||
let!(:bad_status2) { Fabricate(:status, account: bad_account, text: 'Hahaha') }
|
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!(: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) }
|
let!(:already_banned_account) { Fabricate(:account, username: 'badguy', domain: 'evil.org', suspended: true, silenced: true) }
|
||||||
|
|
||||||
subject { BlockDomainService.new }
|
|
||||||
|
|
||||||
describe 'for a suspension' do
|
describe 'for a suspension' do
|
||||||
before do
|
before do
|
||||||
subject.call(DomainBlock.create!(domain: 'evil.org', severity: :suspend))
|
subject.call(DomainBlock.create!(domain: 'evil.org', severity: :suspend))
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
RSpec.describe BlockService, type: :service do
|
RSpec.describe BlockService, type: :service do
|
||||||
let(:sender) { Fabricate(:account, username: 'alice') }
|
|
||||||
|
|
||||||
subject { BlockService.new }
|
subject { BlockService.new }
|
||||||
|
|
||||||
|
let(:sender) { Fabricate(:account, username: 'alice') }
|
||||||
|
|
||||||
describe 'local' do
|
describe 'local' do
|
||||||
let(:bob) { Fabricate(:account, username: 'bob') }
|
let(:bob) { Fabricate(:account, username: 'bob') }
|
||||||
|
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
RSpec.describe ClearDomainMediaService, type: :service do
|
RSpec.describe ClearDomainMediaService, type: :service do
|
||||||
|
subject { ClearDomainMediaService.new }
|
||||||
|
|
||||||
let!(:bad_account) { Fabricate(:account, username: 'badguy666', domain: 'evil.org') }
|
let!(:bad_account) { Fabricate(:account, username: 'badguy666', domain: 'evil.org') }
|
||||||
let!(:bad_status1) { Fabricate(:status, account: bad_account, text: 'You suck') }
|
let!(:bad_status1) { Fabricate(:status, account: bad_account, text: 'You suck') }
|
||||||
let!(:bad_status2) { Fabricate(:status, account: bad_account, text: 'Hahaha') }
|
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!(: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
|
describe 'for a silence with reject media' do
|
||||||
before do
|
before do
|
||||||
subject.call(DomainBlock.create!(domain: 'evil.org', severity: :silence, reject_media: true))
|
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
|
RSpec.describe DeleteAccountService, type: :service do
|
||||||
shared_examples 'common behavior' do
|
shared_examples 'common behavior' do
|
||||||
|
subject { described_class.new.call(account) }
|
||||||
|
|
||||||
let!(:status) { Fabricate(:status, account: account) }
|
let!(:status) { Fabricate(:status, account: account) }
|
||||||
let!(:mention) { Fabricate(:mention, account: local_follower) }
|
let!(:mention) { Fabricate(:mention, account: local_follower) }
|
||||||
let!(:status_with_mention) { Fabricate(:status, account: account, mentions: [mention]) }
|
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) }
|
let!(:account_note) { Fabricate(:account_note, account: account) }
|
||||||
|
|
||||||
subject { described_class.new.call(account) }
|
|
||||||
|
|
||||||
it 'deletes associated owned records' do
|
it 'deletes associated owned records' do
|
||||||
expect { subject }.to change {
|
expect { subject }.to change {
|
||||||
[
|
[
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
RSpec.describe FanOutOnWriteService, type: :service do
|
RSpec.describe FanOutOnWriteService, type: :service do
|
||||||
|
subject { described_class.new }
|
||||||
|
|
||||||
let(:last_active_at) { Time.now.utc }
|
let(:last_active_at) { Time.now.utc }
|
||||||
let(:status) { Fabricate(:status, account: alice, visibility: visibility, text: 'Hello @bob #hoge') }
|
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!(: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 }
|
let!(:tom) { Fabricate(:user, current_sign_in_at: last_active_at).account }
|
||||||
|
|
||||||
subject { described_class.new }
|
|
||||||
|
|
||||||
before do
|
before do
|
||||||
bob.follow!(alice)
|
bob.follow!(alice)
|
||||||
tom.follow!(alice)
|
tom.follow!(alice)
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
RSpec.describe FavouriteService, type: :service do
|
RSpec.describe FavouriteService, type: :service do
|
||||||
let(:sender) { Fabricate(:account, username: 'alice') }
|
|
||||||
|
|
||||||
subject { FavouriteService.new }
|
subject { FavouriteService.new }
|
||||||
|
|
||||||
|
let(:sender) { Fabricate(:account, username: 'alice') }
|
||||||
|
|
||||||
describe 'local' do
|
describe 'local' do
|
||||||
let(:bob) { Fabricate(:account) }
|
let(:bob) { Fabricate(:account) }
|
||||||
let(:status) { Fabricate(:status, account: bob) }
|
let(:status) { Fabricate(:status, account: bob) }
|
||||||
|
@ -2,10 +2,10 @@ require 'rails_helper'
|
|||||||
|
|
||||||
RSpec.describe FetchResourceService, type: :service do
|
RSpec.describe FetchResourceService, type: :service do
|
||||||
describe '#call' do
|
describe '#call' do
|
||||||
let(:url) { 'http://example.com' }
|
|
||||||
|
|
||||||
subject { described_class.new.call(url) }
|
subject { described_class.new.call(url) }
|
||||||
|
|
||||||
|
let(:url) { 'http://example.com' }
|
||||||
|
|
||||||
context 'with blank url' do
|
context 'with blank url' do
|
||||||
let(:url) { '' }
|
let(:url) { '' }
|
||||||
|
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
RSpec.describe FollowService, type: :service do
|
RSpec.describe FollowService, type: :service do
|
||||||
let(:sender) { Fabricate(:account, username: 'alice') }
|
|
||||||
|
|
||||||
subject { FollowService.new }
|
subject { FollowService.new }
|
||||||
|
|
||||||
|
let(:sender) { Fabricate(:account, username: 'alice') }
|
||||||
|
|
||||||
context 'local account' do
|
context 'local account' do
|
||||||
describe 'locked account' do
|
describe 'locked account' do
|
||||||
let(:bob) { Fabricate(:account, locked: true, username: 'bob') }
|
let(:bob) { Fabricate(:account, locked: true, username: 'bob') }
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
RSpec.describe ProcessMentionsService, type: :service do
|
RSpec.describe ProcessMentionsService, type: :service do
|
||||||
let(:account) { Fabricate(:account, username: 'alice') }
|
|
||||||
|
|
||||||
subject { ProcessMentionsService.new }
|
subject { ProcessMentionsService.new }
|
||||||
|
|
||||||
|
let(:account) { Fabricate(:account, username: 'alice') }
|
||||||
|
|
||||||
context 'when mentions contain blocked accounts' do
|
context 'when mentions contain blocked accounts' do
|
||||||
let(:non_blocked_account) { Fabricate(:account) }
|
let(:non_blocked_account) { Fabricate(:account) }
|
||||||
let(:individually_blocked_account) { Fabricate(:account) }
|
let(:individually_blocked_account) { Fabricate(:account) }
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
RSpec.describe PurgeDomainService, type: :service do
|
RSpec.describe PurgeDomainService, type: :service do
|
||||||
|
subject { PurgeDomainService.new }
|
||||||
|
|
||||||
let!(:old_account) { Fabricate(:account, domain: 'obsolete.org') }
|
let!(:old_account) { Fabricate(:account, domain: 'obsolete.org') }
|
||||||
let!(:old_status1) { Fabricate(:status, account: old_account) }
|
let!(:old_status1) { Fabricate(:status, account: old_account) }
|
||||||
let!(:old_status2) { 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')) }
|
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
|
describe 'for a suspension' do
|
||||||
before do
|
before do
|
||||||
subject.call('obsolete.org')
|
subject.call('obsolete.org')
|
||||||
|
@ -4,12 +4,12 @@ RSpec.describe ReblogService, type: :service do
|
|||||||
let(:alice) { Fabricate(:account, username: 'alice') }
|
let(:alice) { Fabricate(:account, username: 'alice') }
|
||||||
|
|
||||||
context 'creates a reblog with appropriate visibility' do
|
context 'creates a reblog with appropriate visibility' do
|
||||||
|
subject { ReblogService.new }
|
||||||
|
|
||||||
let(:visibility) { :public }
|
let(:visibility) { :public }
|
||||||
let(:reblog_visibility) { :public }
|
let(:reblog_visibility) { :public }
|
||||||
let(:status) { Fabricate(:status, account: alice, visibility: visibility) }
|
let(:status) { Fabricate(:status, account: alice, visibility: visibility) }
|
||||||
|
|
||||||
subject { ReblogService.new }
|
|
||||||
|
|
||||||
before do
|
before do
|
||||||
subject.call(alice, status, visibility: reblog_visibility)
|
subject.call(alice, status, visibility: reblog_visibility)
|
||||||
end
|
end
|
||||||
@ -45,11 +45,11 @@ RSpec.describe ReblogService, type: :service do
|
|||||||
end
|
end
|
||||||
|
|
||||||
context 'ActivityPub' do
|
context 'ActivityPub' do
|
||||||
|
subject { ReblogService.new }
|
||||||
|
|
||||||
let(:bob) { Fabricate(:account, username: 'bob', protocol: :activitypub, domain: 'example.com', inbox_url: 'http://example.com/inbox') }
|
let(:bob) { Fabricate(:account, username: 'bob', protocol: :activitypub, domain: 'example.com', inbox_url: 'http://example.com/inbox') }
|
||||||
let(:status) { Fabricate(:status, account: bob) }
|
let(:status) { Fabricate(:status, account: bob) }
|
||||||
|
|
||||||
subject { ReblogService.new }
|
|
||||||
|
|
||||||
before do
|
before do
|
||||||
stub_request(:post, bob.inbox_url)
|
stub_request(:post, bob.inbox_url)
|
||||||
allow(ActivityPub::DistributionWorker).to receive(:perform_async)
|
allow(ActivityPub::DistributionWorker).to receive(:perform_async)
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
RSpec.describe RejectFollowService, type: :service do
|
RSpec.describe RejectFollowService, type: :service do
|
||||||
let(:sender) { Fabricate(:account, username: 'alice') }
|
|
||||||
|
|
||||||
subject { RejectFollowService.new }
|
subject { RejectFollowService.new }
|
||||||
|
|
||||||
|
let(:sender) { Fabricate(:account, username: 'alice') }
|
||||||
|
|
||||||
describe 'local' do
|
describe 'local' do
|
||||||
let(:bob) { Fabricate(:account) }
|
let(:bob) { Fabricate(:account) }
|
||||||
|
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
RSpec.describe RemoveFromFollowersService, type: :service do
|
RSpec.describe RemoveFromFollowersService, type: :service do
|
||||||
let(:bob) { Fabricate(:account, username: 'bob') }
|
|
||||||
|
|
||||||
subject { RemoveFromFollowersService.new }
|
subject { RemoveFromFollowersService.new }
|
||||||
|
|
||||||
|
let(:bob) { Fabricate(:account, username: 'bob') }
|
||||||
|
|
||||||
describe 'local' do
|
describe 'local' do
|
||||||
let(:sender) { Fabricate(:account, username: 'alice') }
|
let(:sender) { Fabricate(:account, username: 'alice') }
|
||||||
|
|
||||||
|
@ -29,13 +29,13 @@ RSpec.describe ReportService, type: :service do
|
|||||||
end
|
end
|
||||||
|
|
||||||
context 'when the reported status is a DM' do
|
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
|
subject do
|
||||||
-> { described_class.new.call(source_account, target_account, status_ids: [status.id]) }
|
-> { described_class.new.call(source_account, target_account, status_ids: [status.id]) }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
let(:target_account) { Fabricate(:account) }
|
||||||
|
let(:status) { Fabricate(:status, account: target_account, visibility: :direct) }
|
||||||
|
|
||||||
context 'when it is addressed to the reporter' do
|
context 'when it is addressed to the reporter' do
|
||||||
before do
|
before do
|
||||||
status.mentions.create(account: source_account)
|
status.mentions.create(account: source_account)
|
||||||
@ -85,13 +85,13 @@ RSpec.describe ReportService, type: :service do
|
|||||||
end
|
end
|
||||||
|
|
||||||
context 'when other reports already exist for the same target' do
|
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
|
subject do
|
||||||
-> { described_class.new.call(source_account, target_account) }
|
-> { described_class.new.call(source_account, target_account) }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
let!(:target_account) { Fabricate(:account) }
|
||||||
|
let!(:other_report) { Fabricate(:report, target_account: target_account) }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
ActionMailer::Base.deliveries.clear
|
ActionMailer::Base.deliveries.clear
|
||||||
source_account.user.settings.notification_emails['report'] = true
|
source_account.user.settings.notification_emails['report'] = true
|
||||||
|
@ -2,11 +2,11 @@ require 'rails_helper'
|
|||||||
|
|
||||||
RSpec.describe SuspendAccountService, type: :service do
|
RSpec.describe SuspendAccountService, type: :service do
|
||||||
shared_examples 'common behavior' 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!(:local_follower) { Fabricate(:user, current_sign_in_at: 1.hour.ago).account }
|
||||||
let!(:list) { Fabricate(:list, account: local_follower) }
|
let!(:list) { Fabricate(:list, account: local_follower) }
|
||||||
|
|
||||||
subject { described_class.new.call(account) }
|
|
||||||
|
|
||||||
before do
|
before do
|
||||||
allow(FeedManager.instance).to receive(:unmerge_from_home).and_return(nil)
|
allow(FeedManager.instance).to receive(:unmerge_from_home).and_return(nil)
|
||||||
allow(FeedManager.instance).to receive(:unmerge_from_list).and_return(nil)
|
allow(FeedManager.instance).to receive(:unmerge_from_list).and_return(nil)
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
RSpec.describe UnallowDomainService, type: :service do
|
RSpec.describe UnallowDomainService, type: :service do
|
||||||
|
subject { UnallowDomainService.new }
|
||||||
|
|
||||||
let!(:bad_account) { Fabricate(:account, username: 'badguy666', domain: 'evil.org') }
|
let!(:bad_account) { Fabricate(:account, username: 'badguy666', domain: 'evil.org') }
|
||||||
let!(:bad_status1) { Fabricate(:status, account: bad_account, text: 'You suck') }
|
let!(:bad_status1) { Fabricate(:status, account: bad_account, text: 'You suck') }
|
||||||
let!(:bad_status2) { Fabricate(:status, account: bad_account, text: 'Hahaha') }
|
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!(:already_banned_account) { Fabricate(:account, username: 'badguy', domain: 'evil.org', suspended: true, silenced: true) }
|
||||||
let!(:domain_allow) { Fabricate(:domain_allow, domain: 'evil.org') }
|
let!(:domain_allow) { Fabricate(:domain_allow, domain: 'evil.org') }
|
||||||
|
|
||||||
subject { UnallowDomainService.new }
|
|
||||||
|
|
||||||
context 'in limited federation mode' do
|
context 'in limited federation mode' do
|
||||||
before do
|
before do
|
||||||
allow(subject).to receive(:whitelist_mode?).and_return(true)
|
allow(subject).to receive(:whitelist_mode?).and_return(true)
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
RSpec.describe UnblockService, type: :service do
|
RSpec.describe UnblockService, type: :service do
|
||||||
let(:sender) { Fabricate(:account, username: 'alice') }
|
|
||||||
|
|
||||||
subject { UnblockService.new }
|
subject { UnblockService.new }
|
||||||
|
|
||||||
|
let(:sender) { Fabricate(:account, username: 'alice') }
|
||||||
|
|
||||||
describe 'local' do
|
describe 'local' do
|
||||||
let(:bob) { Fabricate(:account) }
|
let(:bob) { Fabricate(:account) }
|
||||||
|
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
RSpec.describe UnfollowService, type: :service do
|
RSpec.describe UnfollowService, type: :service do
|
||||||
let(:sender) { Fabricate(:account, username: 'alice') }
|
|
||||||
|
|
||||||
subject { UnfollowService.new }
|
subject { UnfollowService.new }
|
||||||
|
|
||||||
|
let(:sender) { Fabricate(:account, username: 'alice') }
|
||||||
|
|
||||||
describe 'local' do
|
describe 'local' do
|
||||||
let(:bob) { Fabricate(:account, username: 'bob') }
|
let(:bob) { Fabricate(:account, username: 'bob') }
|
||||||
|
|
||||||
|
@ -2,11 +2,11 @@ require 'rails_helper'
|
|||||||
|
|
||||||
RSpec.describe UnsuspendAccountService, type: :service do
|
RSpec.describe UnsuspendAccountService, type: :service do
|
||||||
shared_examples 'common behavior' 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!(:local_follower) { Fabricate(:user, current_sign_in_at: 1.hour.ago).account }
|
||||||
let!(:list) { Fabricate(:list, account: local_follower) }
|
let!(:list) { Fabricate(:list, account: local_follower) }
|
||||||
|
|
||||||
subject { described_class.new.call(account) }
|
|
||||||
|
|
||||||
before do
|
before do
|
||||||
allow(FeedManager.instance).to receive(:merge_into_home).and_return(nil)
|
allow(FeedManager.instance).to receive(:merge_into_home).and_return(nil)
|
||||||
allow(FeedManager.instance).to receive(:merge_into_list).and_return(nil)
|
allow(FeedManager.instance).to receive(:merge_into_list).and_return(nil)
|
||||||
|
@ -4,6 +4,8 @@ require 'rails_helper'
|
|||||||
|
|
||||||
RSpec.describe BlacklistedEmailValidator, type: :validator do
|
RSpec.describe BlacklistedEmailValidator, type: :validator do
|
||||||
describe '#validate' do
|
describe '#validate' do
|
||||||
|
subject { described_class.new.validate(user); errors }
|
||||||
|
|
||||||
let(:user) { double(email: 'info@mail.com', sign_up_ip: '1.2.3.4', errors: errors) }
|
let(:user) { double(email: 'info@mail.com', sign_up_ip: '1.2.3.4', errors: errors) }
|
||||||
let(:errors) { double(add: nil) }
|
let(:errors) { double(add: nil) }
|
||||||
|
|
||||||
@ -12,8 +14,6 @@ RSpec.describe BlacklistedEmailValidator, type: :validator do
|
|||||||
allow_any_instance_of(described_class).to receive(:blocked_email_provider?) { blocked_email }
|
allow_any_instance_of(described_class).to receive(:blocked_email_provider?) { blocked_email }
|
||||||
end
|
end
|
||||||
|
|
||||||
subject { described_class.new.validate(user); errors }
|
|
||||||
|
|
||||||
context 'when e-mail provider is blocked' do
|
context 'when e-mail provider is blocked' do
|
||||||
let(:blocked_email) { true }
|
let(:blocked_email) { true }
|
||||||
|
|
||||||
|
@ -3,6 +3,8 @@
|
|||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
describe MoveWorker do
|
describe MoveWorker do
|
||||||
|
subject { described_class.new }
|
||||||
|
|
||||||
let(:local_follower) { Fabricate(:account) }
|
let(:local_follower) { Fabricate(:account) }
|
||||||
let(:blocking_account) { Fabricate(:account) }
|
let(:blocking_account) { Fabricate(:account) }
|
||||||
let(:muting_account) { Fabricate(:account) }
|
let(:muting_account) { Fabricate(:account) }
|
||||||
@ -14,8 +16,6 @@ describe MoveWorker do
|
|||||||
|
|
||||||
let(:block_service) { double }
|
let(:block_service) { double }
|
||||||
|
|
||||||
subject { described_class.new }
|
|
||||||
|
|
||||||
before do
|
before do
|
||||||
local_follower.follow!(source_account)
|
local_follower.follow!(source_account)
|
||||||
blocking_account.block!(source_account)
|
blocking_account.block!(source_account)
|
||||||
|
@ -3,13 +3,13 @@
|
|||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
describe UnfollowFollowWorker do
|
describe UnfollowFollowWorker do
|
||||||
|
subject { described_class.new }
|
||||||
|
|
||||||
let(:local_follower) { Fabricate(:account) }
|
let(:local_follower) { Fabricate(:account) }
|
||||||
let(:source_account) { Fabricate(:account) }
|
let(:source_account) { Fabricate(:account) }
|
||||||
let(:target_account) { Fabricate(:account) }
|
let(:target_account) { Fabricate(:account) }
|
||||||
let(:show_reblogs) { true }
|
let(:show_reblogs) { true }
|
||||||
|
|
||||||
subject { described_class.new }
|
|
||||||
|
|
||||||
before do
|
before do
|
||||||
local_follower.follow!(source_account, reblogs: show_reblogs)
|
local_follower.follow!(source_account, reblogs: show_reblogs)
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user