Skip to content

Commit

Permalink
Merge pull request #787 from octokit/release-candidate
Browse files Browse the repository at this point in the history
release candidate
  • Loading branch information
shiftkey committed Apr 22, 2015
2 parents 71cbe19 + ad268b2 commit e9918f8
Show file tree
Hide file tree
Showing 13 changed files with 35 additions and 190 deletions.
12 changes: 0 additions & 12 deletions Octokit.Reactive/Clients/IObservableRepositoriesClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,18 +50,6 @@ public interface IObservableRepositoriesClient
Justification = "Makes a network request")]
IObservable<Repository> GetAllPublic();

/// <summary>
/// Retrieves every public <see cref="Repository"/> since the last repository seen.
/// </summary>
/// <remarks>
/// The default page size on GitHub.com is 30.
/// </remarks>
/// <param name="request">Search parameters of the last repository seen</param>
/// <returns>A <see cref="IReadOnlyPagedCollection{Repository}"/> of <see cref="Repository"/>.</returns>
[SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate",
Justification = "Makes a network request")]
IObservable<Repository> GetAllPublic(PublicRepositoryRequest request);

/// <summary>
/// Retrieves every <see cref="Repository"/> that belongs to the current user.
/// </summary>
Expand Down
15 changes: 0 additions & 15 deletions Octokit.Reactive/Clients/ObservableRepositoriesClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,21 +102,6 @@ public IObservable<Repository> GetAllPublic()
return _connection.GetAndFlattenAllPages<Repository>(ApiUrls.AllPublicRepositories());
}

/// <summary>
/// Retrieves every public <see cref="Repository"/> since the last repository seen.
/// </summary>
/// <remarks>
/// The default page size on GitHub.com is 30.
/// </remarks>
/// <param name="request">Search parameters of the last repository seen</param>
/// <returns>A <see cref="IReadOnlyPagedCollection{Repository}"/> of <see cref="Repository"/>.</returns>
public IObservable<Repository> GetAllPublic(PublicRepositoryRequest request)
{
Ensure.ArgumentNotNull(request, "request");

return _connection.GetAndFlattenAllPages<Repository>(ApiUrls.AllPublicRepositories(), request.ToParametersDictionary());
}

/// <summary>
/// Retrieves every <see cref="Repository"/> that belongs to the current user.
/// </summary>
Expand Down
8 changes: 4 additions & 4 deletions Octokit.Tests.Integration/Clients/EventsClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public void AllEventsHavePayloads()
Assert.True(_events.All(e => e.Payload != null));
}

[IntegrationTest]
[IntegrationTest(Skip = "no longer able to access this event")]
public void IssueCommentPayloadEventDeserializesCorrectly()
{
var commentEvent = _events.FirstOrDefault(e => e.Id == "2628548686");
Expand All @@ -49,7 +49,7 @@ public void IssueCommentPayloadEventDeserializesCorrectly()
Assert.Equal(742, commentPayload.Issue.Number);
}

[IntegrationTest]
[IntegrationTest(Skip = "no longer able to access this event")]
public void PushEventPayloadDeserializesCorrectly()
{
var pushEvent = _events.FirstOrDefault(e => e.Id == "2628858765");
Expand All @@ -65,7 +65,7 @@ public void PushEventPayloadDeserializesCorrectly()
Assert.Equal(1, pushPayload.Size);
}

[IntegrationTest]
[IntegrationTest(Skip = "no longer able to access this event")]
public void PREventPayloadDeserializesCorrectly()
{
var prEvent = _events.FirstOrDefault(e => e.Id == "2628718313");
Expand All @@ -79,7 +79,7 @@ public void PREventPayloadDeserializesCorrectly()
Assert.Equal(743, prPayload.PullRequest.Number);
}

[IntegrationTest]
[IntegrationTest(Skip = "no longer able to access this event")]
public void PRReviewCommentEventPayloadDeserializesCorrectly()
{
var prrcEvent = _events.First(e => e.Id == "2623246246");
Expand Down
28 changes: 14 additions & 14 deletions Octokit.Tests.Integration/Clients/RepositoriesClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -553,20 +553,20 @@ public async Task ReturnsAllPublicRepositories()
Assert.True(repositories.Count > 80);
}

[IntegrationTest]
public async Task ReturnsAllPublicRepositoriesSinceLastSeen()
{
var github = Helper.GetAuthenticatedClient();

var request = new PublicRepositoryRequest(32732250);
var repositories = await github.Repository.GetAllPublic(request);

Assert.NotNull(repositories);
Assert.True(repositories.Any());
Assert.Equal(32732252, repositories[0].Id);
Assert.False(repositories[0].Private);
Assert.Equal("zad19", repositories[0].Name);
}
//[IntegrationTest]
//public async Task ReturnsAllPublicRepositoriesSinceLastSeen()
//{
// var github = Helper.GetAuthenticatedClient();

// var request = new PublicRepositoryRequest(32732250);
// var repositories = await github.Repository.GetAllPublic(request);

