From 5e15a01789cc8923b7eadd741e7b4fb2a884277f Mon Sep 17 00:00:00 2001 From: brettmortensen <11483419+brettmortensen@users.noreply.github.com> Date: Tue, 30 Oct 2018 21:13:53 -0600 Subject: [PATCH 1/2] Add 'Participants on issues' endpoint Adds missing 'Participants on issues' endpoint and spec. --- lib/gitlab/client/issues.rb | 11 +++++++++++ spec/gitlab/client/issues_spec.rb | 16 ++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/lib/gitlab/client/issues.rb b/lib/gitlab/client/issues.rb index 3ff3831d2..98ac01905 100644 --- a/lib/gitlab/client/issues.rb +++ b/lib/gitlab/client/issues.rb @@ -205,5 +205,16 @@ def reset_time_spent_on_issue(project, id) def time_stats_for_issue(project, id) get("/projects/#{url_encode project}/issues/#{id}/time_stats") end + + # Get participants on issue + # + # @example + # @gitlab.participants_on_issue(3, 42) + # + # @param [Integer, String] project The ID or name of a project. + # @param [Integer] id The ID of an issue. + def participants_on_issue(project, id) + get("/projects/#{url_encode project}/issues/#{id}/participants") + end end end diff --git a/spec/gitlab/client/issues_spec.rb b/spec/gitlab/client/issues_spec.rb index e4c011920..5d2643773 100644 --- a/spec/gitlab/client/issues_spec.rb +++ b/spec/gitlab/client/issues_spec.rb @@ -284,4 +284,20 @@ expect(@issue.assignee.name).to eq('Jack Smith') end end + + describe '.issue_participants' do + before do + stub_get('/projects/3/issues/33/participants', 'issue') + @issue = Gitlab.participants_on_issue(3, 33) + end + + it 'gets the correct resource' do + expect(a_get('/projects/3/issues/33/participants')).to have_been_made + end + + it 'returns information about the participants on issue' do + expect(@issue.project_id).to eq(3) + expect(@issue.assignee.name).to eq('Jack Smith') + end + end end From f7a892c7dce6bc86534fa80f0f59c0854906183b Mon Sep 17 00:00:00 2001 From: brettmortensen <11483419+brettmortensen@users.noreply.github.com> Date: Tue, 30 Oct 2018 22:25:23 -0600 Subject: [PATCH 2/2] Refactor spec to follow existing pattern --- spec/fixtures/participants_on_issue.json | 18 ++++++++++++++++++ spec/gitlab/client/issues_spec.rb | 10 +++++----- 2 files changed, 23 insertions(+), 5 deletions(-) create mode 100644 spec/fixtures/participants_on_issue.json diff --git a/spec/fixtures/participants_on_issue.json b/spec/fixtures/participants_on_issue.json new file mode 100644 index 000000000..d15bb8f2a --- /dev/null +++ b/spec/fixtures/participants_on_issue.json @@ -0,0 +1,18 @@ +[ + { + "id": 1, + "name": "John Doe1", + "username": "user1", + "state": "active", + "avatar_url": "http://www.gravatar.com/avatar/c922747a93b40d1ea88262bf1aebee62?s=80&d=identicon", + "web_url": "http://localhost/user1" + }, + { + "id": 5, + "name": "John Doe5", + "username": "user5", + "state": "active", + "avatar_url": "http://www.gravatar.com/avatar/4aea8cf834ed91844a2da4ff7ae6b491?s=80&d=identicon", + "web_url": "http://localhost/user5" + } +] diff --git a/spec/gitlab/client/issues_spec.rb b/spec/gitlab/client/issues_spec.rb index 5d2643773..3d6c5db88 100644 --- a/spec/gitlab/client/issues_spec.rb +++ b/spec/gitlab/client/issues_spec.rb @@ -285,10 +285,10 @@ end end - describe '.issue_participants' do + describe '.participants_on_issue' do before do - stub_get('/projects/3/issues/33/participants', 'issue') - @issue = Gitlab.participants_on_issue(3, 33) + stub_get('/projects/3/issues/33/participants', 'participants_on_issue') + @participants = Gitlab.participants_on_issue(3, 33) end it 'gets the correct resource' do @@ -296,8 +296,8 @@ end it 'returns information about the participants on issue' do - expect(@issue.project_id).to eq(3) - expect(@issue.assignee.name).to eq('Jack Smith') + expect(@participants.first.name).to eq('John Doe1') + expect(@participants.size).to eq(2) end end end