summaryrefslogtreecommitdiff
path: root/spec/requests/api
diff options
context:
space:
mode:
authorZeger-Jan van de Weg <git@zjvandeweg.nl>2019-01-07 11:07:14 +0100
committerZeger-Jan van de Weg <git@zjvandeweg.nl>2019-01-14 14:29:51 +0100
commit5396594a831de3f467f28c25c5856ba441b07ea7 (patch)
tree67adf2e591c65446a1d73ac90685e6073f867ad4 /spec/requests/api
parent604073ffc38f938e36f613c592c444d56c99f49c (diff)
downloadgitlab-ce-5396594a831de3f467f28c25c5856ba441b07ea7.tar.gz
Allow setting of feature gates per project
For features the feature gates are sometimes projects, not groups or users. For example for git object pools: https://gitlab.com/gitlab-com/gl-infra/infrastructure/issues/5872 This commit allows for setting feature group gates based on projects, by its path as that seems most convenient.
Diffstat (limited to 'spec/requests/api')
-rw-r--r--spec/requests/api/features_spec.rb34
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' }