// Assert.NotNull(repositories);
// Assert.True(repositories.Any());
// Assert.Equal(32732252, repositories[0].Id);
// Assert.False(repositories[0].Private);
// Assert.Equal("zad19", repositories[0].Name);
//}
}

public class TheGetAllForOrgMethod
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,22 +28,5 @@ public async Task ReturnsSpecifiedRepository()
Assert.False(repository2.Fork);
}
}

public class TheGetAllPublicSinceMethod
{
[IntegrationTest(Skip = "This will take a very long time to return, so will skip it for now.")]
public async Task ReturnsAllPublicReposSinceLastSeen()
{
var github = Helper.GetAuthenticatedClient();

var client = new ObservableRepositoriesClient(github);
var request = new PublicRepositoryRequest(32732250);
var repositories = await client.GetAllPublic(request).ToArray();
Assert.NotEmpty(repositories);
Assert.Equal(32732252, repositories[0].Id);
Assert.False(repositories[0].Private);
Assert.Equal("zad19", repositories[0].Name);
}
}
}
}
4 changes: 2 additions & 2 deletions Octokit.Tests/Clients/AuthorizationsClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public void GetsOrCreatesAuthenticationAtCorrectUrl()

authEndpoint.GetOrCreateApplicationAuthentication("clientId", "secret", data);

client.Received().Post<ApplicationAuthorization>(Arg.Is<Uri>(u => u.ToString() == "authorizations/clients/clientId"),
client.Received().Put<ApplicationAuthorization>(Arg.Is<Uri>(u => u.ToString() == "authorizations/clients/clientId"),
Args.Object);
}

Expand Down Expand Up @@ -235,7 +235,7 @@ public async Task GetsOrCreatesAuthenticationWithFingerprintAtCorrectUrl()

authEndpoint.GetOrCreateApplicationAuthentication("clientId", "secret", data);

client.Received().Post<ApplicationAuthorization>(Arg.Is<Uri>(u => u.ToString() == "authorizations/clients/clientId/ha-ha-fingerprint"),
client.Received().Put<ApplicationAuthorization>(Arg.Is<Uri>(u => u.ToString() == "authorizations/clients/clientId/ha-ha-fingerprint"),
Args.Object);
}
}
Expand Down
31 changes: 0 additions & 31 deletions Octokit.Tests/Clients/RepositoriesClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -273,37 +273,6 @@ public void RequestsTheCorrectUrlAndReturnsRepositories()
}
}


public class TheGetAllPublicSinceMethod
{
[Fact]
public void RequestsTheCorrectUrl()
{
var connection = Substitute.For<IApiConnection>();
var client = new RepositoriesClient(connection);

client.GetAllPublic(new PublicRepositoryRequest(364));

connection.Received()
.GetAll<Repository>(Arg.Is<Uri>(u => u.ToString() == "/repositories"),
Arg.Any<Dictionary<string, string>>());
}

[Fact]
public void SendsTheCorrectParameter()
{
var connection = Substitute.For<IApiConnection>();
var client = new RepositoriesClient(connection);

client.GetAllPublic(new PublicRepositoryRequest(364));

connection.Received()
.GetAll<Repository>(Arg.Is<Uri>(u => u.ToString() == "/repositories"),
Arg.Is<Dictionary<string, string>>(d => d.Count == 1
&& d["since"] == "364"));
}
}

public class TheGetAllForCurrentMethod
{
[Fact]
Expand Down
59 changes: 0 additions & 59 deletions Octokit.Tests/Reactive/ObservableRepositoriesClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -158,65 +158,6 @@ public async Task StopsMakingNewRequestsWhenTakeIsFulfilled()
}
}

public class TheGetAllPublicRepositoriesSinceMethod
{
[Fact]
public async Task ReturnsEveryPageOfRepositories()
{
var firstPageUrl = new Uri("/repositories", UriKind.Relative);
var secondPageUrl = new Uri("https://example.com/page/2");
var firstPageLinks = new Dictionary<string, Uri> { { "next", secondPageUrl } };
IApiResponse<List<Repository>> firstPageResponse = new ApiResponse<List<Repository>>(
CreateResponseWithApiInfo(firstPageLinks),
new List<Repository>
{
new Repository(364),
new Repository(365),
new Repository(366)
});

var thirdPageUrl = new Uri("https://example.com/page/3");
var secondPageLinks = new Dictionary<string, Uri> { { "next", thirdPageUrl } };
IApiResponse<List<Repository>> secondPageResponse = new ApiResponse<List<Repository>>
(
CreateResponseWithApiInfo(secondPageLinks),
new List<Repository>
{
new Repository(367),
new Repository(368),
new Repository(369)
});

IApiResponse<List<Repository>> lastPageResponse = new ApiResponse<List<Repository>>(
new Response(),
new List<Repository>
{
new Repository(370)
});

var gitHubClient = Substitute.For<IGitHubClient>();
gitHubClient.Connection.Get<List<Repository>>(firstPageUrl,
Arg.Is<Dictionary<string, string>>(d => d.Count == 1
&& d["since"] == "364"), null)
.Returns(Task.FromResult(firstPageResponse));
gitHubClient.Connection.Get<List<Repository>>(secondPageUrl, null, null)
.Returns(Task.FromResult(secondPageResponse));
gitHubClient.Connection.Get<List<Repository>>(thirdPageUrl, null, null)
.Returns(Task.FromResult(lastPageResponse));

var repositoriesClient = new ObservableRepositoriesClient(gitHubClient);

var results = await repositoriesClient.GetAllPublic(new PublicRepositoryRequest(364)).ToArray();

Assert.Equal(7, results.Length);
gitHubClient.Connection.Received(1).Get<List<Repository>>(firstPageUrl,
Arg.Is<Dictionary<string, string>>(d=>d.Count == 1
&& d["since"] == "364"), null);
gitHubClient.Connection.Received(1).Get<List<Repository>>(secondPageUrl, null, null);
gitHubClient.Connection.Received(1).Get<List<Repository>>(thirdPageUrl, null, null);
}
}

