From e92a82aa1d16e24a9447930d0d3441716b40efaa Mon Sep 17 00:00:00 2001 From: Dylan Yang Date: Wed, 26 Jun 2024 19:44:39 -0700 Subject: [PATCH] FIX: update id types in API docs to integers (#27412) --- spec/requests/api/posts_spec.rb | 29 +++++++++++++++++-- spec/requests/api/private_messages_spec.rb | 6 ++-- .../api/schemas/json/admin_user_response.json | 4 +-- .../json/category_topics_response.json | 2 +- .../schemas/json/post_replies_response.json | 6 ++-- .../api/schemas/json/post_show_response.json | 4 +-- .../schemas/json/post_update_response.json | 4 +-- .../schemas/json/topic_create_response.json | 4 +-- .../api/schemas/json/topic_show_response.json | 2 +- .../api/schemas/json/user_get_response.json | 6 ++-- spec/requests/api/tags_spec.rb | 2 +- spec/requests/api/topics_spec.rb | 6 ++-- spec/requests/api/users_spec.rb | 12 ++++++++ 13 files changed, 61 insertions(+), 26 deletions(-) diff --git a/spec/requests/api/posts_spec.rb b/spec/requests/api/posts_spec.rb index e2041e8c3bd..51e4a672a69 100644 --- a/spec/requests/api/posts_spec.rb +++ b/spec/requests/api/posts_spec.rb @@ -117,7 +117,7 @@ RSpec.describe "posts" do type: %i[string null], }, flair_group_id: { - type: %i[string null], + type: %i[integer null], }, version: { type: :integer, @@ -191,7 +191,7 @@ RSpec.describe "posts" do type: :boolean, }, reviewable_id: { - type: %i[string null], + type: %i[integer null], }, reviewable_score_count: { type: :integer, @@ -261,6 +261,29 @@ RSpec.describe "posts" do let(:expected_request_schema) { expected_request_schema } end end + + response "200", "single reviewable post" do + expected_response_schema = load_spec_schema("post_show_response") + schema expected_response_schema + + let(:id) do + topic = Fabricate(:topic) + post = Fabricate(:post, topic: topic) + Fabricate(:reviewable_flagged_post, topic: topic, target: post) + + post.id + end + + let(:moderator) { Fabricate(:moderator) } + before { sign_in(moderator) } + + run_test! + + 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 put "Update a single post" do @@ -570,7 +593,7 @@ RSpec.describe "posts" do type: :object, }, reviewable_id: { - type: %i[string null], + type: %i[integer null], }, reviewable_score_count: { type: :integer, diff --git a/spec/requests/api/private_messages_spec.rb b/spec/requests/api/private_messages_spec.rb index 2086302e785..5e13feefcfb 100644 --- a/spec/requests/api/private_messages_spec.rb +++ b/spec/requests/api/private_messages_spec.rb @@ -178,7 +178,7 @@ RSpec.describe "private messages" do type: :integer, }, primary_group_id: { - type: %i[string null], + type: %i[integer null], }, }, }, @@ -198,7 +198,7 @@ RSpec.describe "private messages" do type: :integer, }, primary_group_id: { - type: %i[string null], + type: %i[integer null], }, }, }, @@ -385,7 +385,7 @@ RSpec.describe "private messages" do type: :integer, }, primary_group_id: { - type: %i[string null], + type: %i[integer null], }, }, }, diff --git a/spec/requests/api/schemas/json/admin_user_response.json b/spec/requests/api/schemas/json/admin_user_response.json index e268a83077a..6b6d902c1fa 100644 --- a/spec/requests/api/schemas/json/admin_user_response.json +++ b/spec/requests/api/schemas/json/admin_user_response.json @@ -144,7 +144,7 @@ ] }, "primary_group_id": { - "type": ["string", "null"] + "type": ["integer", "null"] }, "badge_count": { "type": "integer" @@ -411,7 +411,7 @@ "type": ["string", "null"] }, "flair_group_id": { - "type": ["string", "null"] + "type": ["integer", "null"] }, "bio_raw": { "type": ["string", "null"] diff --git a/spec/requests/api/schemas/json/category_topics_response.json b/spec/requests/api/schemas/json/category_topics_response.json index aba3b4deb7a..8f15282e8ad 100644 --- a/spec/requests/api/schemas/json/category_topics_response.json +++ b/spec/requests/api/schemas/json/category_topics_response.json @@ -176,7 +176,7 @@ }, "primary_group_id": { "type": [ - "string", + "integer", "null" ] } diff --git a/spec/requests/api/schemas/json/post_replies_response.json b/spec/requests/api/schemas/json/post_replies_response.json index aa3f0c0b337..8c9ecb3e582 100644 --- a/spec/requests/api/schemas/json/post_replies_response.json +++ b/spec/requests/api/schemas/json/post_replies_response.json @@ -103,7 +103,7 @@ }, "flair_group_id": { "type": [ - "string", + "integer", "null" ] }, @@ -155,7 +155,7 @@ }, "actions_summary": { "type": "array", - "items": + "items": { "type": "object", "additionalProperties": false, @@ -214,7 +214,7 @@ }, "reviewable_id": { "type": [ - "string", + "integer", "null" ] }, diff --git a/spec/requests/api/schemas/json/post_show_response.json b/spec/requests/api/schemas/json/post_show_response.json index 1e16c83d676..2148cd0a0f9 100644 --- a/spec/requests/api/schemas/json/post_show_response.json +++ b/spec/requests/api/schemas/json/post_show_response.json @@ -90,7 +90,7 @@ }, "flair_group_id": { "type": [ - "string", + "integer", "null" ] }, @@ -193,7 +193,7 @@ }, "reviewable_id": { "type": [ - "string", + "integer", "null" ] }, diff --git a/spec/requests/api/schemas/json/post_update_response.json b/spec/requests/api/schemas/json/post_update_response.json index e395b053e04..da253ae720d 100644 --- a/spec/requests/api/schemas/json/post_update_response.json +++ b/spec/requests/api/schemas/json/post_update_response.json @@ -94,7 +94,7 @@ }, "flair_group_id": { "type": [ - "string", + "integer", "null" ] }, @@ -191,7 +191,7 @@ }, "reviewable_id": { "type": [ - "string", + "integer", "null" ] }, diff --git a/spec/requests/api/schemas/json/topic_create_response.json b/spec/requests/api/schemas/json/topic_create_response.json index d142fd2d782..6cfbaac4f37 100644 --- a/spec/requests/api/schemas/json/topic_create_response.json +++ b/spec/requests/api/schemas/json/topic_create_response.json @@ -105,7 +105,7 @@ }, "flair_group_id": { "type": [ - "string", + "integer", "null" ] }, @@ -200,7 +200,7 @@ }, "reviewable_id": { "type": [ - "string", + "integer", "null" ] }, diff --git a/spec/requests/api/schemas/json/topic_show_response.json b/spec/requests/api/schemas/json/topic_show_response.json index b6fe0b92023..7c728075233 100644 --- a/spec/requests/api/schemas/json/topic_show_response.json +++ b/spec/requests/api/schemas/json/topic_show_response.json @@ -836,7 +836,7 @@ }, "flair_group_id": { "type": [ - "string", + "integer", "null" ] }, diff --git a/spec/requests/api/schemas/json/user_get_response.json b/spec/requests/api/schemas/json/user_get_response.json index 70fc13f671b..1bf590efc3c 100644 --- a/spec/requests/api/schemas/json/user_get_response.json +++ b/spec/requests/api/schemas/json/user_get_response.json @@ -119,7 +119,7 @@ }, "primary_group_id": { "type": [ - "string", + "integer", "null" ] }, @@ -131,7 +131,7 @@ }, "flair_group_id": { "type": [ - "string", + "integer", "null" ] }, @@ -182,7 +182,7 @@ }, "uploaded_avatar_id": { "type": [ - "string", + "integer", "null" ] }, diff --git a/spec/requests/api/tags_spec.rb b/spec/requests/api/tags_spec.rb index 2c282aab592..218adcdcc21 100644 --- a/spec/requests/api/tags_spec.rb +++ b/spec/requests/api/tags_spec.rb @@ -444,7 +444,7 @@ RSpec.describe "tags" do type: :integer, }, primary_group_id: { - type: %i[string null], + type: %i[integer null], }, }, }, diff --git a/spec/requests/api/topics_spec.rb b/spec/requests/api/topics_spec.rb index 1de78096b6a..adc166264b0 100644 --- a/spec/requests/api/topics_spec.rb +++ b/spec/requests/api/topics_spec.rb @@ -627,7 +627,7 @@ RSpec.describe "topics" do type: :integer, }, primary_group_id: { - type: %i[string null], + type: %i[integer null], }, }, }, @@ -827,7 +827,7 @@ RSpec.describe "topics" do type: :integer, }, primary_group_id: { - type: %i[string null], + type: %i[integer null], }, }, }, @@ -966,7 +966,7 @@ RSpec.describe "topics" do type: :boolean, }, category_id: { - type: %i[string null], + type: %i[integer null], }, } diff --git a/spec/requests/api/users_spec.rb b/spec/requests/api/users_spec.rb index dd1b6222823..0b6da1aee1f 100644 --- a/spec/requests/api/users_spec.rb +++ b/spec/requests/api/users_spec.rb @@ -68,6 +68,18 @@ RSpec.describe "users" do let(:expected_request_schema) { expected_request_schema } end end + + response "200", "user with primary group response" do + expected_response_schema = load_spec_schema("user_get_response") + schema expected_response_schema + + let(:username) { Fabricate(:user, primary_group_id: Fabricate(:group).id).username } + + 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 put "Update a user" do