discourse/spec/requests/api/site_spec.rb
Daniel Waterworth 6e161d3e75
DEV: Allow fab! without block (#24314)
The most common thing that we do with fab! is:

    fab!(:thing) { Fabricate(:thing) }

This commit adds a shorthand for this which is just simply:

    fab!(:thing)

i.e. If you omit the block, then, by default, you'll get a `Fabricate`d object using the fabricator of the same name.
2023-11-09 16:47:59 -06:00

41 lines
1.1 KiB
Ruby

# frozen_string_literal: true
require "swagger_helper"
RSpec.describe "site" do
fab!(:admin)
fab!(:category)
fab!(:subcategory) { Fabricate(:category, parent_category: category) }
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
begin
Site.preloaded_category_custom_fields << "no_oddjob"
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.reset_preloaded_category_custom_fields
end
end
end
end
end