Skip to content

Commit 180fbfd

Browse files
jdecoolm1guelpf
authored andcommitted
Add method to remove group variable
1 parent 8ba69aa commit 180fbfd

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

lib/Gitlab/Api/Groups.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,17 @@ public function updateVariable($group_id, $key, $value, $protected = null)
285285
return $this->put($this->getGroupPath($group_id, 'variables/'.$this->encodePath($key)), $payload);
286286
}
287287

288+
/**
289+
* @param int $group_id
290+
* @param string $key
291+
*
292+
* @return mixed
293+
*/
294+
public function removeVariable($group_id, $key)
295+
{
296+
return $this->delete($this->getGroupPath($group_id, 'variables/'.$this->encodePath($key)));
297+
}
298+
288299
private function getGroupSearchResolver()
289300
{
290301
$resolver = $this->createOptionsResolver();

test/Gitlab/Tests/Api/GroupsTest.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,23 @@ public function shouldUpdateVariableWithProtected()
413413
$this->assertEquals($expectedArray, $api->updateVariable(1, 'DEPLOY_SERVER', 'stage.example.com', true));
414414
}
415415

416+
/**
417+
* @test
418+
*/
419+
public function shouldRemoveVariable()
420+
{
421+
$expectedBool = true;
422+
423+
$api = $this->getApiMock();
424+
$api->expects($this->once())
425+
->method('delete')
426+
->with('groups/1/variables/ftp_password')
427+
->will($this->returnValue($expectedBool))
428+
;
429+
430+
$this->assertEquals($expectedBool, $api->removeVariable(1, 'ftp_password'));
431+
}
432+
416433
protected function getApiClass()
417434
{
418435
return 'Gitlab\Api\Groups';

0 commit comments

Comments
 (0)