DEV: Add API scope for categories endpoint (#16105)

This change adds support for the categories endpoint to have an api
scope. Only adds GET scope for listing categories and for fetching a
single category.

See: https://meta.discourse.org/t/218080/4
This commit is contained in:
Blake Erickson 2022-03-04 14:29:47 -07:00 committed by GitHub
parent eb2e3b510d
commit d760fd4074
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 1 deletions

View File

@ -36,6 +36,10 @@ class ApiKeyScope < ActiveRecord::Base
posts: {
edit: { actions: %w[posts#update], params: %i[id] }
},
categories: {
list: { actions: %w[categories#index] },
show: { actions: %w[categories#show], params: %i[id] }
},
uploads: {
create: {
actions: %w[

View File

@ -4219,6 +4219,9 @@ en:
wordpress: Necessary for the WordPress wp-discourse plugin to work.
posts:
edit: Edit any post or a specific one.
categories:
list: Get a list of categories.
show: Get a single category by id.
uploads:
create: Upload a new file or initiate single or multipart direct uploads to external storage.
users:

View File

@ -235,7 +235,7 @@ describe Admin::ApiController do
scopes = response.parsed_body['scopes']
expect(scopes.keys).to contain_exactly('topics', 'users', 'email', 'posts', 'uploads', 'global', 'badges')
expect(scopes.keys).to contain_exactly('topics', 'users', 'email', 'posts', 'uploads', 'global', 'badges', 'categories')
end
end
end