2020-05-12 03:06:49 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
require "swagger_helper"
|
|
|
|
|
2022-07-28 10:27:38 +08:00
|
|
|
RSpec.describe "posts" do
|
2020-05-12 03:06:49 +08:00
|
|
|
let(:"Api-Key") { Fabricate(:api_key).key }
|
|
|
|
let(:"Api-Username") { "system" }
|
2021-03-13 07:48:39 +08:00
|
|
|
let(:admin) { Fabricate(:admin) }
|
|
|
|
|
|
|
|
before do
|
|
|
|
Jobs.run_immediately!
|
|
|
|
sign_in(admin)
|
|
|
|
end
|
2020-05-12 03:06:49 +08:00
|
|
|
|
|
|
|
path "/posts.json" do
|
|
|
|
get "List latest posts across topics" do
|
|
|
|
tags "Posts"
|
2021-09-03 21:39:29 +08:00
|
|
|
operationId "listPosts"
|
2020-05-12 03:06:49 +08:00
|
|
|
parameter name: "Api-Key", in: :header, type: :string, required: true
|
|
|
|
parameter name: "Api-Username", in: :header, type: :string, required: true
|
2022-09-16 22:09:15 +08:00
|
|
|
parameter name: "before",
|
|
|
|
in: :query,
|
|
|
|
type: :string,
|
|
|
|
description: "Load posts with an id lower than this value. Useful for pagination.",
|
|
|
|
required: false
|
2020-05-12 03:06:49 +08:00
|
|
|
produces "application/json"
|
2023-01-09 19:18:21 +08:00
|
|
|
|
2020-05-12 03:06:49 +08:00
|
|
|
response "200", "latest posts" do
|
|
|
|
schema type: :object,
|
|
|
|
properties: {
|
|
|
|
latest_posts: {
|
|
|
|
type: :array,
|
|
|
|
items: {
|
|
|
|
type: :object,
|
|
|
|
properties: {
|
|
|
|
id: {
|
|
|
|
type: :integer,
|
|
|
|
},
|
|
|
|
name: {
|
|
|
|
type: :string,
|
|
|
|
},
|
|
|
|
username: {
|
|
|
|
type: :string,
|
|
|
|
},
|
|
|
|
avatar_template: {
|
|
|
|
type: :string,
|
|
|
|
},
|
|
|
|
created_at: {
|
|
|
|
type: :string,
|
|
|
|
},
|
|
|
|
cooked: {
|
|
|
|
type: :string,
|
|
|
|
},
|
|
|
|
post_number: {
|
|
|
|
type: :integer,
|
|
|
|
},
|
|
|
|
post_type: {
|
|
|
|
type: :integer,
|
|
|
|
},
|
|
|
|
updated_at: {
|
|
|
|
type: :string,
|
|
|
|
},
|
|
|
|
reply_count: {
|
2021-08-13 02:25:17 +08:00
|
|
|
type: :integer,
|
|
|
|
},
|
|
|
|
reply_to_post_number: {
|
|
|
|
type: %i[string null],
|
2020-05-12 03:06:49 +08:00
|
|
|
},
|
|
|
|
quote_count: {
|
|
|
|
type: :integer,
|
|
|
|
},
|
|
|
|
incoming_link_count: {
|
|
|
|
type: :integer,
|
|
|
|
},
|
|
|
|
reads: {
|
|
|
|
type: :integer,
|
|
|
|
},
|
|
|
|
readers_count: {
|
|
|
|
type: :integer,
|
|
|
|
},
|
|
|
|
score: {
|
|
|
|
type: :number,
|
|
|
|
},
|
|
|
|
yours: {
|
|
|
|
type: :boolean,
|
|
|
|
},
|
|
|
|
topic_id: {
|
|
|
|
type: :integer,
|
|
|
|
},
|
|
|
|
topic_slug: {
|
|
|
|
type: :string,
|
|
|
|
},
|
|
|
|
topic_title: {
|
|
|
|
type: :string,
|
|
|
|
},
|
|
|
|
topic_html_title: {
|
|
|
|
type: :string,
|
|
|
|
},
|
|
|
|
category_id: {
|
|
|
|
type: :integer,
|
|
|
|
},
|
|
|
|
display_username: {
|
2021-08-13 02:25:17 +08:00
|
|
|
type: :string,
|
|
|
|
},
|
|
|
|
primary_group_name: {
|
|
|
|
type: %i[string null],
|
|
|
|
},
|
|
|
|
flair_name: {
|
|
|
|
type: %i[string null],
|
|
|
|
},
|
|
|
|
flair_url: {
|
|
|
|
type: %i[string null],
|
|
|
|
},
|
|
|
|
flair_bg_color: {
|
|
|
|
type: %i[string null],
|
|
|
|
},
|
|
|
|
flair_color: {
|
|
|
|
type: %i[string null],
|
2020-05-12 03:06:49 +08:00
|
|
|
},
|
2023-04-25 03:04:26 +08:00
|
|
|
flair_group_id: {
|
|
|
|
type: %i[string null],
|
|
|
|
},
|
2020-05-12 03:06:49 +08:00
|
|
|
version: {
|
|
|
|
type: :integer,
|
|
|
|
},
|
|
|
|
can_edit: {
|
|
|
|
type: :boolean,
|
|
|
|
},
|
|
|
|
can_delete: {
|
|
|
|
type: :boolean,
|
|
|
|
},
|
|
|
|
can_recover: {
|
|
|
|
type: :boolean,
|
|
|
|
},
|
2023-06-01 11:32:05 +08:00
|
|
|
can_see_hidden_post: {
|
|
|
|
type: :boolean,
|
|
|
|
},
|
2020-05-12 03:06:49 +08:00
|
|
|
can_wiki: {
|
2021-08-13 02:25:17 +08:00
|
|
|
type: :boolean,
|
|
|
|
},
|
|
|
|
user_title: {
|
|
|
|
type: %i[string null],
|
2020-05-12 03:06:49 +08:00
|
|
|
},
|
|
|
|
raw: {
|
|
|
|
type: :string,
|
2023-01-09 19:18:21 +08:00
|
|
|
},
|
2020-05-12 03:06:49 +08:00
|
|
|
actions_summary: {
|
|
|
|
type: :array,
|
|
|
|
items: {
|
|
|
|
type: :object,
|
|
|
|
properties: {
|
|
|
|
id: {
|
|
|
|
type: :integer,
|
|
|
|
},
|
|
|
|
can_act: {
|
|
|
|
type: :boolean,
|
2023-01-09 19:18:21 +08:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2020-05-12 03:06:49 +08:00
|
|
|
},
|
|
|
|
moderator: {
|
|
|
|
type: :boolean,
|
|
|
|
},
|
|
|
|
admin: {
|
|
|
|
type: :boolean,
|
2023-01-09 19:18:21 +08:00
|
|
|
},
|
|
|
|
staff: {
|
2020-05-12 03:06:49 +08:00
|
|
|
type: :boolean,
|
|
|
|
},
|
|
|
|
user_id: {
|
|
|
|
type: :integer,
|
|
|
|
},
|
|
|
|
hidden: {
|
|
|
|
type: :boolean,
|
|
|
|
},
|
|
|
|
trust_level: {
|
|
|
|
type: :integer,
|
2021-08-13 02:25:17 +08:00
|
|
|
},
|
|
|
|
deleted_at: {
|
|
|
|
type: %i[string null],
|
2020-05-12 03:06:49 +08:00
|
|
|
},
|
|
|
|
user_deleted: {
|
|
|
|
type: :boolean,
|
2021-08-13 02:25:17 +08:00
|
|
|
},
|
|
|
|
edit_reason: {
|
|
|
|
type: %i[string null],
|
2020-05-12 03:06:49 +08:00
|
|
|
},
|
|
|
|
can_view_edit_history: {
|
|
|
|
type: :boolean,
|
|
|
|
},
|
|
|
|
wiki: {
|
2021-08-13 02:25:17 +08:00
|
|
|
type: :boolean,
|
|
|
|
},
|
|
|
|
reviewable_id: {
|
|
|
|
type: %i[string null],
|
2020-05-12 03:06:49 +08:00
|
|
|
},
|
|
|
|
reviewable_score_count: {
|
|
|
|
type: :integer,
|
|
|
|
},
|
|
|
|
reviewable_score_pending_count: {
|
|
|
|
type: :integer,
|
|
|
|
},
|
2023-01-09 19:18:21 +08:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2020-05-12 03:06:49 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
let!(:post) { Fabricate(:post) }
|
|
|
|
run_test!
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
post "Creates a new topic, a new post, or a private message" do
|
2021-03-13 07:48:39 +08:00
|
|
|
tags "Posts", "Topics", "Private Messages"
|
2021-09-03 21:39:29 +08:00
|
|
|
operationId "createTopicPostPM"
|
2020-05-12 03:06:49 +08:00
|
|
|
consumes "application/json"
|
2021-03-13 07:48:39 +08:00
|
|
|
expected_request_schema = load_spec_schema("topic_create_request")
|
|
|
|
parameter name: :params, in: :body, schema: expected_request_schema
|
2020-05-12 03:06:49 +08:00
|
|
|
|
|
|
|
produces "application/json"
|
|
|
|
response "200", "post created" do
|
2021-03-13 07:48:39 +08:00
|
|
|
expected_response_schema = load_spec_schema("topic_create_response")
|
|
|
|
schema expected_response_schema
|
2020-05-12 03:06:49 +08:00
|
|
|
|
2021-03-13 07:48:39 +08:00
|
|
|
let(:params) { Fabricate(:post) }
|
|
|
|
|
|
|
|
it_behaves_like "a JSON endpoint", 200 do
|
|
|
|
let(:expected_response_schema) { expected_response_schema }
|
|
|
|
let(:expected_request_schema) { expected_request_schema }
|
|
|
|
end
|
2020-05-12 03:06:49 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
path "/posts/{id}.json" do
|
2021-05-21 09:43:47 +08:00
|
|
|
get "Retrieve a single post" do
|
2020-05-12 03:06:49 +08:00
|
|
|
tags "Posts"
|
2021-09-03 21:39:29 +08:00
|
|
|
operationId "getPost"
|
2023-04-10 23:07:10 +08:00
|
|
|
consumes "application/json"
|
|
|
|
description <<~TEXT
|
|
|
|
This endpoint can be used to get the number of likes on a post using the
|
|
|
|
`actions_summary` property in the response. `actions_summary` responses
|
|
|
|
with the id of `2` signify a `like`. If there are no `actions_summary`
|
|
|
|
items with the id of `2`, that means there are 0 likes. Other ids likely
|
|
|
|
refer to various different flag types.
|
|
|
|
TEXT
|
|
|
|
|
|
|
|
expected_request_schema = nil
|
2020-05-12 03:06:49 +08:00
|
|
|
parameter name: :id, in: :path, schema: { type: :string }
|
|
|
|
|
|
|
|
produces "application/json"
|
2023-01-09 19:18:21 +08:00
|
|
|
|
2023-04-10 23:07:10 +08:00
|
|
|
response "200", "single post" do
|
|
|
|
expected_response_schema = load_spec_schema("post_show_response")
|
|
|
|
schema expected_response_schema
|
2020-05-12 03:06:49 +08:00
|
|
|
|
|
|
|
let(:id) { Fabricate(:post).id }
|
|
|
|
run_test!
|
2023-04-10 23:07:10 +08:00
|
|
|
|
|
|
|
it_behaves_like "a JSON endpoint", 200 do
|
|
|
|
let(:expected_response_schema) { expected_response_schema }
|
|
|
|
let(:expected_request_schema) { expected_request_schema }
|
|
|
|
end
|
2020-05-12 03:06:49 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
put "Update a single post" do
|
|
|
|
tags "Posts"
|
2021-09-03 21:39:29 +08:00
|
|
|
operationId "updatePost"
|
2020-05-12 03:06:49 +08:00
|
|
|
consumes "application/json"
|
2023-04-10 23:07:10 +08:00
|
|
|
expected_request_schema = load_spec_schema("post_update_request")
|
2020-05-12 03:06:49 +08:00
|
|
|
parameter name: :id, in: :path, schema: { type: :string }
|
2023-04-10 23:07:10 +08:00
|
|
|
parameter name: :params, in: :body, schema: expected_request_schema
|
2023-01-09 19:18:21 +08:00
|
|
|
|
2020-05-12 03:06:49 +08:00
|
|
|
produces "application/json"
|
|
|
|
response "200", "post updated" do
|
2023-04-10 23:07:10 +08:00
|
|
|
expected_response_schema = load_spec_schema("post_update_response")
|
|
|
|
schema expected_response_schema
|
2023-01-09 19:18:21 +08:00
|
|
|
|
2023-04-10 23:07:10 +08:00
|
|
|
let(:params) do
|
|
|
|
{ "post" => { "raw" => "Updated content!", "edit_reason" => "fixed typo" } }
|
|
|
|
end
|
2020-05-12 03:06:49 +08:00
|
|
|
let(:id) { Fabricate(:post).id }
|
|
|
|
|
|
|
|
run_test! do |response|
|
|
|
|
data = JSON.parse(response.body)
|
|
|
|
expect(data["post"]["cooked"]).to eq("<p>Updated content!</p>")
|
|
|
|
expect(data["post"]["edit_reason"]).to eq("fixed typo")
|
|
|
|
end
|
2023-04-10 23:07:10 +08:00
|
|
|
|
|
|
|
it_behaves_like "a JSON endpoint", 200 do
|
|
|
|
let(:expected_response_schema) { expected_response_schema }
|
|
|
|
let(:expected_request_schema) { expected_request_schema }
|
|
|
|
end
|
2020-05-12 03:06:49 +08:00
|
|
|
end
|
|
|
|
end
|
2022-01-08 07:09:32 +08:00
|
|
|
|
|
|
|
delete "delete a single post" do
|
|
|
|
tags "Posts"
|
|
|
|
operationId "deletePost"
|
|
|
|
consumes "application/json"
|
|
|
|
expected_request_schema = load_spec_schema("post_delete_request")
|
|
|
|
parameter name: :id, in: :path, schema: { type: :integer }
|
|
|
|
parameter name: :params, in: :body, schema: expected_request_schema
|
|
|
|
|
|
|
|
produces "application/json"
|
|
|
|
response "200", "success response" do
|
|
|
|
expected_response_schema = nil
|
|
|
|
schema expected_response_schema
|
|
|
|
|
|
|
|
let(:topic) { Fabricate(:topic) }
|
|
|
|
let(:post) { Fabricate(:post, topic_id: topic.id, post_number: 3) }
|
|
|
|
let(:id) { post.id }
|
|
|
|
let(:params) { { "force_destroy" => false } }
|
|
|
|
|
|
|
|
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
|
2020-05-12 03:06:49 +08:00
|
|
|
end
|
|
|
|
|
2022-02-10 06:04:36 +08:00
|
|
|
path "/posts/{id}/replies.json" do
|
|
|
|
get "List replies to a post" do
|
|
|
|
tags "Posts"
|
|
|
|
operationId "postReplies"
|
|
|
|
consumes "application/json"
|
|
|
|
expected_request_schema = nil
|
|
|
|
parameter name: :id, in: :path, schema: { type: :string }
|
|
|
|
|
|
|
|
produces "application/json"
|
|
|
|
response "200", "post replies" do
|
|
|
|
expected_response_schema = load_spec_schema("post_replies_response")
|
|
|
|
schema expected_response_schema
|
|
|
|
|
2023-11-10 06:47:59 +08:00
|
|
|
fab!(:user)
|
|
|
|
fab!(:topic)
|
2022-02-10 06:04:36 +08:00
|
|
|
fab!(:post) { Fabricate(:post, topic: topic, user: user) }
|
|
|
|
let!(:reply) do
|
|
|
|
PostCreator.new(
|
|
|
|
user,
|
|
|
|
raw: "this is some text for my post",
|
|
|
|
topic_id: topic.id,
|
|
|
|
reply_to_post_number: post.post_number,
|
|
|
|
).create
|
2023-01-09 19:18:21 +08:00
|
|
|
end
|
2022-02-10 06:04:36 +08:00
|
|
|
let!(:id) { post.id }
|
|
|
|
|
|
|
|
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
|
|
|
|
|
2020-05-12 03:06:49 +08:00
|
|
|
path "/posts/{id}/locked.json" do
|
|
|
|
put "Lock a post from being edited" do
|
|
|
|
tags "Posts"
|
2021-09-03 21:39:29 +08:00
|
|
|
operationId "lockPost"
|
2020-05-12 03:06:49 +08:00
|
|
|
consumes "application/json"
|
|
|
|
parameter name: "Api-Key", in: :header, type: :string, required: true
|
|
|
|
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: {
|
2022-06-06 15:23:40 +08:00
|
|
|
locked: {
|
|
|
|
type: :string,
|
2020-05-12 03:06:49 +08:00
|
|
|
},
|
2023-01-09 19:18:21 +08:00
|
|
|
},
|
2020-05-12 03:06:49 +08:00
|
|
|
required: ["locked"],
|
|
|
|
}
|
|
|
|
|
|
|
|
produces "application/json"
|
|
|
|
response "200", "post updated" do
|
|
|
|
schema type: :object, properties: { locked: { type: :boolean } }
|
|
|
|
|
|
|
|
let(:post_body) { { locked: "true" } }
|
|
|
|
let(:id) { Fabricate(:post).id }
|
|
|
|
|
|
|
|
run_test! do |response|
|
|
|
|
data = JSON.parse(response.body)
|
|
|
|
expect(data["locked"]).to eq(true)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
path "/post_actions.json" do
|
|
|
|
post "Like a post and other actions" do
|
|
|
|
tags "Posts"
|
2021-09-03 21:39:29 +08:00
|
|
|
operationId "performPostAction"
|
2020-05-12 03:06:49 +08:00
|
|
|
consumes "application/json"
|
|
|
|
parameter name: "Api-Key", in: :header, type: :string, required: true
|
|
|
|
parameter name: "Api-Username", in: :header, type: :string, required: true
|
2023-01-09 19:18:21 +08:00
|
|
|
|
2020-05-12 03:06:49 +08:00
|
|
|
parameter name: :post_body,
|
|
|
|
in: :body,
|
|
|
|
schema: {
|
|
|
|
type: :object,
|
|
|
|
properties: {
|
|
|
|
id: {
|
|
|
|
type: :integer,
|
|
|
|
},
|
|
|
|
post_action_type_id: {
|
|
|
|
type: :integer,
|
|
|
|
},
|
|
|
|
flag_topic: {
|
|
|
|
type: :boolean,
|
2023-01-09 19:18:21 +08:00
|
|
|
},
|
2020-05-12 03:06:49 +08:00
|
|
|
},
|
|
|
|
required: %w[id post_action_type_id],
|
|
|
|
}
|
2023-01-09 19:18:21 +08:00
|
|
|
|
2020-05-12 03:06:49 +08:00
|
|
|
produces "application/json"
|
|
|
|
response "200", "post updated" do
|
|
|
|
schema type: :object,
|
|
|
|
properties: {
|
|
|
|
id: {
|
|
|
|
type: :integer,
|
|
|
|
},
|
|
|
|
name: {
|
|
|
|
type: :string,
|
|
|
|
},
|
|
|
|
username: {
|
|
|
|
type: :string,
|
|
|
|
},
|
|
|
|
avatar_template: {
|
|
|
|
type: :string,
|
|
|
|
},
|
|
|
|
created_at: {
|
2021-08-13 02:25:17 +08:00
|
|
|
type: :string,
|
2020-05-12 03:06:49 +08:00
|
|
|
},
|
|
|
|
cooked: {
|
|
|
|
type: :string,
|
|
|
|
},
|
|
|
|
post_number: {
|
|
|
|
type: :integer,
|
|
|
|
},
|
|
|
|
post_type: {
|
|
|
|
type: :integer,
|
|
|
|
},
|
|
|
|
updated_at: {
|
|
|
|
type: :string,
|
|
|
|
},
|
|
|
|
reply_count: {
|
2021-08-13 02:25:17 +08:00
|
|
|
type: :integer,
|
|
|
|
},
|
|
|
|
reply_to_post_number: {
|
|
|
|
type: %i[string null],
|
2020-05-12 03:06:49 +08:00
|
|
|
},
|
|
|
|
quote_count: {
|
|
|
|
type: :integer,
|
|
|
|
},
|
|
|
|
incoming_link_count: {
|
|
|
|
type: :integer,
|
|
|
|
},
|
|
|
|
reads: {
|
|
|
|
type: :integer,
|
|
|
|
},
|
|
|
|
readers_count: {
|
2022-01-08 07:09:32 +08:00
|
|
|
type: :integer,
|
2020-05-12 03:06:49 +08:00
|
|
|
},
|
|
|
|
score: {
|
|
|
|
type: :number,
|
|
|
|
},
|
|
|
|
yours: {
|
|
|
|
type: :boolean,
|
|
|
|
},
|
|
|
|
topic_id: {
|
|
|
|
type: :integer,
|
|
|
|
},
|
|
|
|
topic_slug: {
|
|
|
|
type: :string,
|
|
|
|
},
|
|
|
|
display_username: {
|
2021-08-13 02:25:17 +08:00
|
|
|
type: :string,
|
|
|
|
},
|
|
|
|
primary_group_name: {
|
|
|
|
type: %i[string null],
|
|
|
|
},
|
|
|
|
flair_name: {
|
|
|
|
type: %i[string null],
|
|
|
|
},
|
|
|
|
flair_url: {
|
|
|
|
type: %i[string null],
|
|
|
|
},
|
|
|
|
flair_bg_color: {
|
|
|
|
type: %i[string null],
|
|
|
|
},
|
|
|
|
flair_color: {
|
|
|
|
type: %i[string null],
|
2020-05-12 03:06:49 +08:00
|
|
|
},
|
|
|
|
version: {
|
|
|
|
type: :integer,
|
|
|
|
},
|
|
|
|
can_edit: {
|
|
|
|
type: :boolean,
|
|
|
|
},
|
|
|
|
can_delete: {
|
|
|
|
type: :boolean,
|
|
|
|
},
|
|
|
|
can_recover: {
|
2022-06-06 16:37:08 +08:00
|
|
|
type: :boolean,
|
2020-05-12 03:06:49 +08:00
|
|
|
},
|
|
|
|
can_wiki: {
|
|
|
|
type: :boolean,
|
2021-08-13 02:25:17 +08:00
|
|
|
},
|
|
|
|
user_title: {
|
|
|
|
type: %i[string null],
|
2023-01-09 19:18:21 +08:00
|
|
|
},
|
2020-05-12 03:06:49 +08:00
|
|
|
actions_summary: {
|
|
|
|
type: :array,
|
|
|
|
items: {
|
|
|
|
type: :object,
|
|
|
|
properties: {
|
|
|
|
id: {
|
2022-01-08 07:09:32 +08:00
|
|
|
type: :integer,
|
2020-05-12 03:06:49 +08:00
|
|
|
},
|
2023-01-09 19:18:21 +08:00
|
|
|
count: {
|
2020-05-12 03:06:49 +08:00
|
|
|
type: :integer,
|
|
|
|
},
|
|
|
|
acted: {
|
|
|
|
type: :boolean,
|
|
|
|
},
|
|
|
|
can_undo: {
|
|
|
|
type: :boolean,
|
2023-01-09 19:18:21 +08:00
|
|
|
},
|
|
|
|
},
|
2020-05-12 03:06:49 +08:00
|
|
|
},
|
2023-01-09 19:18:21 +08:00
|
|
|
},
|
2020-05-12 03:06:49 +08:00
|
|
|
moderator: {
|
2022-06-06 16:37:08 +08:00
|
|
|
type: :boolean,
|
2020-05-12 03:06:49 +08:00
|
|
|
},
|
|
|
|
admin: {
|
2022-06-06 16:37:08 +08:00
|
|
|
type: :boolean,
|
2023-01-09 19:18:21 +08:00
|
|
|
},
|
|
|
|
staff: {
|
2020-05-12 03:06:49 +08:00
|
|
|
type: :boolean,
|
|
|
|
},
|
|
|
|
user_id: {
|
|
|
|
type: :integer,
|
|
|
|
},
|
|
|
|
hidden: {
|
|
|
|
type: :boolean,
|
|
|
|
},
|
|
|
|
trust_level: {
|
|
|
|
type: :integer,
|
2021-08-13 02:25:17 +08:00
|
|
|
},
|
|
|
|
deleted_at: {
|
|
|
|
type: %i[string null],
|
2020-05-12 03:06:49 +08:00
|
|
|
},
|
|
|
|
user_deleted: {
|
|
|
|
type: :boolean,
|
2021-08-13 02:25:17 +08:00
|
|
|
},
|
|
|
|
edit_reason: {
|
|
|
|
type: %i[string null],
|
2020-05-12 03:06:49 +08:00
|
|
|
},
|
|
|
|
can_view_edit_history: {
|
|
|
|
type: :boolean,
|
|
|
|
},
|
|
|
|
wiki: {
|
|
|
|
type: :boolean,
|
2020-11-11 20:49:53 +08:00
|
|
|
},
|
|
|
|
notice: {
|
|
|
|
type: :object,
|
2021-08-13 02:25:17 +08:00
|
|
|
},
|
|
|
|
reviewable_id: {
|
|
|
|
type: %i[string null],
|
2020-05-12 03:06:49 +08:00
|
|
|
},
|
|
|
|
reviewable_score_count: {
|
|
|
|
type: :integer,
|
|
|
|
},
|
|
|
|
reviewable_score_pending_count: {
|
2022-01-08 07:09:32 +08:00
|
|
|
type: :integer,
|
2023-01-09 19:18:21 +08:00
|
|
|
},
|
2020-05-12 03:06:49 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
let(:id) { Fabricate(:post).id }
|
|
|
|
let(:post_body) { { id: id, post_action_type_id: 2 } }
|
|
|
|
|
|
|
|
run_test! do |response|
|
|
|
|
data = JSON.parse(response.body)
|
|
|
|
expect(data["actions_summary"][0]["id"]).to eq(2)
|
|
|
|
expect(data["actions_summary"][0]["count"]).to eq(1)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|