2021-09-08 00:36:05 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
require "swagger_helper"
|
|
|
|
|
2022-07-28 10:27:38 +08:00
|
|
|
RSpec.describe "site" do
|
2023-11-10 06:47:59 +08:00
|
|
|
fab!(:admin)
|
|
|
|
fab!(:category)
|
2022-07-08 09:04:50 +08:00
|
|
|
fab!(:subcategory) { Fabricate(:category, parent_category: category) }
|
2021-09-08 00:36:05 +08:00
|
|
|
|
|
|
|
before do
|
|
|
|
Jobs.run_immediately!
|
|
|
|
sign_in(admin)
|
|
|
|
end
|
|
|
|
|
|
|
|
path "/site.json" do
|
|
|
|
get "Get site info" do
|
|
|
|
tags "Site", "Categories"
|
|
|
|
operationId "getSite"
|
|
|
|
description "Can be used to fetch all categories and subcategories"
|
|
|
|
consumes "application/json"
|
|
|
|
expected_request_schema = nil
|
|
|
|
|
|
|
|
produces "application/json"
|
|
|
|
response "200", "success response" do
|
2022-07-08 09:04:50 +08:00
|
|
|
begin
|
|
|
|
Site.preloaded_category_custom_fields << "no_oddjob"
|
2021-09-08 00:36:05 +08:00
|
|
|
|
2022-07-08 09:04:50 +08:00
|
|
|
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
|
2022-07-14 08:54:31 +08:00
|
|
|
Site.reset_preloaded_category_custom_fields
|
2021-09-08 00:36:05 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2024-04-03 04:53:19 +08:00
|
|
|
|
|
|
|
path "/site/basic-info.json" do
|
|
|
|
get "Get site basic info" do
|
|
|
|
tags "Site"
|
|
|
|
operationId "getSiteBasicInfo"
|
|
|
|
description "Can be used to fetch basic info about a site"
|
|
|
|
consumes "application/json"
|
|
|
|
expected_request_schema = nil
|
|
|
|
|
|
|
|
produces "application/json"
|
|
|
|
response "200", "success response" do
|
|
|
|
expected_response_schema = load_spec_schema("site_basic_info_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
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2021-09-08 00:36:05 +08:00
|
|
|
end
|