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

This commit is contained in:
KMY 2025-01-17 16:29:11 +09:00
commit 5d79bd078c
150 changed files with 2982 additions and 1485 deletions

View file

@ -53,8 +53,9 @@ RSpec.describe 'Accounts show response' do
it 'returns a standard HTML response', :aggregate_failures do
expect(response)
.to have_http_status(200)
.and render_template(:show)
.and have_http_link_header(ActivityPub::TagManager.instance.uri_for(account)).for(rel: 'alternate')
expect(response.parsed_body.at('title').content)
.to include(account.username)
end
end

View file

@ -258,6 +258,19 @@ RSpec.describe 'Domain Blocks' do
.to start_with('application/json')
end
end
context 'when severity is invalid' do
let(:params) { { domain: 'bar.com', severity: :bar } }
it 'returns http unprocessable entity' do
subject
expect(response).to have_http_status(422)
expect(response.content_type)
.to start_with('application/json')
expect(response.parsed_body[:error]).to eq('Validation failed: Severity is not included in the list')
end
end
end
describe 'PUT /api/v1/admin/domain_blocks/:id' do

View file

@ -187,6 +187,16 @@ RSpec.describe 'IP Blocks' do
.to start_with('application/json')
end
end
context 'when the given severity is invalid' do
let(:params) { { ip: '151.0.32.55', severity: 'invalid' } }
it 'returns http unprocessable entity' do
subject
expect(response).to have_http_status(422)
end
end
end
describe 'PUT /api/v1/admin/ip_blocks/:id' do

View file

@ -9,10 +9,21 @@ RSpec.describe 'Languages' do
end
it 'returns http success and includes supported languages' do
expect(response).to have_http_status(200)
expect(response)
.to have_http_status(200)
expect(response.content_type)
.to start_with('application/json')
expect(response.parsed_body.pluck(:code)).to match_array LanguagesHelper::SUPPORTED_LOCALES.keys.map(&:to_s)
expect(response.parsed_body)
.to match_array(supported_locale_expectations)
end
def supported_locale_expectations
LanguagesHelper::SUPPORTED_LOCALES.map do |key, values|
include(
code: key.to_s,
name: values.first
)
end
end
end
end

View file

@ -36,6 +36,31 @@ RSpec.describe 'Polls' do
end
end
context 'when poll is remote and needs refresh' do
let(:poll) { Fabricate(:poll, last_fetched_at: nil, account: remote_account, status: status) }
let(:remote_account) { Fabricate :account, domain: 'host.example' }
let(:service) { instance_double(ActivityPub::FetchRemotePollService, call: nil) }
let(:status) { Fabricate(:status, visibility: 'public', account: remote_account) }
before { allow(ActivityPub::FetchRemotePollService).to receive(:new).and_return(service) }
it 'returns poll data and calls fetch remote service' do
subject
expect(response)
.to have_http_status(200)
expect(response.content_type)
.to start_with('application/json')
expect(response.parsed_body).to match(
a_hash_including(
id: poll.id.to_s
)
)
expect(service)
.to have_received(:call).with(poll, user.account)
end
end
context 'when parent status is private' do
let(:visibility) { 'private' }

View file

@ -143,6 +143,55 @@ RSpec.describe 'Notifications' do
end
end
context 'when there are numerous notifications for the same final group' do
before do
user.account.notifications.destroy_all
5.times.each { FavouriteService.new.call(Fabricate(:account), user.account.statuses.first) }
end
context 'with no options' do
it 'returns a notification group covering all notifications' do
subject
notification_ids = user.account.notifications.reload.pluck(:id)
expect(response).to have_http_status(200)
expect(response.content_type)
.to start_with('application/json')
expect(response.parsed_body[:notification_groups]).to contain_exactly(
a_hash_including(
type: 'favourite',
sample_account_ids: have_attributes(size: 5),
page_min_id: notification_ids.first.to_s,
page_max_id: notification_ids.last.to_s
)
)
end
end
context 'with min_id param' do
let(:params) { { min_id: user.account.notifications.reload.first.id - 1 } }
it 'returns a notification group covering all notifications' do
subject
notification_ids = user.account.notifications.reload.pluck(:id)
expect(response).to have_http_status(200)
expect(response.content_type)
.to start_with('application/json')
expect(response.parsed_body[:notification_groups]).to contain_exactly(
a_hash_including(
type: 'favourite',
sample_account_ids: have_attributes(size: 5),
page_min_id: notification_ids.first.to_s,
page_max_id: notification_ids.last.to_s
)
)
end
end
end
context 'with no options' do
it 'returns expected notification types', :aggregate_failures do
subject

View file

@ -0,0 +1,27 @@
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe 'Auth Setup' do
describe 'GET /auth/setup' do
context 'with a signed out request' do
it 'redirects to root' do
get '/auth/setup'
expect(response)
.to redirect_to(new_user_session_url)
end
end
context 'with a confirmed signed in user' do
before { sign_in Fabricate(:user, confirmed_at: 2.days.ago) }
it 'redirects to root' do
get '/auth/setup'
expect(response)
.to redirect_to(root_url)
end
end
end
end

View file

@ -9,7 +9,6 @@ RSpec.describe 'Remote Interaction Helper' do
expect(response)
.to have_http_status(200)
.and render_template(:index, layout: 'helper_frame')
.and have_attributes(
headers: include(
'X-Frame-Options' => 'SAMEORIGIN',
@ -17,6 +16,8 @@ RSpec.describe 'Remote Interaction Helper' do
'Content-Security-Policy' => expected_csp_headers
)
)
expect(response.body)
.to match(/remote_interaction_helper/)
end
end