Commit be9934d6 authored by Ben Boeckel's avatar Ben Boeckel Committed by Kitware Robot
Browse files

Merge topic 'add_merge_requests_closing'

561fc997

 api/projects: add issues/merge_requests_closing endpoint
Acked-by: Kitware Robot's avatarKitware Robot <kwrobot@kitware.com>
Acked-by: Ben Boeckel's avatarBen Boeckel <ben.boeckel@kitware.com>
Merge-request: !264
parents a04de1dc 561fc997
# v0.1302.1 (unreleased)
## Additions
- Added `api::projects::issues::MergeRequestsClosing` and `api::projects::issues::MergeRequestsClosing`
## Fixes
* GitLab 13.2 added the `approved` and `unapproved` merge request actions for
......
......@@ -31,6 +31,7 @@ These API endpoints have been implemented.
* `POST /projects/:project/issues` `projects/issues/create.rs`
* `GET /projects/:project/issues/:issue` `projects/issues/issue.rs`
* `PUT /projects/:project/issues/:issue` `projects/issues/edit.rs`
* `GET /projects/:project/issues/:issue/closed_by` `projects/issues/merge_requests_closing.rs`
* `GET /projects/:project/issues/:issue/notes` `projects/issues/notes/notes.rs`
* `POST /projects/:project/issues/:issue/notes` `projects/issues/notes/create.rs`
* `PUT /projects/:project/issues/:issue/notes/:note` `projects/issues/notes/edit.rs`
......@@ -189,7 +190,6 @@ instead of having to search the page for missing endpoints.
* `POST /projects/:project/issues/:issue/award_emoji` https://gitlab.kitware.com/help/api/award_emoji.md#award-a-new-emoji
* `GET /projects/:project/issues/:issue/award_emoji/:award` https://gitlab.kitware.com/help/api/award_emoji.md#get-single-award-emoji
* `DELETE /projects/:project/issues/:issue/award_emoji/:award` https://gitlab.kitware.com/help/api/award_emoji.md#delete-an-award-emoji
* `GET /projects/:project/issues/:issue/closed_by` https://gitlab.kitware.com/help/api/issues.md#list-merge-requests-that-will-close-issue-on-merge
* `GET /projects/:project/issues/:issue/discussions` https://gitlab.kitware.com/help/api/discussions.md#list-project-issue-discussion-items
* `POST /projects/:project/issues/:issue/discussions` https://gitlab.kitware.com/help/api/discussions.md#create-new-issue-thread
* `GET /projects/:project/issues/:issue/discussions/:discussion` https://gitlab.kitware.com/help/api/discussions.md#get-single-issue-discussion-item
......
......@@ -12,6 +12,7 @@ mod create;
mod edit;
mod issue;
mod issues;
mod merge_requests_closing;
pub mod notes;
mod resource_label_events;
......@@ -32,5 +33,8 @@ pub use self::issues::IssueWeight;
pub use self::issues::Issues;
pub use self::issues::IssuesBuilder;
pub use self::merge_requests_closing::MergeRequestsClosing;
pub use self::merge_requests_closing::MergeRequestsClosingBuilder;
pub use self::resource_label_events::IssueResourceLabelEvents;
pub use self::resource_label_events::IssueResourceLabelEventsBuilder;
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use derive_builder::Builder;
use crate::api::common::NameOrId;
use crate::api::endpoint_prelude::*;
/// Query for merge requests closing an issue
#[derive(Debug, Builder)]
pub struct MergeRequestsClosing<'a> {
/// The project to of the merge request.
#[builder(setter(into))]
project: NameOrId<'a>,
/// The ID of the issue
issue: u64,
}
impl<'a> MergeRequestsClosing<'a> {
/// Create a builder for the endpoint.
pub fn builder() -> MergeRequestsClosingBuilder<'a> {
MergeRequestsClosingBuilder::default()
}
}
impl<'a> Endpoint for MergeRequestsClosing<'a> {
fn method(&self) -> Method {
Method::GET
}
fn endpoint(&self) -> Cow<'static, str> {
format!("projects/{}/issues/{}/closed_by", self.project, self.issue).into()
}
}
impl<'a> Pageable for MergeRequestsClosing<'a> {}
#[cfg(test)]
mod tests {
use crate::api::projects::issues::MergeRequestsClosing;
use crate::api::{self, Query};
use crate::test::client::{ExpectedUrl, SingleTestClient};
#[test]
fn project_and_issue_are_needed() {
let err = MergeRequestsClosing::builder().build().unwrap_err();
assert_eq!(err, "`project` must be initialized");
}
#[test]
fn project_is_needed() {
let err = MergeRequestsClosing::builder()
.issue(1)
.build()
.unwrap_err();
assert_eq!(err, "`project` must be initialized");
}
#[test]
fn issue_is_needed() {
let err = MergeRequestsClosing::builder()
.project(1)
.build()
.unwrap_err();
assert_eq!(err, "`issue` must be initialized");
}
#[test]
fn project_and_issue_are_sufficient() {
MergeRequestsClosing::builder()
.project(1)
.issue(1)
.build()
.unwrap();
}
#[test]
fn endpoint() {
let endpoint = ExpectedUrl::builder()
.endpoint("projects/simple%2Fproject/issues/1/closed_by")
.build()
.unwrap();
let client = SingleTestClient::new_raw(endpoint, "");
let endpoint = MergeRequestsClosing::builder()
.project("simple/project")
.issue(1)
.build()
.unwrap();
api::ignore(endpoint).query(&client).unwrap();
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment