diff --git a/Octokit.Tests.Integration/Clients/IssuesClientTests.cs b/Octokit.Tests.Integration/Clients/IssuesClientTests.cs index f930d322..73284093 100644 --- a/Octokit.Tests.Integration/Clients/IssuesClientTests.cs +++ b/Octokit.Tests.Integration/Clients/IssuesClientTests.cs @@ -22,6 +22,22 @@ public class IssuesClientTests : IDisposable _context = github.CreateRepositoryContext(new NewRepository(repoName)).Result; } + [IntegrationTest] + public async Task CanDeserializeIssue() + { + const string title = "a test issue"; + const string description = "A new unassigned issue"; + var newIssue = new NewIssue(title) { Body = description }; + var issue = await _issuesClient.Create(_context.RepositoryOwner, _context.RepositoryName, newIssue); + var retrieved = await _issuesClient.Get(_context.RepositoryOwner, _context.RepositoryName, issue.Number); + + Assert.NotNull(retrieved); + Assert.NotEqual(0, issue.Id); + Assert.Equal(false, issue.Locked); + Assert.Equal(title, retrieved.Title); + Assert.Equal(description, retrieved.Body); + } + [IntegrationTest] public async Task CanCreateRetrieveAndCloseIssue() { diff --git a/Octokit.Tests.Integration/Clients/IssuesEventsClientTests.cs b/Octokit.Tests.Integration/Clients/IssuesEventsClientTests.cs index 68c3c2f6..61f9c919 100644 --- a/Octokit.Tests.Integration/Clients/IssuesEventsClientTests.cs +++ b/Octokit.Tests.Integration/Clients/IssuesEventsClientTests.cs @@ -9,7 +9,7 @@ using Octokit.Tests.Integration.Helpers; public class IssuesEventsClientTests : IDisposable { - private readonly IIssuesEventsClient _issuesEventsClientClient; + private readonly IIssuesEventsClient _issuesEventsClient; private readonly IIssuesClient _issuesClient; private readonly RepositoryContext _context; @@ -17,7 +17,7 @@ public class IssuesEventsClientTests : IDisposable { var github = Helper.GetAuthenticatedClient(); - _issuesEventsClientClient = github.Issue.Events; + _issuesEventsClient = github.Issue.Events; _issuesClient = github.Issue; var repoName = Helper.MakeNameWithTimestamp("public-repo"); @@ -30,13 +30,13 @@ public class IssuesEventsClientTests : IDisposable var newIssue = new NewIssue("a test issue") { Body = "A new unassigned issue" }; var issue = await _issuesClient.Create(_context.RepositoryOwner, _context.RepositoryName, newIssue); - var issueEventInfo = await _issuesEventsClientClient.GetAllForIssue(_context.RepositoryOwner, _context.RepositoryName, issue.Number); + var issueEventInfo = await _issuesEventsClient.GetAllForIssue(_context.RepositoryOwner, _context.RepositoryName, issue.Number); Assert.Empty(issueEventInfo); var closed = _issuesClient.Update(_context.RepositoryOwner, _context.RepositoryName, issue.Number, new IssueUpdate { State = ItemState.Closed }) .Result; Assert.NotNull(closed); - issueEventInfo = await _issuesEventsClientClient.GetAllForIssue(_context.RepositoryOwner, _context.RepositoryName, issue.Number); + issueEventInfo = await _issuesEventsClient.GetAllForIssue(_context.RepositoryOwner, _context.RepositoryName, issue.Number); Assert.Equal(1, issueEventInfo.Count); Assert.Equal(EventInfoState.Closed, issueEventInfo[0].Event); @@ -67,7 +67,7 @@ public class IssuesEventsClientTests : IDisposable .Result; Assert.NotNull(closed2); - var issueEvents = await _issuesEventsClientClient.GetAllForRepository(_context.RepositoryOwner, _context.RepositoryName); + var issueEvents = await _issuesEventsClient.GetAllForRepository(_context.RepositoryOwner, _context.RepositoryName); Assert.Equal(3, issueEvents.Count); Assert.Equal(2, issueEvents.Count(issueEvent => issueEvent.Issue.Body == "Everything's coming up Millhouse")); @@ -81,10 +81,10 @@ public class IssuesEventsClientTests : IDisposable var closed = _issuesClient.Update(_context.RepositoryOwner, _context.RepositoryName, issue.Number, new IssueUpdate { State = ItemState.Closed }) .Result; Assert.NotNull(closed); - var issueEvents = await _issuesEventsClientClient.GetAllForRepository(_context.RepositoryOwner, _context.RepositoryName); + var issueEvents = await _issuesEventsClient.GetAllForRepository(_context.RepositoryOwner, _context.RepositoryName); int issueEventId = issueEvents[0].Id; - var issueEventLookupById = await _issuesEventsClientClient.Get(_context.RepositoryOwner, _context.RepositoryName, issueEventId); + var issueEventLookupById = await _issuesEventsClient.Get(_context.RepositoryOwner, _context.RepositoryName, issueEventId); Assert.Equal(issueEventId, issueEventLookupById.Id); Assert.Equal(issueEvents[0].Event, issueEventLookupById.Event); @@ -98,6 +98,17 @@ public class IssuesEventsClientTests : IDisposable Assert.Equal(EventInfoState.Unsubscribed, issue.Event); } + [IntegrationTest] + public async Task CanDeserializeMergedEvent() + { + var issueEvent = await _issuesEventsClient.Get("octokit", "octokit.net", 490490630); + + Assert.NotNull(issueEvent); + Assert.Equal(EventInfoState.Merged, issueEvent.Event); + Assert.Equal("0bb8747a0ad1a9efff201ea017a0a6a4f69b797e", issueEvent.CommitId); + Assert.Equal(new Uri("https://api.github.com/repos/octokit/octokit.net/commits/0bb8747a0ad1a9efff201ea017a0a6a4f69b797e"), issueEvent.CommitUrl); + } + public void Dispose() { _context.Dispose(); diff --git a/Octokit.Tests/Clients/EventsClientTests.cs b/Octokit.Tests/Clients/EventsClientTests.cs index e2cab605..57437d82 100644 --- a/Octokit.Tests/Clients/EventsClientTests.cs +++ b/Octokit.Tests/Clients/EventsClientTests.cs @@ -360,18 +360,18 @@ namespace Octokit.Tests.Clients { "payload", new { - action = "assigned", + action = "created", issue = new { - number = 1337 - }, - assignee = new - { - id = 1337 - }, - label = new - { - name = "bug" + number = 1337, + assignee = new + { + id = 1337 + }, + labels = new[] + { + new { name = "bug"} + } } } } @@ -382,10 +382,10 @@ namespace Octokit.Tests.Clients Assert.Equal(1, activities.Count); var payload = activities.FirstOrDefault().Payload as IssueEventPayload; - Assert.Equal("assigned", payload.Action); + Assert.Equal("created", payload.Action); Assert.Equal(1337, payload.Issue.Number); - Assert.Equal(1337, payload.Assignee.Id); - Assert.Equal("bug", payload.Label.Name); + Assert.Equal(1337, payload.Issue.Assignee.Id); + Assert.Equal("bug", payload.Issue.Labels.First().Name); } [Fact] diff --git a/Octokit/Clients/IssuesClient.cs b/Octokit/Clients/IssuesClient.cs index 2dbabc89..8b924245 100644 --- a/Octokit/Clients/IssuesClient.cs +++ b/Octokit/Clients/IssuesClient.cs @@ -208,10 +208,9 @@ namespace Octokit } /// - /// Creates an issue for the specified repository. Any user with pull access to a repository can create an - /// issue. + /// Updates an issue for the specified repository. Issue owners and users with push access can edit an issue. /// - /// http://developer.github.com/v3/issues/#create-an-issue + /// https://developer.github.com/v3/issues/#edit-an-issue /// The owner of the repository /// The name of the repository /// The issue number diff --git a/Octokit/Models/Response/ActivityPayloads/IssueEventPayload.cs b/Octokit/Models/Response/ActivityPayloads/IssueEventPayload.cs index 04f18177..1f40a122 100644 --- a/Octokit/Models/Response/ActivityPayloads/IssueEventPayload.cs +++ b/Octokit/Models/Response/ActivityPayloads/IssueEventPayload.cs @@ -7,7 +7,5 @@ namespace Octokit { public string Action { get; protected set; } public Issue Issue { get; protected set; } - public User Assignee { get; protected set; } - public Label Label { get; protected set; } } } diff --git a/Octokit/Models/Response/Issue.cs b/Octokit/Models/Response/Issue.cs index c676f111..e961fe7c 100644 --- a/Octokit/Models/Response/Issue.cs +++ b/Octokit/Models/Response/Issue.cs @@ -10,8 +10,9 @@ namespace Octokit { public Issue() { } - public Issue(Uri url, Uri htmlUrl, Uri commentsUrl, Uri eventsUrl, int number, ItemState state, string title, string body, User user, IReadOnlyList