Skip to content

A platform for community discussion. Free, open, simple.

DEV: Update api-docs for posts locked endpoint (#35453)

Blake Erickson57bec16515d3
diff --git a/spec/requests/api/posts_spec.rb b/spec/requests/api/posts_spec.rb
index 16fad584e05..093c9de9c26 100644
--- a/spec/requests/api/posts_spec.rb
+++ b/spec/requests/api/posts_spec.rb
@@ -219,28 +219,20 @@ RSpec.describe "posts" do
parameter name: "Api-Username", in: :header, type: :string, required: true
parameter name: :id, in: :path, schema: { type: :string }
- parameter name: :post_body,
- in: :body,
- schema: {
- type: :object,
- properties: {
- locked: {
- type: :string,
- },
- },
- required: ["locked"],
- }
+ expected_request_schema = load_spec_schema("post_lock_request")
+ parameter name: :params, in: :body, schema: expected_request_schema
produces "application/json"
response "200", "post updated" do
- schema type: :object, properties: { locked: { type: :boolean } }
+ expected_response_schema = load_spec_schema("post_lock_response")
+ schema expected_response_schema
- let(:post_body) { { locked: "true" } }
+ let(:params) { { locked: "true" } }
let(:id) { Fabricate(:post).id }
- run_test! do |response|
- data = JSON.parse(response.body)
- expect(data["locked"]).to eq(true)
+ 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
diff --git a/spec/requests/api/schemas/json/post_lock_request.json b/spec/requests/api/schemas/json/post_lock_request.json
new file mode 100644
index 00000000000..a172293f4fd
--- /dev/null
+++ b/spec/requests/api/schemas/json/post_lock_request.json
@@ -0,0 +1,12 @@
+{
+ "type": "object",
+ "properties": {
+ "locked": {
+ "type": "string",
+ "description": "Whether to lock the post (true/false)"
+ }
+ },
+ "required": [
+ "locked"
+ ]
+}
\ No newline at end of file
diff --git a/spec/requests/api/schemas/json/post_lock_response.json b/spec/requests/api/schemas/json/post_lock_response.json
new file mode 100644
index 00000000000..d8172b26614
--- /dev/null
+++ b/spec/requests/api/schemas/json/post_lock_response.json
@@ -0,0 +1,12 @@
+{
+ "type": "object",
+ "properties": {
+ "locked": {
+ "type": "boolean",
+ "description": "Whether the post is locked"
+ }
+ },
+ "required": [
+ "locked"
+ ]
+}
\ No newline at end of file