diff options
author | James Lopez <james@gitlab.com> | 2019-02-19 07:50:55 +0000 |
---|---|---|
committer | James Lopez <james@gitlab.com> | 2019-02-19 07:50:55 +0000 |
commit | 5ff775fdef99eeec1f25bea7baf5480fa402f714 (patch) | |
tree | d7f9b148101af6690214989fa33d0bcd0cf301e9 /spec/requests | |
parent | 503061217e010e74d155464be7dfd8e9754776db (diff) | |
parent | 46f66c7f0aa5ddf2f8d996880936d88e6977f6c0 (diff) | |
download | gitlab-ce-5ff775fdef99eeec1f25bea7baf5480fa402f714.tar.gz |
Merge branch 'jej/feature-gates-can-be-set-by-group-path' into 'master'
Allow setting feature flags per GitLab group
See merge request gitlab-org/gitlab-ce!25022
Diffstat (limited to 'spec/requests')
-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' } |