Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds PullRequestReviewEventPayload #1767

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 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,44 @@ 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);
A
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this aint gonna work 😝

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; }
}
}