mirror of
https://github.com/discourse/discourse.git
synced 2025-05-23 16:41:08 +08:00
FIX: Allow plugins to correctly extend API key scopes. (#12113)
Adding a scope from a plugin was broken. This commit fixes it and adds a test. It also documents the instance method and renames the serialized "id" attribute to "scope_id" to avoid a conflict when the scope also has a parameter with the same name.
This commit is contained in:
@ -137,7 +137,7 @@ describe Admin::ApiController do
|
||||
post "/admin/api/keys.json", params: {
|
||||
key: {
|
||||
description: "master key description",
|
||||
scopes: [{ id: 'topics:write', topic_id: '55' }]
|
||||
scopes: [{ scope_id: 'topics:write', topic_id: '55' }]
|
||||
}
|
||||
}
|
||||
expect(response.status).to eq(200)
|
||||
@ -154,7 +154,7 @@ describe Admin::ApiController do
|
||||
post "/admin/api/keys.json", params: {
|
||||
key: {
|
||||
description: "master key description",
|
||||
scopes: [{ id: 'topics:write', topic_id: '55,33' }]
|
||||
scopes: [{ scope_id: 'topics:write', topic_id: '55,33' }]
|
||||
}
|
||||
}
|
||||
expect(response.status).to eq(200)
|
||||
@ -170,7 +170,7 @@ describe Admin::ApiController do
|
||||
post "/admin/api/keys.json", params: {
|
||||
key: {
|
||||
description: "master key description",
|
||||
scopes: [{ id: 'topics:write', fake_id: '55' }]
|
||||
scopes: [{ scope_id: 'topics:write', fake_id: '55' }]
|
||||
}
|
||||
}
|
||||
|
||||
@ -186,7 +186,7 @@ describe Admin::ApiController do
|
||||
post "/admin/api/keys.json", params: {
|
||||
key: {
|
||||
description: "master key description",
|
||||
scopes: [{ id: 'something:else' }]
|
||||
scopes: [{ scope_id: 'something:else' }]
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user