mirror of
https://github.com/discourse/discourse.git
synced 2025-05-29 21:08:03 +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:
@ -593,4 +593,13 @@ describe Plugin::Instance do
|
||||
expect(ReviewableScore.types.values.max).to eq(highest_flag_id + 2)
|
||||
end
|
||||
end
|
||||
|
||||
describe '#add_api_key_scope' do
|
||||
it 'adds a custom api key scope' do
|
||||
actions = %w[admin/groups#create]
|
||||
subject.add_api_key_scope(:groups, create: { actions: actions })
|
||||
|
||||
expect(ApiKeyScope.scope_mappings.dig(:groups, :create, :actions)).to contain_exactly(*actions)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user