DEV: Add API scopes for post revisions (#26183)

This commit adds API scopes for reading, modifying, and deleting post
revisions.
This commit is contained in:
Blake Erickson 2024-03-14 15:24:54 -06:00 committed by GitHub
parent c986f9a947
commit 70c23f11a9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 25 additions and 0 deletions

View File

@ -71,6 +71,20 @@ class ApiKeyScope < ActiveRecord::Base
actions: %w[posts#latest], actions: %w[posts#latest],
}, },
}, },
revisions: {
read: {
actions: %w[posts#latest_revision posts#revisions],
params: %i[post_id],
},
modify: {
actions: %w[posts#hide_revision posts#show_revision posts#revert],
params: %i[post_id],
},
permanently_delete: {
actions: %w[posts#permanently_delete_revisions],
params: %i[post_id],
},
},
tags: { tags: {
list: { list: {
actions: %w[tags#index], actions: %w[tags#index],

View File

@ -5063,6 +5063,10 @@ en:
delete: Delete a post. delete: Delete a post.
recover: Recover a post. recover: Recover a post.
list: List latest posts and private posts. RSS is also supported. list: List latest posts and private posts. RSS is also supported.
revisions:
read: "Get the latest or a specific revision."
modify: "Hide, show, or revert revisions."
permanently_delete: "Permanently delete a revision."
tags: tags:
list: List tags. list: List tags.
tag_groups: tag_groups:

View File

@ -450,6 +450,7 @@ RSpec.describe Admin::ApiController do
"users", "users",
"email", "email",
"posts", "posts",
"revisions",
"tags", "tags",
"tag_groups", "tag_groups",
"uploads", "uploads",
@ -491,6 +492,12 @@ RSpec.describe Admin::ApiController do
scopes["posts"].any? { |h| h["urls"].include?("/posts/:post_id/recover (PUT)") }, scopes["posts"].any? { |h| h["urls"].include?("/posts/:post_id/recover (PUT)") },
).to be_truthy ).to be_truthy
expect(
scopes["revisions"].any? do |h|
h["urls"].include?("/posts/:post_id/revisions/permanently_delete (DELETE)")
end,
).to be_truthy
expect(scopes["users"].find { _1["key"] == "update" }["urls"]).to contain_exactly( expect(scopes["users"].find { _1["key"] == "update" }["urls"]).to contain_exactly(
"/users/:username (PUT)", "/users/:username (PUT)",
"/users/:username/preferences/badge_title (PUT)", "/users/:username/preferences/badge_title (PUT)",