Skip to content

Commit

Permalink
Update observable pull requests client and tests to use draft PR acce…
Browse files Browse the repository at this point in the history
…pt header
  • Loading branch information
hnrkndrssn committed Sep 21, 2019
1 parent 9a0b8e6 commit d4b71e8
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
8 changes: 4 additions & 4 deletions Octokit.Reactive/Clients/ObservablePullRequestsClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public IObservable<PullRequest> GetAllForRepository(string owner, string name, A
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
Ensure.ArgumentNotNull(options, nameof(options));

return _connection.GetAndFlattenAllPages<PullRequest>(ApiUrls.PullRequests(owner, name), options);
return _connection.GetAndFlattenAllPages<PullRequest>(ApiUrls.PullRequests(owner, name), null, AcceptHeaders.DraftPullRequestApiPreview, options);
}

/// <summary>
Expand All @@ -126,7 +126,7 @@ public IObservable<PullRequest> GetAllForRepository(long repositoryId, ApiOption
{
Ensure.ArgumentNotNull(options, nameof(options));

return _connection.GetAndFlattenAllPages<PullRequest>(ApiUrls.PullRequests(repositoryId), options);
return _connection.GetAndFlattenAllPages<PullRequest>(ApiUrls.PullRequests(repositoryId), null, AcceptHeaders.DraftPullRequestApiPreview, options);
}

/// <summary>
Expand Down Expand Up @@ -180,7 +180,7 @@ public IObservable<PullRequest> GetAllForRepository(string owner, string name, P
Ensure.ArgumentNotNull(options, nameof(options));

return _connection.GetAndFlattenAllPages<PullRequest>(ApiUrls.PullRequests(owner, name),
request.ToParametersDictionary(), options);
request.ToParametersDictionary(), AcceptHeaders.DraftPullRequestApiPreview, options);
}

/// <summary>
Expand All @@ -198,7 +198,7 @@ public IObservable<PullRequest> GetAllForRepository(long repositoryId, PullReque
Ensure.ArgumentNotNull(options, nameof(options));

return _connection.GetAndFlattenAllPages<PullRequest>(ApiUrls.PullRequests(repositoryId),
request.ToParametersDictionary(), options);
request.ToParametersDictionary(), AcceptHeaders.DraftPullRequestApiPreview, options);
}

/// <summary>
Expand Down
24 changes: 12 additions & 12 deletions Octokit.Tests/Reactive/ObservablePullRequestsClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -209,11 +209,11 @@ public async Task ReturnsEveryPageOfPullRequests()
}
);
var gitHubClient = Substitute.For<IGitHubClient>();
gitHubClient.Connection.Get<List<PullRequest>>(firstPageUrl, Args.EmptyDictionary, null)
gitHubClient.Connection.Get<List<PullRequest>>(firstPageUrl, Args.EmptyDictionary, "application/vnd.github.shadow-cat-preview+json")
.Returns(Task.Factory.StartNew<IApiResponse<List<PullRequest>>>(() => firstPageResponse));
gitHubClient.Connection.Get<List<PullRequest>>(secondPageUrl, Args.EmptyDictionary, null)
gitHubClient.Connection.Get<List<PullRequest>>(secondPageUrl, Args.EmptyDictionary, "application/vnd.github.shadow-cat-preview+json")
.Returns(Task.Factory.StartNew<IApiResponse<List<PullRequest>>>(() => secondPageResponse));
gitHubClient.Connection.Get<List<PullRequest>>(thirdPageUrl, Args.EmptyDictionary, null)
gitHubClient.Connection.Get<List<PullRequest>>(thirdPageUrl, Args.EmptyDictionary, "application/vnd.github.shadow-cat-preview+json")
.Returns(Task.Factory.StartNew<IApiResponse<List<PullRequest>>>(() => lastPageResponse));
var client = new ObservablePullRequestsClient(gitHubClient);

