From 9705b4272bd2a28b5118abfbe42fcc2498bf83b0 Mon Sep 17 00:00:00 2001 From: Brendan Forster Date: Sat, 8 Mar 2014 12:14:20 +1100 Subject: [PATCH] added support for searching by mentions --- .../Clients/IssuesClientTests.cs | 25 +++++++++++++++++++ .../Models/Request/RepositoryIssueRequest.cs | 5 ++++ 2 files changed, 30 insertions(+) diff --git a/Octokit.Tests.Integration/Clients/IssuesClientTests.cs b/Octokit.Tests.Integration/Clients/IssuesClientTests.cs index ad02ff1b..41e2016d 100644 --- a/Octokit.Tests.Integration/Clients/IssuesClientTests.cs +++ b/Octokit.Tests.Integration/Clients/IssuesClientTests.cs @@ -212,6 +212,31 @@ public class IssuesClientTests : IDisposable Assert.Equal(0, issuesCreatedByExternalUser.Count); } + [IntegrationTest] + public async Task CanFilterByMentioned() + { + var owner = _repository.Owner.Login; + var newIssue1 = new NewIssue("An issue") { Body = "words words words hello there @shiftkey" }; + var newIssue2 = new NewIssue("Another issue") { Body = "some other words" }; + await _issuesClient.Create(owner, _repository.Name, newIssue1); + await _issuesClient.Create(owner, _repository.Name, newIssue2); + + var allIssues = await _issuesClient.GetForRepository(owner, _repository.Name, + new RepositoryIssueRequest()); + + Assert.Equal(2, allIssues.Count); + + var mentionsWithShiftkey = await _issuesClient.GetForRepository(owner, _repository.Name, + new RepositoryIssueRequest { Mentioned = "shiftkey" }); + + Assert.Equal(1, mentionsWithShiftkey.Count); + + var mentionsWithHaacked = await _issuesClient.GetForRepository(owner, _repository.Name, + new RepositoryIssueRequest { Mentioned = "haacked" }); + + Assert.Equal(0, mentionsWithHaacked.Count); + } + [IntegrationTest] public async Task FilteringByInvalidAccountThrowsError() { diff --git a/Octokit/Models/Request/RepositoryIssueRequest.cs b/Octokit/Models/Request/RepositoryIssueRequest.cs index e1008e02..f125afd4 100644 --- a/Octokit/Models/Request/RepositoryIssueRequest.cs +++ b/Octokit/Models/Request/RepositoryIssueRequest.cs @@ -26,5 +26,10 @@ namespace Octokit /// Specify "none" for issues with no assigned user /// public string Creator { get; set; } + + /// + /// A user that’s mentioned in the issue + /// + public string Mentioned { get; set; } } }