Merge remote-tracking branch 'parent/main' into upstream-20240906

This commit is contained in:
KMY 2024-09-09 08:47:15 +09:00
commit 218cb37fe3
176 changed files with 750 additions and 603 deletions

View file

@ -31,7 +31,7 @@ RSpec.describe ActivityPub::CollectionsController do
.and have_cacheable_headers
expect(response.media_type).to eq 'application/activity+json'
expect(body_as_json[:orderedItems])
expect(response.parsed_body[:orderedItems])
.to be_an(Array)
.and have_attributes(size: 3)
.and include(ActivityPub::TagManager.instance.uri_for(private_pinned))
@ -71,7 +71,7 @@ RSpec.describe ActivityPub::CollectionsController do
expect(response.media_type).to eq 'application/activity+json'
expect(body_as_json[:orderedItems])
expect(response.parsed_body[:orderedItems])
.to be_an(Array)
.and have_attributes(size: 3)
.and include(ActivityPub::TagManager.instance.uri_for(private_pinned))
@ -94,7 +94,7 @@ RSpec.describe ActivityPub::CollectionsController do
expect(response.media_type).to eq 'application/activity+json'
expect(response.headers['Cache-Control']).to include 'private'
expect(body_as_json[:orderedItems])
expect(response.parsed_body[:orderedItems])
.to be_an(Array)
.and be_empty
end
@ -110,7 +110,7 @@ RSpec.describe ActivityPub::CollectionsController do
expect(response.media_type).to eq 'application/activity+json'
expect(response.headers['Cache-Control']).to include 'private'
expect(body_as_json[:orderedItems])
expect(response.parsed_body[:orderedItems])
.to be_an(Array)
.and be_empty
end

View file

@ -34,7 +34,6 @@ RSpec.describe ActivityPub::FollowersSynchronizationsController do
context 'with signature from example.com' do
subject(:response) { get :show, params: { account_username: account.username } }
let(:body) { body_as_json }
let(:remote_account) { Fabricate(:account, domain: 'example.com', uri: 'https://example.com/instance') }
it 'returns http success and cache control and activity json types and correct items' do
@ -42,7 +41,7 @@ RSpec.describe ActivityPub::FollowersSynchronizationsController do
expect(response.headers['Cache-Control']).to eq 'max-age=0, private'
expect(response.media_type).to eq 'application/activity+json'
expect(body[:orderedItems])
expect(response.parsed_body[:orderedItems])
.to be_an(Array)
.and contain_exactly(
follower_example_com_instance_actor.uri,

View file

@ -19,7 +19,6 @@ RSpec.describe ActivityPub::OutboxesController do
context 'without signature' do
subject(:response) { get :show, params: { account_username: account.username, page: page } }
let(:body) { body_as_json }
let(:remote_account) { nil }
context 'with page not requested' do
@ -32,7 +31,7 @@ RSpec.describe ActivityPub::OutboxesController do
expect(response.media_type).to eq 'application/activity+json'
expect(response.headers['Vary']).to be_nil
expect(body[:totalItems]).to eq 4
expect(response.parsed_body[:totalItems]).to eq 4
end
context 'when account is permanently suspended' do
@ -68,9 +67,11 @@ RSpec.describe ActivityPub::OutboxesController do
expect(response.media_type).to eq 'application/activity+json'
expect(response.headers['Vary']).to include 'Signature'
expect(body[:orderedItems]).to be_an Array
expect(body[:orderedItems].size).to eq 2
expect(body[:orderedItems].all? { |item| targets_public_collection?(item) }).to be true
expect(response.parsed_body)
.to include(
orderedItems: be_an(Array).and(have_attributes(size: 2))
)
expect(response.parsed_body[:orderedItems].all? { |item| targets_public_collection?(item) }).to be true
end
context 'when account is permanently suspended' do
@ -110,9 +111,11 @@ RSpec.describe ActivityPub::OutboxesController do
expect(response.media_type).to eq 'application/activity+json'
expect(response.headers['Cache-Control']).to eq 'max-age=60, private'
expect(body_as_json[:orderedItems]).to be_an Array
expect(body_as_json[:orderedItems].size).to eq 2
expect(body_as_json[:orderedItems].all? { |item| targets_public_collection?(item) }).to be true
expect(response.parsed_body)
.to include(
orderedItems: be_an(Array).and(have_attributes(size: 2))
)
expect(response.parsed_body[:orderedItems].all? { |item| targets_public_collection?(item) }).to be true
end
end
@ -127,9 +130,11 @@ RSpec.describe ActivityPub::OutboxesController do
expect(response.media_type).to eq 'application/activity+json'
expect(response.headers['Cache-Control']).to eq 'max-age=60, private'
expect(body_as_json[:orderedItems]).to be_an Array
expect(body_as_json[:orderedItems].size).to eq 3
expect(body_as_json[:orderedItems].all? { |item| targets_public_collection?(item) || targets_followers_collection?(item, account) }).to be true
expect(response.parsed_body)
.to include(
orderedItems: be_an(Array).and(have_attributes(size: 3))
)
expect(response.parsed_body[:orderedItems].all? { |item| targets_public_collection?(item) || targets_followers_collection?(item, account) }).to be true
end
end
@ -144,9 +149,10 @@ RSpec.describe ActivityPub::OutboxesController do
expect(response.media_type).to eq 'application/activity+json'
expect(response.headers['Cache-Control']).to eq 'max-age=60, private'
expect(body_as_json[:orderedItems])
.to be_an(Array)
.and be_empty
expect(response.parsed_body)
.to include(
orderedItems: be_an(Array).and(be_empty)
)
end
end
@ -161,9 +167,10 @@ RSpec.describe ActivityPub::OutboxesController do
expect(response.media_type).to eq 'application/activity+json'
expect(response.headers['Cache-Control']).to eq 'max-age=60, private'
expect(body_as_json[:orderedItems])
.to be_an(Array)
.and be_empty
expect(response.parsed_body)
.to include(
orderedItems: be_an(Array).and(be_empty)
)
end
end
end

View file

@ -66,7 +66,7 @@ RSpec.describe ActivityPub::RepliesController do
context 'when status is public' do
let(:parent_visibility) { :public }
let(:page_json) { body_as_json[:first] }
let(:page_json) { response.parsed_body[:first] }
it 'returns http success and correct media type' do
expect(response)

View file

@ -55,6 +55,23 @@ RSpec.describe Admin::AccountsController do
describe 'GET #show' do
let(:current_user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
describe 'account moderation notes' do
let(:account) { Fabricate(:account) }
it 'includes moderation notes' do
note1 = Fabricate(:account_moderation_note, target_account: account)
note2 = Fabricate(:account_moderation_note, target_account: account)
get :show, params: { id: account.id }
expect(response).to have_http_status(200)
moderation_notes = assigns(:moderation_notes).to_a
expect(moderation_notes.size).to be 2
expect(moderation_notes).to eq [note1, note2]
end
end
context 'with a remote account' do
let(:account) { Fabricate(:account, domain: 'example.com') }

View file

@ -47,6 +47,24 @@ RSpec.describe Admin::ReportsController do
expect(response.body)
.to include(report.comment)
end
describe 'account moderation notes' do
let(:report) { Fabricate(:report) }
it 'includes moderation notes' do
note1 = Fabricate(:report_note, report: report)
note2 = Fabricate(:report_note, report: report)
get :show, params: { id: report }
expect(response).to have_http_status(200)
report_notes = assigns(:report_notes).to_a
expect(report_notes.size).to be 2
expect(report_notes).to eq [note1, note2]
end
end
end
describe 'POST #resolve' do

View file

@ -441,7 +441,7 @@ RSpec.describe Auth::SessionsController do
end
it 'instructs the browser to redirect to home, logs the user in, and updates the sign count' do
expect(body_as_json[:redirect_path]).to eq(root_path)
expect(response.parsed_body[:redirect_path]).to eq(root_path)
expect(controller.current_user).to eq user

View file

@ -39,8 +39,6 @@ RSpec.describe FollowerAccountsController do
end
context 'when format is json' do
subject(:body) { response.parsed_body }
let(:response) { get :index, params: { account_username: alice.username, page: page, format: :json } }
context 'with page' do
@ -48,15 +46,15 @@ RSpec.describe FollowerAccountsController do
it 'returns followers' do
expect(response).to have_http_status(200)
expect(body_as_json)
expect(response.parsed_body)
.to include(
orderedItems: contain_exactly(
include(follow_from_bob.account.username),
include(follow_from_chris.account.username)
)
),
totalItems: eq(2),
partOf: be_present
)
expect(body['totalItems']).to eq 2
expect(body['partOf']).to be_present
end
context 'when account is permanently suspended' do
@ -86,8 +84,11 @@ RSpec.describe FollowerAccountsController do
it 'returns followers' do
expect(response).to have_http_status(200)
expect(body['totalItems']).to eq 2
expect(body['partOf']).to be_blank
expect(response.parsed_body)
.to include(
totalItems: eq(2)
)
.and not_include(:partOf)
end
context 'when account hides their network' do
@ -95,15 +96,17 @@ RSpec.describe FollowerAccountsController do
alice.update(hide_collections: true)
end
it 'returns followers count' do
expect(body['totalItems']).to eq 2
end
it 'does not return items' do
expect(body['items']).to be_blank
expect(body['orderedItems']).to be_blank
expect(body['first']).to be_blank
expect(body['last']).to be_blank
it 'returns followers count but not any items' do
expect(response.parsed_body)
.to include(
totalItems: eq(2)
)
.and not_include(
:items,
:orderedItems,
:first,
:last
)
end
end

View file

@ -39,8 +39,6 @@ RSpec.describe FollowingAccountsController do
end
context 'when format is json' do
subject(:body) { response.parsed_body }
let(:response) { get :index, params: { account_username: alice.username, page: page, format: :json } }
context 'with page' do
@ -48,15 +46,15 @@ RSpec.describe FollowingAccountsController do
it 'returns followers' do
expect(response).to have_http_status(200)
expect(body_as_json)
expect(response.parsed_body)
.to include(
orderedItems: contain_exactly(
include(follow_of_bob.target_account.username),
include(follow_of_chris.target_account.username)
)
),
totalItems: eq(2),
partOf: be_present
)
expect(body['totalItems']).to eq 2
expect(body['partOf']).to be_present
end
context 'when account is permanently suspended' do
@ -86,8 +84,11 @@ RSpec.describe FollowingAccountsController do
it 'returns followers' do
expect(response).to have_http_status(200)
expect(body['totalItems']).to eq 2
expect(body['partOf']).to be_blank
expect(response.parsed_body)
.to include(
totalItems: eq(2)
)
.and not_include(:partOf)
end
context 'when account hides their network' do
@ -95,15 +96,17 @@ RSpec.describe FollowingAccountsController do
alice.update(hide_collections: true)
end
it 'returns followers count' do
expect(body['totalItems']).to eq 2
end
it 'does not return items' do
expect(body['items']).to be_blank
expect(body['orderedItems']).to be_blank
expect(body['first']).to be_blank
expect(body['last']).to be_blank
it 'returns followers count but not any items' do
expect(response.parsed_body)
.to include(
totalItems: eq(2)
)
.and not_include(
:items,
:orderedItems,
:first,
:last
)
end
end

