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:
Roman Rizzi
2021-02-17 14:42:44 -03:00
committed by GitHub
parent a174c8b8d4
commit 07cf0f9460
5 changed files with 31 additions and 10 deletions

View File

@ -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