Skip to content

Commit 0ae08e8

Browse files
committed
Merge branch 'bug/issue-43' into support/0.8
Fixes #43
2 parents 5583d0e + 58ea5aa commit 0ae08e8

File tree

3 files changed

+32
-0
lines changed

3 files changed

+32
-0
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22
All notable changes to this project will be documented in this file.
33
This project adheres to [Semantic Versioning](http://semver.org/).
44

5+
## [Unreleased]
6+
7+
## Fixed:
8+
- Declining a PR without a `message` parameter caused a 500 response. (issue #43)
9+
10+
511
## 0.8.0 / 2015-12-05
612

713
### Added:

lib/Bitbucket/API/Repositories/PullRequests.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,10 @@ public function accept($account, $repo, $id, $params = array())
309309
*/
310310
public function decline($account, $repo, $id, $params = array())
311311
{
312+
if (false === array_key_exists('message', $params)) {
313+
$params['message'] = '';
314+
}
315+
312316
return $this->getClient()->setApiVersion('2.0')->post(
313317
sprintf('repositories/%s/%s/pullrequests/%d/decline', $account, $repo, $id),
314318
json_encode($params),

test/Bitbucket/Tests/API/Repositories/PullRequestsTest.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Bitbucket\Tests\API as Tests;
66
use Bitbucket\API;
7+
use Buzz\Message\RequestInterface;
78

89
/**
910
* Class PullRequestsTest
@@ -318,4 +319,25 @@ public function testDeclineAPullRequest()
318319

319320
$pull->decline('gentle', 'eof', 1, $params);
320321
}
322+
323+
/**
324+
* @ticket 43
325+
*/
326+
public function testDeclineAPullRequestWithoutAMessage()
327+
{
328+
$endpoint = 'repositories/gentle/eof/pullrequests/1/decline';
329+
$params = array(
330+
'message' => ''
331+
);
332+
333+
$client = $this->getHttpClientMock();
334+
$client->expects($this->once())
335+
->method('post')
336+
->with($endpoint, json_encode($params));
337+
338+
/** @var \Bitbucket\API\Repositories\PullRequests $pull */
339+
$pull = $this->getClassMock('Bitbucket\API\Repositories\PullRequests', $client);
340+
341+
$pull->decline('gentle', 'eof', 1, array());
342+
}
321343
}

0 commit comments

Comments
 (0)