Expand Down Expand Up @@ -262,11 +262,11 @@ public async Task ReturnsEveryPageOfPullRequestsWithRepositoryId()
}
);
var gitHubClient = Substitute.For<IGitHubClient>();
gitHubClient.Connection.Get<List<PullRequest>>(firstPageUrl, Args.EmptyDictionary, null)
gitHubClient.Connection.Get<List<PullRequest>>(firstPageUrl, Args.EmptyDictionary, "application/vnd.github.shadow-cat-preview+json")
.Returns(Task.Factory.StartNew<IApiResponse<List<PullRequest>>>(() => firstPageResponse));
gitHubClient.Connection.Get<List<PullRequest>>(secondPageUrl, Args.EmptyDictionary, null)
gitHubClient.Connection.Get<List<PullRequest>>(secondPageUrl, Args.EmptyDictionary, "application/vnd.github.shadow-cat-preview+json")
.Returns(Task.Factory.StartNew<IApiResponse<List<PullRequest>>>(() => secondPageResponse));
gitHubClient.Connection.Get<List<PullRequest>>(thirdPageUrl, Args.EmptyDictionary, null)
gitHubClient.Connection.Get<List<PullRequest>>(thirdPageUrl, Args.EmptyDictionary, "application/vnd.github.shadow-cat-preview+json")
.Returns(Task.Factory.StartNew<IApiResponse<List<PullRequest>>>(() => lastPageResponse));
var client = new ObservablePullRequestsClient(gitHubClient);

Expand Down Expand Up @@ -321,21 +321,21 @@ public async Task SendsAppropriateParametersMulti()
&& d["state"] == "open"
&& d["base"] == "fake_base_branch"
&& d["sort"] == "created"
&& d["direction"] == "desc"), Arg.Any<string>())
&& d["direction"] == "desc"), "application/vnd.github.shadow-cat-preview+json")
.Returns(Task.Factory.StartNew<IApiResponse<List<PullRequest>>>(() => firstPageResponse));
gitHubClient.Connection.Get<List<PullRequest>>(secondPageUrl, Arg.Is<Dictionary<string, string>>(d => d.Count == 5
&& d["head"] == "user:ref-name"
&& d["state"] == "open"
&& d["base"] == "fake_base_branch"
&& d["sort"] == "created"
&& d["direction"] == "desc"), null)
&& d["direction"] == "desc"), "application/vnd.github.shadow-cat-preview+json")
.Returns(Task.Factory.StartNew<IApiResponse<List<PullRequest>>>(() => secondPageResponse));
gitHubClient.Connection.Get<List<PullRequest>>(thirdPageUrl, Arg.Is<Dictionary<string, string>>(d => d.Count == 5
&& d["head"] == "user:ref-name"
&& d["state"] == "open"
&& d["base"] == "fake_base_branch"
&& d["sort"] == "created"
&& d["direction"] == "desc"), null)
&& d["direction"] == "desc"), "application/vnd.github.shadow-cat-preview+json")
.Returns(Task.Factory.StartNew<IApiResponse<List<PullRequest>>>(() => lastPageResponse));
var client = new ObservablePullRequestsClient(gitHubClient);

Expand Down Expand Up @@ -390,21 +390,21 @@ public async Task SendsAppropriateParametersMultiWithRepositoryId()
&& d["state"] == "open"
&& d["base"] == "fake_base_branch"
&& d["sort"] == "created"
&& d["direction"] == "desc"), Arg.Any<string>())
&& d["direction"] == "desc"), "application/vnd.github.shadow-cat-preview+json")
.Returns(Task.Factory.StartNew<IApiResponse<List<PullRequest>>>(() => firstPageResponse));
gitHubClient.Connection.Get<List<PullRequest>>(secondPageUrl, Arg.Is<Dictionary<string, string>>(d => d.Count == 5
&& d["head"] == "user:ref-name"
&& d["state"] == "open"
&& d["base"] == "fake_base_branch"
&& d["sort"] == "created"
&& d["direction"] == "desc"), null)
&& d["direction"] == "desc"), "application/vnd.github.shadow-cat-preview+json")
.Returns(Task.Factory.StartNew<IApiResponse<List<PullRequest>>>(() => secondPageResponse));
gitHubClient.Connection.Get<List<PullRequest>>(thirdPageUrl, Arg.Is<Dictionary<string, string>>(d => d.Count == 5
&& d["head"] == "user:ref-name"
&& d["state"] == "open"
&& d["base"] == "fake_base_branch"
&& d["sort"] == "created"
&& d["direction"] == "desc"), null)
&& d["direction"] == "desc"), "application/vnd.github.shadow-cat-preview+json")
.Returns(Task.Factory.StartNew<IApiResponse<List<PullRequest>>>(() => lastPageResponse));
var client = new ObservablePullRequestsClient(gitHubClient);

Expand Down

0 comments on commit d4b71e8

Please sign in to comment.