Skip to content

Commit

Permalink
Add max_pinned_statuses to instances serializer and api response
Browse files Browse the repository at this point in the history
  • Loading branch information
mjankowski committed Mar 12, 2024
1 parent d4ed7e4 commit b061169
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/serializers/rest/instance_serializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ def configuration

accounts: {
max_featured_tags: FeaturedTag::LIMIT,
max_pinned_statuses: StatusPinValidator::PIN_LIMIT,
},

statuses: {
Expand Down
20 changes: 20 additions & 0 deletions spec/requests/api/v2/instance_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
expect(body_as_json)
.to be_present
.and include(title: 'Mastodon')
.and include_configuration_limits
end
end

Expand All @@ -31,7 +32,26 @@
expect(body_as_json)
.to be_present
.and include(title: 'Mastodon')
.and include_configuration_limits
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
11 changes: 11 additions & 0 deletions spec/serializers/rest/instance_serializer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,22 @@
it 'returns recent usage data' do
expect(serialization['usage']).to eq({ 'users' => { 'active_month' => 0 } })
end
end

describe 'configuration' do
it 'returns the VAPID public key' do
expect(serialization['configuration']['vapid']).to eq({
'public_key' => Rails.configuration.x.vapid_public_key,
})
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

0 comments on commit b061169

Please sign in to comment.