diff options
author | Kamil Trzciński <ayufan@ayufan.eu> | 2019-01-16 12:51:21 +0300 |
---|---|---|
committer | Kamil Trzciński <ayufan@ayufan.eu> | 2019-01-16 12:51:21 +0300 |
commit | 28ca155be9c9fe63aa97d7f7fb9048ccf7c1401b (patch) | |
tree | 638e3ec2f8680847629f184de7d193334c4a2dcc /spec/requests/api | |
parent | 372716ea2472f498a55dc00eea972dfc6cd07ce9 (diff) | |
parent | 5396594a831de3f467f28c25c5856ba441b07ea7 (diff) |
Merge branch 'zj-feature-gate-set-project-path' into 'master'
Allow setting of feature gates per project
See merge request gitlab-org/gitlab-ce!24184
Diffstat (limited to 'spec/requests/api')
-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 7d3eff7d32d..22a9e36ca31 100644 --- a/spec/requests/api/features_spec.rb +++ b/spec/requests/api/features_spec.rb @@ -129,6 +129,40 @@ describe API::Features do end end + context 'when enabling for a project by path' do + context 'when the project exists' do + let!(:project) { create(:project) } + + it 'sets the feature gate' do + post api("/features/#{feature_name}", admin), params: { value: 'true', project: project.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' => ["Project:#{project.id}"] } + ]) + end + end + + context 'when the project does not exist' do + it 'sets no new values' do + post api("/features/#{feature_name}", admin), params: { value: 'true', project: 'mep/to/the/mep/mep' } + + 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' } |