Skip to content

Commit

Permalink
Make pull request body optional (#200)
Browse files Browse the repository at this point in the history
You can create a PR with `"body": null` if you use the API, or use a tool
that uses the API.

```shell
curl -X GET https://api.github.com/repos/lloydmeta/gh-test-repo/pulls
[
  {
    "url": "https://api.github.com/repos/lloydmeta/gh-test-repo/pulls/3",
    // snip
    "body": null,
    // snip
  },
  {
    "url": "https://api.github.com/repos/lloydmeta/gh-test-repo/pulls/1",
    "id": 173714694,
    "html_url": "lloydmeta/gh-test-repo#1",
    "diff_url": "https://github.com/lloydmeta/gh-test-repo/pull/1.diff",
    "patch_url": "https://github.com/lloydmeta/gh-test-repo/pull/1.patch",
    "issue_url": "https://api.github.com/repos/lloydmeta/gh-test-repo/issues/1",
    // snip
    "body": "",
]
```
  • Loading branch information
lloydmeta authored and BenFradet committed Mar 10, 2018
1 parent 1348287 commit 8db7bd4
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ case class PullRequest(
number: Int,
state: String,
title: String,
body: String,
body: Option[String],
locked: Boolean,
html_url: String,
created_at: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,18 @@ trait GHPullRequestsSpec[T] extends BaseIntegrationSpec[T] {
})
}

"PullRequests >> List" should "return a right response when a valid repo is provided but not all pull requests have body" in {
val response =
Github(accessToken).pullRequests
.list("lloydmeta", "gh-test-repo", List(PRFilterOpen))
.execFuture[T](headerUserAgent)

testFutureIsRight[List[PullRequest]](response, { r =>
r.result.nonEmpty shouldBe true
r.statusCode shouldBe okStatusCode
})
}

it should "return a non empty list when valid repo and some filters are provided" in {
val response =
Github(accessToken).pullRequests
Expand Down Expand Up @@ -73,7 +85,7 @@ trait GHPullRequestsSpec[T] extends BaseIntegrationSpec[T] {

"PullRequests >> ListFiles" should "return a right response when a valid repo is provided and not all files have 'patch'" in {
val response =
Github(None).pullRequests
Github(accessToken).pullRequests
.listFiles("scala", "scala", 4877)
.execFuture[T](headerUserAgent)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ trait TestData extends DummyGithubUrls {
number = validPullRequestNumber,
state = "open",
title = "Title",
body = "Body",
body = Some("Body"),
locked = false,
html_url = githubApiUrl,
created_at = "2011-04-10T20:09:31Z",
Expand Down

0 comments on commit 8db7bd4

Please sign in to comment.