mirror of
https://github.com/zoriya/octokit.net.git
synced 2026-06-03 03:01:31 +00:00
Add support for creating project cards from PRs (#2185)
This commit is contained in:
@@ -202,9 +202,8 @@ public class ProjectCardsClientTests
|
||||
public TheCreateMethod()
|
||||
{
|
||||
_github = Helper.GetAuthenticatedClient();
|
||||
var repoName = Helper.MakeNameWithTimestamp("public-repo");
|
||||
|
||||
_context = _github.CreateRepositoryContext(new NewRepository(repoName)).Result;
|
||||
_context = _github.CreateRepositoryContext("public-repo").Result;
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
@@ -228,6 +227,22 @@ public class ProjectCardsClientTests
|
||||
Assert.NotNull(card);
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task CreatesPullRequestCard()
|
||||
{
|
||||
await _github.CreateTheWorld(_context.Repository);
|
||||
|
||||
var project = await CreateRepositoryProjectHelper(_github, _context.RepositoryId);
|
||||
|
||||
var pullRequest = await _github.CreatePullRequest(_context.Repository);
|
||||
|
||||
var column = await CreateColumnHelper(_github, project.Id);
|
||||
|
||||
var card = await CreatePullRequestCardHelper(_github, pullRequest.Id, column.Id);
|
||||
|
||||
Assert.NotNull(card);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
if (_context != null)
|
||||
@@ -445,5 +460,13 @@ public class ProjectCardsClientTests
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private static async Task<ProjectCard> CreatePullRequestCardHelper(IGitHubClient githubClient, long pullRequestId, int columnId)
|
||||
{
|
||||
var newCard = new NewProjectCard(pullRequestId, ProjectCardContentType.PullRequest);
|
||||
var result = await githubClient.Repository.Project.Card.Create(columnId, newCard);
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace Octokit
|
||||
Note = note;
|
||||
}
|
||||
|
||||
public NewProjectCard(int contentId, ProjectCardContentType contentType)
|
||||
public NewProjectCard(long contentId, ProjectCardContentType contentType)
|
||||
{
|
||||
ContentId = contentId;
|
||||
ContentType = contentType;
|
||||
@@ -27,7 +27,7 @@ namespace Octokit
|
||||
/// The id of the Issue or Pull Request to associate with this card.
|
||||
/// </summary>
|
||||
[Parameter(Key = "content_id")]
|
||||
public int? ContentId { get; protected set; }
|
||||
public long? ContentId { get; protected set; }
|
||||
|
||||
/// <summary>
|
||||
/// The type of content to associate with this card.
|
||||
@@ -46,7 +46,9 @@ namespace Octokit
|
||||
|
||||
public enum ProjectCardContentType
|
||||
{
|
||||
[Parameter(Value = "Issue")]
|
||||
Issue
|
||||
[Parameter(Value = nameof(Issue))]
|
||||
Issue,
|
||||
[Parameter(Value = nameof(PullRequest))]
|
||||
PullRequest
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user