View file

@ -81,7 +81,7 @@ RSpec.describe StatusesController do
'Content-Type' => include('application/activity+json'),
'Link' => satisfy { |header| header.to_s.include?('activity+json') }
)
expect(body_as_json)
expect(response.parsed_body)
.to include(content: include(status.text))
end
end
@ -186,7 +186,7 @@ RSpec.describe StatusesController do
'Content-Type' => include('application/activity+json'),
'Link' => satisfy { |header| header.to_s.include?('activity+json') }
)
expect(body_as_json)
expect(response.parsed_body)
.to include(content: include(status.text))
end
end
@ -230,7 +230,7 @@ RSpec.describe StatusesController do
'Content-Type' => include('application/activity+json'),
'Link' => satisfy { |header| header.to_s.include?('activity+json') }
)
expect(body_as_json)
expect(response.parsed_body)
.to include(content: include(status.text))
end
end
@ -296,7 +296,7 @@ RSpec.describe StatusesController do
'Content-Type' => include('application/activity+json'),
'Link' => satisfy { |header| header.to_s.include?('activity+json') }
)
expect(body_as_json)
expect(response.parsed_body)
.to include(content: include(status.text))
end
end
@ -387,7 +387,7 @@ RSpec.describe StatusesController do
'Content-Type' => include('application/activity+json'),
'Link' => satisfy { |header| header.to_s.include?('activity+json') }
)
expect(body_as_json)
expect(response.parsed_body)
.to include(content: include(status.text))
end
end
@ -431,7 +431,7 @@ RSpec.describe StatusesController do
'Link' => satisfy { |header| header.to_s.include?('activity+json') }
)
expect(body_as_json)
expect(response.parsed_body)
.to include(content: include(status.text))
end
end
@ -497,7 +497,7 @@ RSpec.describe StatusesController do
'Content-Type' => include('application/activity+json'),
'Link' => satisfy { |header| header.to_s.include?('activity+json') }
)
expect(body_as_json)
expect(response.parsed_body)
.to include(content: include(status.text))
end
end