public class TheGetAllBranchesMethod
{
[Fact]
Expand Down
14 changes: 0 additions & 14 deletions Octokit/Clients/IRepositoriesClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,20 +109,6 @@ public interface IRepositoriesClient
Justification = "Makes a network request")]
Task<IReadOnlyList<Repository>> GetAllPublic();


/// <summary>
/// Gets all public repositories since the integer ID of the last Repository that you've seen.
/// </summary>
/// <remarks>
/// See the <a href="https://developer.github.com/v3/repos/#list-all-public-repositories">API documentation</a> for more information.
/// The default page size on GitHub.com is 30.
/// </remarks>
/// <param name="request">Search parameters of the last repository seen</param>
/// <exception cref="AuthorizationException">Thrown if the client is not authenticated.</exception>
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
/// <returns>A <see cref="IReadOnlyPagedCollection{Repository}"/> of <see cref="Repository"/>.</returns>
Task<IReadOnlyList<Repository>> GetAllPublic(PublicRepositoryRequest request);

/// <summary>
/// Gets all repositories owned by the current user.
/// </summary>
Expand Down
18 changes: 0 additions & 18 deletions Octokit/Clients/RepositoriesClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -188,24 +188,6 @@ public Task<IReadOnlyList<Repository>> GetAllPublic()
return ApiConnection.GetAll<Repository>(ApiUrls.AllPublicRepositories());
}

/// <summary>
/// Gets all public repositories since the integer ID of the last Repository that you've seen.
/// </summary>
/// <remarks>
/// See the <a href="https://developer.github.com/v3/repos/#list-all-public-repositories">API documentation</a> for more information.
/// The default page size on GitHub.com is 30.
/// </remarks>
/// <param name="request">Search parameters of the last repository seen</param>
/// <exception cref="AuthorizationException">Thrown if the client is not authenticated.</exception>
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
/// <returns>A <see cref="IReadOnlyPagedCollection{Repository}"/> of <see cref="Repository"/>.</returns>
public Task<IReadOnlyList<Repository>> GetAllPublic(PublicRepositoryRequest request)
{
Ensure.ArgumentNotNull(request, "request");

return ApiConnection.GetAll<Repository>(ApiUrls.AllPublicRepositories(), request.ToParametersDictionary());
}

/// <summary>
/// Gets all repositories owned by the current user.
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion Octokit/Models/Response/CommitComment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public CommitComment(int id, Uri url, Uri htmlUrl, string body, string path, int
/// <summary>
/// Line index in the diff that was commented on.
/// </summary>
public int Position { get; protected set; }
public int? Position { get; protected set; }

/// <summary>
/// The line number in the file that was commented on.
Expand Down
11 changes: 11 additions & 0 deletions ReleaseNotes.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
### New in 0.10.0 (released 2015/04/22)
* Fixed: renamed methods to follow `GetAll` convention - #771 via @alfhenrik
* Fixed: helper functions and cleanup to make using Authorization API easier to consume - #786 via @haacked

**Breaking Changes:**
- As part of #771 there were many method which were returning collections
but the method name made it unclear. You might think that it wasn't much, but
you'd be wrong. So if you have a method that no longer compile,
it is likely that you need to set the prefix to `GetAll` to re-disocver that API.
- `CommitComment.Position` is now a nullable `int` to prevent serialization issues.

### New in 0.9.0 (released 2015/04/04)
* New: added `PullRequest.Files` APIs - #752 via @alfhenrik
* Fixed: `PullRequestRequest` now supports `SortDirection` and `SortProperty` - #752 via @alfhenrik
Expand Down
6 changes: 3 additions & 3 deletions SolutionInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
using System.Runtime.InteropServices;

[assembly: AssemblyProductAttribute("Octokit")]
[assembly: AssemblyVersionAttribute("0.9.0")]
[assembly: AssemblyFileVersionAttribute("0.9.0")]
[assembly: AssemblyVersionAttribute("0.10.0")]
[assembly: AssemblyFileVersionAttribute("0.10.0")]
[assembly: ComVisibleAttribute(false)]
namespace System {
internal static class AssemblyVersionInformation {
internal const string Version = "0.9.0";
internal const string Version = "0.10.0";
}
}

0 comments on commit e9918f8

Please sign in to comment.