From 2e6f50c9f7f8159f3529450ade778713c97a4fac Mon Sep 17 00:00:00 2001 From: Shinya Maeda Date: Sat, 16 Dec 2017 02:26:19 +0900 Subject: [PATCH] Add get-group-issues --- lib/gitlab/client/issues.rb | 12 +++ spec/fixtures/group_issues.json | 118 ++++++++++++++++++++++++++++++ spec/gitlab/client/issues_spec.rb | 16 ++++ 3 files changed, 146 insertions(+) create mode 100644 spec/fixtures/group_issues.json diff --git a/lib/gitlab/client/issues.rb b/lib/gitlab/client/issues.rb index 2f1dedaa3..da94177e3 100644 --- a/lib/gitlab/client/issues.rb +++ b/lib/gitlab/client/issues.rb @@ -23,6 +23,18 @@ def issues(project=nil, options={}) end end + # Gets a list of issues of a group. + # + # @example + # Gitlab.group_issues(5) + # + # @param [Integer, String] group_id The ID or name of a group. + # @param [Hash] options A customizable set of options. + # @return [Array] + def group_issues(group=nil, options={}) + get("/groups/#{group}/issues", query: options) + end + # Gets a single issue. # # @example diff --git a/spec/fixtures/group_issues.json b/spec/fixtures/group_issues.json new file mode 100644 index 000000000..61a0acf06 --- /dev/null +++ b/spec/fixtures/group_issues.json @@ -0,0 +1,118 @@ +[ + { + "project_id" : 4, + "milestone" : { + "due_date" : null, + "project_id" : 4, + "state" : "closed", + "description" : "Rerum est voluptatem provident consequuntur molestias similique ipsum dolor.", + "iid" : 3, + "id" : 11, + "title" : "v3.0", + "created_at" : "2016-01-04T15:31:39.788Z", + "updated_at" : "2016-01-04T15:31:39.788Z" + }, + "author" : { + "state" : "active", + "web_url" : "https://gitlab.example.com/root", + "avatar_url" : null, + "username" : "root", + "id" : 1, + "name" : "Administrator" + }, + "description" : "Omnis vero earum sunt corporis dolor et placeat.", + "state" : "closed", + "iid" : 1, + "assignees" : [{ + "avatar_url" : null, + "web_url" : "https://gitlab.example.com/lennie", + "state" : "active", + "username" : "lennie", + "id" : 9, + "name" : "Dr. Luella Kovacek" + }], + "assignee" : { + "avatar_url" : null, + "web_url" : "https://gitlab.example.com/lennie", + "state" : "active", + "username" : "lennie", + "id" : 9, + "name" : "Dr. Luella Kovacek" + }, + "labels" : [], + "id" : 41, + "title" : "Ut commodi ullam eos dolores perferendis nihil sunt.", + "updated_at" : "2016-01-04T15:31:46.176Z", + "created_at" : "2016-01-04T15:31:46.176Z", + "closed_at" : null, + "user_notes_count": 1, + "due_date": null, + "web_url": "http://example.com/example/example/issues/1", + "time_stats": { + "time_estimate": 0, + "total_time_spent": 0, + "human_time_estimate": null, + "human_total_time_spent": null + }, + "confidential": false, + "discussion_locked": false + }, + { + "project_id" : 4, + "milestone" : { + "due_date" : null, + "project_id" : 4, + "state" : "closed", + "description" : "Rerum est voluptatem provident consequuntur molestias similique ipsum dolor.", + "iid" : 3, + "id" : 11, + "title" : "v3.0", + "created_at" : "2016-01-04T15:31:39.788Z", + "updated_at" : "2016-01-04T15:31:39.788Z" + }, + "author" : { + "state" : "active", + "web_url" : "https://gitlab.example.com/root", + "avatar_url" : null, + "username" : "root", + "id" : 1, + "name" : "Administrator" + }, + "description" : "different", + "state" : "closed", + "iid" : 1, + "assignees" : [{ + "avatar_url" : null, + "web_url" : "https://gitlab.example.com/lennie", + "state" : "active", + "username" : "lennie", + "id" : 9, + "name" : "Dr. Luella Kovacek" + }], + "assignee" : { + "avatar_url" : null, + "web_url" : "https://gitlab.example.com/lennie", + "state" : "active", + "username" : "lennie", + "id" : 9, + "name" : "Dr. Luella Kovacek" + }, + "labels" : [], + "id" : 41, + "title" : "different", + "updated_at" : "2016-01-04T15:31:46.176Z", + "created_at" : "2016-01-04T15:31:46.176Z", + "closed_at" : null, + "user_notes_count": 1, + "due_date": null, + "web_url": "http://example.com/example/example/issues/1", + "time_stats": { + "time_estimate": 0, + "total_time_spent": 0, + "human_time_estimate": null, + "human_total_time_spent": null + }, + "confidential": false, + "discussion_locked": false + } +] \ No newline at end of file diff --git a/spec/gitlab/client/issues_spec.rb b/spec/gitlab/client/issues_spec.rb index a139b7722..043d5188d 100644 --- a/spec/gitlab/client/issues_spec.rb +++ b/spec/gitlab/client/issues_spec.rb @@ -52,6 +52,22 @@ end end + describe ".group_issues" do + before do + stub_get("/groups/3/issues", "group_issues") + @issues = Gitlab.group_issues(3) + end + + it "gets the correct resource" do + expect(a_get("/groups/3/issues")).to have_been_made + end + + it "returns a paginated response of project's issues" do + expect(@issues).to be_a Gitlab::PaginatedResponse + expect(@issues.first.project_id).to eq(4) + end + end + describe ".issue" do before do stub_get("/projects/3/issues/33", "issue")