Skip to content

Commit

Permalink
Merge pull request #259 from zendesk/mio/app-installations
Browse files Browse the repository at this point in the history
[MI-753] Fix update of app installations to allow setting of "enabled"
  • Loading branch information
miogalang authored Aug 8, 2016
2 parents 0048d02 + 746a6bc commit 9e981a3
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
13 changes: 11 additions & 2 deletions src/Zendesk/API/Resources/Core/AppInstallations.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ protected function setUpRoutes()
{
$this->setRoutes([
'create' => $this->resourceName . '.json',
'update' => $this->resourceName . '/{id}.json',
'jobStatuses' => $this->resourceName . '/job_statuses/{job_id}.json',
'requirements' => $this->resourceName . '/{id}/requirements.json',
]);
Expand Down Expand Up @@ -111,7 +112,15 @@ public function create(array $params, $routeKey = __FUNCTION__)
*/
public function update($id = null, array $updateResourceFields = [], $routeKey = __FUNCTION__)
{
$this->objectName = 'settings';
return $this->traitUpdate($id, $updateResourceFields, $routeKey);
if (empty($id)) {
$id = $this->getChainedParameter(__CLASS__);
}

$route = $this->getRoute($routeKey, ['id' => $id]);

return $this->client->put(
$route,
$updateResourceFields
);
}
}
9 changes: 6 additions & 3 deletions tests/Zendesk/API/UnitTests/Core/AppInstallationsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,17 @@ public function testUpdate()
{
$faker = Factory::create();
$params = [
$faker->word => $faker->boolean(),
$faker->word => $faker->randomNumber(),
'enabled' => $faker->boolean(),
'settings' => [
$faker->word => $faker->boolean(),
$faker->word => $faker->randomNumber(),
]
];

$id = $faker->randomNumber();

$this->assertEndpointCalled(function () use ($id, $params) {
$this->client->appInstallations()->update($id, $params);
}, "apps/installations/{$id}.json", 'PUT', ['postFields' => ['settings' => $params]]);
}, "apps/installations/{$id}.json", 'PUT', ['postFields' => $params]);
}
}

0 comments on commit 9e981a3

Please sign in to comment.