diff options
Diffstat (limited to 'spec/requests/api/features_spec.rb')
-rw-r--r-- | spec/requests/api/features_spec.rb | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/spec/requests/api/features_spec.rb b/spec/requests/api/features_spec.rb index 22a9e36ca31..57a57e69a00 100644 --- a/spec/requests/api/features_spec.rb +++ b/spec/requests/api/features_spec.rb @@ -163,6 +163,40 @@ describe API::Features do end end + context 'when enabling for a group by path' do + context 'when the group exists' do + it 'sets the feature gate' do + group = create(:group) + + post api("/features/#{feature_name}", admin), params: { value: 'true', group: group.full_path } + + expect(response).to have_gitlab_http_status(201) + expect(json_response).to eq( + 'name' => 'my_feature', + 'state' => 'conditional', + 'gates' => [ + { 'key' => 'boolean', 'value' => false }, + { 'key' => 'actors', 'value' => ["Group:#{group.id}"] } + ]) + end + end + + context 'when the group does not exist' do + it 'sets no new values and keeps the feature disabled' do + post api("/features/#{feature_name}", admin), params: { value: 'true', group: 'not/a/group' } + + expect(response).to have_gitlab_http_status(201) + expect(json_response).to eq( + "name" => "my_feature", + "state" => "off", + "gates" => [ + { "key" => "boolean", "value" => false } + ] + ) + end + end + end + it 'creates a feature with the given percentage if passed an integer' do post api("/features/#{feature_name}", admin), params: { value: '50' } |