Add `max_pinned_statuses` to instances serializer and api response (#29441)

This commit is contained in:
Matt Jankowski 2024-04-02 09:54:11 -04:00 committed by GitHub
parent f56309f5f0
commit 34489591ec
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 32 additions and 0 deletions

View File

@ -54,6 +54,7 @@ class REST::InstanceSerializer < ActiveModel::Serializer
accounts: { accounts: {
max_featured_tags: FeaturedTag::LIMIT, max_featured_tags: FeaturedTag::LIMIT,
max_pinned_statuses: StatusPinValidator::PIN_LIMIT,
}, },
statuses: { statuses: {

View File

@ -18,6 +18,7 @@ describe 'Instances' do
expect(body_as_json) expect(body_as_json)
.to be_present .to be_present
.and include(title: 'Mastodon') .and include(title: 'Mastodon')
.and include_configuration_limits
end end
end end
@ -31,7 +32,26 @@ describe 'Instances' do
expect(body_as_json) expect(body_as_json)
.to be_present .to be_present
.and include(title: 'Mastodon') .and include(title: 'Mastodon')
.and include_configuration_limits
end end
end end
def include_configuration_limits
include(
configuration: include(
accounts: include(
max_featured_tags: FeaturedTag::LIMIT,
max_pinned_statuses: StatusPinValidator::PIN_LIMIT
),
statuses: include(
max_characters: StatusLengthValidator::MAX_CHARS,
max_media_attachments: 4 # TODO, move to constant somewhere
),
polls: include(
max_options: PollValidator::MAX_OPTIONS
)
)
)
end
end end
end end

View File

@ -10,11 +10,22 @@ describe REST::InstanceSerializer do
it 'returns recent usage data' do it 'returns recent usage data' do
expect(serialization['usage']).to eq({ 'users' => { 'active_month' => 0 } }) expect(serialization['usage']).to eq({ 'users' => { 'active_month' => 0 } })
end end
end
describe 'configuration' do
it 'returns the VAPID public key' do it 'returns the VAPID public key' do
expect(serialization['configuration']['vapid']).to eq({ expect(serialization['configuration']['vapid']).to eq({
'public_key' => Rails.configuration.x.vapid_public_key, 'public_key' => Rails.configuration.x.vapid_public_key,
}) })
end end
it 'returns the max pinned statuses limit' do
expect(serialization.deep_symbolize_keys)
.to include(
configuration: include(
accounts: include(max_pinned_statuses: StatusPinValidator::PIN_LIMIT)
)
)
end
end end
end end