DEV: Fix missing optional site.json fields (#17364)

The site.json endpoint was missing some optional fields on the
categories property that is returned. This commit documents the
`parent_category_id` which is present if there are subcategories and it
also documents the `custom_fields` property which the chat plugin is
using causing some flaky tests.
This commit is contained in:
Blake Erickson 2022-07-07 20:04:50 -05:00 committed by GitHub
parent d9eab4bbbb
commit 59d514df34
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 6 deletions

View File

@ -634,6 +634,16 @@
},
"can_edit": {
"type": "boolean"
},
"custom_fields": {
"type": [
"object",
"null"
],
"additionalProperties": true
},
"parent_category_id": {
"type": "integer"
}
},
"required": [

View File

@ -3,7 +3,9 @@ require 'swagger_helper'
describe 'site' do
let(:admin) { Fabricate(:admin) }
fab!(:admin) { Fabricate(:admin) }
fab!(:category) { Fabricate(:category) }
fab!(:subcategory) { Fabricate(:category, parent_category: category) }
before do
Jobs.run_immediately!
@ -21,12 +23,18 @@ describe 'site' do
produces 'application/json'
response '200', 'success response' do
expected_response_schema = load_spec_schema('site_response')
schema expected_response_schema
begin
Site.preloaded_category_custom_fields << "no_oddjob"
it_behaves_like "a JSON endpoint", 200 do
let(:expected_response_schema) { expected_response_schema }
let(:expected_request_schema) { expected_request_schema }
expected_response_schema = load_spec_schema('site_response')
schema expected_response_schema
it_behaves_like "a JSON endpoint", 200 do
let(:expected_response_schema) { expected_response_schema }
let(:expected_request_schema) { expected_request_schema }
end
ensure
Site.preloaded_category_custom_fields = Set.new
end
end
end