From 85ecc37c7618a150eb97d13145f995717010cc6c Mon Sep 17 00:00:00 2001 From: Gabriel Mazetto Date: Mon, 30 Jan 2017 11:57:27 +0100 Subject: [PATCH] Allow issues to use NAMESPACE/REPO identifier --- CHANGELOG.md | 1 + lib/gitlab/client/issues.rb | 2 +- spec/gitlab/client/issues_spec.rb | 16 ++++++++++++++++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7f23f1192..543a78292 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ - Update documentation to link to docs.gitlab.com instead of the GitHub mirror for GitLab CE. (@connorshea) - Add method `share_project_with_group` (@danhalligan) - Allow to retrieve `ssh_keys` for a specific user(@dirker) +- Allow issues to use NAMESPACE/REPO identifier (@brodock) ### 3.7.0 (16/08/2016) diff --git a/lib/gitlab/client/issues.rb b/lib/gitlab/client/issues.rb index ca3f5ee25..b6a90d82e 100644 --- a/lib/gitlab/client/issues.rb +++ b/lib/gitlab/client/issues.rb @@ -16,7 +16,7 @@ module Issues # @option options [Integer] :per_page The number of results per page. # @return [Array] def issues(project=nil, options={}) - if project.to_i.zero? + if project.to_s.empty? && project.to_i.zero? get("/issues", query: options) else get("/projects/#{project}/issues", query: options) diff --git a/spec/gitlab/client/issues_spec.rb b/spec/gitlab/client/issues_spec.rb index a8e703dc4..24f392059 100644 --- a/spec/gitlab/client/issues_spec.rb +++ b/spec/gitlab/client/issues_spec.rb @@ -18,6 +18,22 @@ end end + context 'with literal project ID passed' do + before do + stub_get("/projects/gitlab-org%2Fgitlab-ce/issues", "project_issues") + @issues = Gitlab.issues('gitlab-org%2Fgitlab-ce') + end + + it "should get the correct resource" do + expect(a_get("/projects/gitlab-org%2Fgitlab-ce/issues")).to have_been_made + end + + it "should return a paginated response of project's issues" do + expect(@issues).to be_a Gitlab::PaginatedResponse + expect(@issues.first.project_id).to eq(3) + end + end + context "without project ID passed" do before do stub_get("/issues", "issues")