summaryrefslogtreecommitdiff
path: root/spec/requests
diff options
context:
space:
mode:
authorJames Lopez <james@gitlab.com>2019-02-19 07:50:55 +0000
committerJames Lopez <james@gitlab.com>2019-02-19 07:50:55 +0000
commit5ff775fdef99eeec1f25bea7baf5480fa402f714 (patch)
treed7f9b148101af6690214989fa33d0bcd0cf301e9 /spec/requests
parent503061217e010e74d155464be7dfd8e9754776db (diff)
parent46f66c7f0aa5ddf2f8d996880936d88e6977f6c0 (diff)
downloadgitlab-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.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 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' }