Skip to content

Commit

Permalink
Adds PullRequestReviewEventPayload (#1767)
Browse files Browse the repository at this point in the history
* Adds PullRequestReviewEventPayload

* Remove random A
  • Loading branch information
Cyberboss authored and ryangribble committed Feb 25, 2018
1 parent e430a9e commit 3ec01bd
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 0 deletions.
38 changes: 38 additions & 0 deletions Octokit.Tests/Clients/EventsClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -558,6 +558,7 @@ public async Task EnsuresNonNullArguments()
{"IssueCommentEvent", typeof(IssueCommentPayload)},
{"IssuesEvent", typeof(IssueEventPayload)},
{"PullRequestEvent", typeof(PullRequestEventPayload)},
{"PullRequestReviewEvent", typeof(PullRequestReviewEventPayload)},
{"PullRequestReviewCommentEvent", typeof(PullRequestCommentPayload)},
{"PushEvent", typeof(PushEventPayload)},
{"StatusEvent", typeof(StatusEventPayload)},
Expand Down Expand Up @@ -743,6 +744,43 @@ public async Task DeserializesPullRequestEventCorrectly()
Assert.Equal("PR Title", payload.PullRequest.Title);
}

[Fact]
public async Task DeserializesPullRequestReviewEventCorrectly()
{
var jsonObj = new JsonObject
{
{ "type", "PullRequestReviewEvent" },
{
"payload", new
{
action = "submitted",
review = new {
id = 2626884,
body = "Looks great!",
state = "approved",
html_url = "https://github.com/baxterthehacker/public-repo/pull/8#pullrequestreview-2626884",
},
pull_request = new
{
title = "PR Title"
}
}
}
};

var client = GetTestingEventsClient(jsonObj);
var activities = await client.GetAll();
Assert.Equal(1, activities.Count);

var payload = activities.FirstOrDefault().Payload as PullRequestReviewEventPayload;
Assert.Equal("submitted", payload.Action);
Assert.Equal(2626884, payload.Review.Id);
Assert.Equal("Looks great!", payload.Review.Body);
Assert.Equal(PullRequestReviewState.Approved, payload.Review.State.Value);
Assert.Equal("https://github.com/baxterthehacker/public-repo/pull/8#pullrequestreview-2626884", payload.Review.HtmlUrl);
Assert.Equal("PR Title", payload.PullRequest.Title);
}

[Fact]
public async Task DeserializesPullRequestCommentEventCorrectly()
{
Expand Down
2 changes: 2 additions & 0 deletions Octokit/Http/SimpleJsonSerializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,8 @@ private static Type GetPayloadType(string activityType)
return typeof(IssueEventPayload);
case "PullRequestEvent":
return typeof(PullRequestEventPayload);
case "PullRequestReviewEvent":
return typeof(PullRequestReviewEventPayload);
case "PullRequestReviewCommentEvent":
return typeof(PullRequestCommentPayload);
case "PushEvent":
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using System.Diagnostics;

namespace Octokit
{
[DebuggerDisplay("{DebuggerDisplay,nq}")]
public class PullRequestReviewEventPayload : ActivityPayload
{
public string Action { get; protected set; }
public PullRequest PullRequest { get; protected set; }
public PullRequestReview Review { get; protected set; }
}
}

0 comments on commit 3ec01bd

Please sign in to comment.