|
163 | 163 | end
|
164 | 164 | end
|
165 | 165 |
|
| 166 | + context 'when enabling for a group by path' do |
| 167 | + context 'when the group exists' do |
| 168 | + it 'sets the feature gate' do |
| 169 | + group = create(:group) |
| 170 | + |
| 171 | + post api("/features/#{feature_name}", admin), params: { value: 'true', group: group.full_path } |
| 172 | + |
| 173 | + expect(response).to have_gitlab_http_status(201) |
| 174 | + expect(json_response).to eq( |
| 175 | + 'name' => 'my_feature', |
| 176 | + 'state' => 'conditional', |
| 177 | + 'gates' => [ |
| 178 | + { 'key' => 'boolean', 'value' => false }, |
| 179 | + { 'key' => 'actors', 'value' => ["Group:#{group.id}"] } |
| 180 | + ]) |
| 181 | + end |
| 182 | + end |
| 183 | + |
| 184 | + context 'when the group does not exist' do |
| 185 | + it 'sets no new values and keeps the feature disabled' do |
| 186 | + post api("/features/#{feature_name}", admin), params: { value: 'true', group: 'not/a/group' } |
| 187 | + |
| 188 | + expect(response).to have_gitlab_http_status(201) |
| 189 | + expect(json_response).to eq( |
| 190 | + "name" => "my_feature", |
| 191 | + "state" => "off", |
| 192 | + "gates" => [ |
| 193 | + { "key" => "boolean", "value" => false } |
| 194 | + ] |
| 195 | + ) |
| 196 | + end |
| 197 | + end |
| 198 | + end |
| 199 | + |
166 | 200 | it 'creates a feature with the given percentage if passed an integer' do
|
167 | 201 | post api("/features/#{feature_name}", admin), params: { value: '50' }
|
168 | 202 |
|
|
0 commit comments