diff options
author | Alexander Randa <randa.alex@gmail.com> | 2017-03-27 13:43:21 +0000 |
---|---|---|
committer | Alexander Randa <randa.alex@gmail.com> | 2017-03-28 17:43:55 +0300 |
commit | c4be3460c202cf8c33429ddca8f0f8383907ac60 (patch) | |
tree | 774855670f155efd39aee680c281445e59f51d00 | |
parent | f74e9245cb18582caa79abd4b7c0b942b9dae851 (diff) | |
download | gitlab-ce-c4be3460c202cf8c33429ddca8f0f8383907ac60.tar.gz |
Fix API group/issues default state filter
-rw-r--r-- | changelogs/unreleased/23655-api-group-issues.yml | 4 | ||||
-rw-r--r-- | lib/api/issues.rb | 4 | ||||
-rw-r--r-- | lib/api/v3/issues.rb | 4 | ||||
-rw-r--r-- | spec/requests/api/issues_spec.rb | 20 | ||||
-rw-r--r-- | spec/requests/api/v3/issues_spec.rb | 20 |
5 files changed, 36 insertions, 16 deletions
diff --git a/changelogs/unreleased/23655-api-group-issues.yml b/changelogs/unreleased/23655-api-group-issues.yml new file mode 100644 index 00000000000..e19e588d09e --- /dev/null +++ b/changelogs/unreleased/23655-api-group-issues.yml @@ -0,0 +1,4 @@ +--- +title: Fix API group/issues default state filter +merge_request: +author: Alexander Randa diff --git a/lib/api/issues.rb b/lib/api/issues.rb index fd2674910d2..4dce5dd130a 100644 --- a/lib/api/issues.rb +++ b/lib/api/issues.rb @@ -63,14 +63,14 @@ module API success Entities::IssueBasic end params do - optional :state, type: String, values: %w[opened closed all], default: 'opened', + optional :state, type: String, values: %w[opened closed all], default: 'all', desc: 'Return opened, closed, or all issues' use :issues_params end get ":id/issues" do group = find_group!(params[:id]) - issues = find_issues(group_id: group.id, state: params[:state] || 'opened') + issues = find_issues(group_id: group.id) present paginate(issues), with: Entities::IssueBasic, current_user: current_user end diff --git a/lib/api/v3/issues.rb b/lib/api/v3/issues.rb index 54c6a8060b8..715083fc4f8 100644 --- a/lib/api/v3/issues.rb +++ b/lib/api/v3/issues.rb @@ -73,14 +73,14 @@ module API success ::API::Entities::Issue end params do - optional :state, type: String, values: %w[opened closed all], default: 'opened', + optional :state, type: String, values: %w[opened closed all], default: 'all', desc: 'Return opened, closed, or all issues' use :issues_params end get ":id/issues" do group = find_group!(params[:id]) - issues = find_issues(group_id: group.id, state: params[:state] || 'opened', match_all_labels: true) + issues = find_issues(group_id: group.id, match_all_labels: true) present paginate(issues), with: ::API::Entities::Issue, current_user: current_user end diff --git a/spec/requests/api/issues_spec.rb b/spec/requests/api/issues_spec.rb index 52f68fed2cc..91d6fb83c0b 100644 --- a/spec/requests/api/issues_spec.rb +++ b/spec/requests/api/issues_spec.rb @@ -333,8 +333,16 @@ describe API::Issues, api: true do end let(:base_url) { "/groups/#{group.id}/issues" } + it 'returns all group issues (including opened and closed)' do + get api(base_url, admin) + + expect(response).to have_http_status(200) + expect(json_response).to be_an Array + expect(json_response.length).to eq(3) + end + it 'returns group issues without confidential issues for non project members' do - get api(base_url, non_member) + get api("#{base_url}?state=opened", non_member) expect(response).to have_http_status(200) expect(response).to include_pagination_headers @@ -344,7 +352,7 @@ describe API::Issues, api: true do end it 'returns group confidential issues for author' do - get api(base_url, author) + get api("#{base_url}?state=opened", author) expect(response).to have_http_status(200) expect(response).to include_pagination_headers @@ -353,7 +361,7 @@ describe API::Issues, api: true do end it 'returns group confidential issues for assignee' do - get api(base_url, assignee) + get api("#{base_url}?state=opened", assignee) expect(response).to have_http_status(200) expect(response).to include_pagination_headers @@ -362,7 +370,7 @@ describe API::Issues, api: true do end it 'returns group issues with confidential issues for project members' do - get api(base_url, user) + get api("#{base_url}?state=opened", user) expect(response).to have_http_status(200) expect(response).to include_pagination_headers @@ -371,7 +379,7 @@ describe API::Issues, api: true do end it 'returns group confidential issues for admin' do - get api(base_url, admin) + get api("#{base_url}?state=opened", admin) expect(response).to have_http_status(200) expect(response).to include_pagination_headers @@ -460,7 +468,7 @@ describe API::Issues, api: true do end it 'returns an array of issues in given milestone' do - get api("#{base_url}?milestone=#{group_milestone.title}", user) + get api("#{base_url}?state=opened&milestone=#{group_milestone.title}", user) expect(response).to have_http_status(200) expect(response).to include_pagination_headers diff --git a/spec/requests/api/v3/issues_spec.rb b/spec/requests/api/v3/issues_spec.rb index 51021eec63c..383871d5c38 100644 --- a/spec/requests/api/v3/issues_spec.rb +++ b/spec/requests/api/v3/issues_spec.rb @@ -285,8 +285,16 @@ describe API::V3::Issues, api: true do end let(:base_url) { "/groups/#{group.id}/issues" } + it 'returns all group issues (including opened and closed)' do + get v3_api(base_url, admin) + + expect(response).to have_http_status(200) + expect(json_response).to be_an Array + expect(json_response.length).to eq(3) + end + it 'returns group issues without confidential issues for non project members' do - get v3_api(base_url, non_member) + get v3_api("#{base_url}?state=opened", non_member) expect(response).to have_http_status(200) expect(json_response).to be_an Array @@ -295,7 +303,7 @@ describe API::V3::Issues, api: true do end it 'returns group confidential issues for author' do - get v3_api(base_url, author) + get v3_api("#{base_url}?state=opened", author) expect(response).to have_http_status(200) expect(json_response).to be_an Array @@ -303,7 +311,7 @@ describe API::V3::Issues, api: true do end it 'returns group confidential issues for assignee' do - get v3_api(base_url, assignee) + get v3_api("#{base_url}?state=opened", assignee) expect(response).to have_http_status(200) expect(json_response).to be_an Array @@ -311,7 +319,7 @@ describe API::V3::Issues, api: true do end it 'returns group issues with confidential issues for project members' do - get v3_api(base_url, user) + get v3_api("#{base_url}?state=opened", user) expect(response).to have_http_status(200) expect(json_response).to be_an Array @@ -319,7 +327,7 @@ describe API::V3::Issues, api: true do end it 'returns group confidential issues for admin' do - get v3_api(base_url, admin) + get v3_api("#{base_url}?state=opened", admin) expect(response).to have_http_status(200) expect(json_response).to be_an Array @@ -368,7 +376,7 @@ describe API::V3::Issues, api: true do end it 'returns an array of issues in given milestone' do - get v3_api("#{base_url}?milestone=#{group_milestone.title}", user) + get v3_api("#{base_url}?state=opened&milestone=#{group_milestone.title}", user) expect(response).to have_http_status(200) expect(json_response).to be_an Array |