Commit 03c24c33 authored by Rémy Coutable's avatar Rémy Coutable

Merge branch '23655-api-group-issues' into 'master'

Fix API group/issues default state filter

Closes #23655

See merge request !10253
parents 03611b91 c4be3460
---
title: Fix API group/issues default state filter
merge_request:
author: Alexander Randa
...@@ -63,14 +63,14 @@ module API ...@@ -63,14 +63,14 @@ module API
success Entities::IssueBasic success Entities::IssueBasic
end end
params do 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' desc: 'Return opened, closed, or all issues'
use :issues_params use :issues_params
end end
get ":id/issues" do get ":id/issues" do
group = find_group!(params[:id]) 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 present paginate(issues), with: Entities::IssueBasic, current_user: current_user
end end
......
...@@ -73,14 +73,14 @@ module API ...@@ -73,14 +73,14 @@ module API
success ::API::Entities::Issue success ::API::Entities::Issue
end end
params do 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' desc: 'Return opened, closed, or all issues'
use :issues_params use :issues_params
end end
get ":id/issues" do get ":id/issues" do
group = find_group!(params[:id]) 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 present paginate(issues), with: ::API::Entities::Issue, current_user: current_user
end end
......
...@@ -333,8 +333,16 @@ describe API::Issues, api: true do ...@@ -333,8 +333,16 @@ describe API::Issues, api: true do
end end
let(:base_url) { "/groups/#{group.id}/issues" } 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 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 have_http_status(200)
expect(response).to include_pagination_headers expect(response).to include_pagination_headers
...@@ -344,7 +352,7 @@ describe API::Issues, api: true do ...@@ -344,7 +352,7 @@ describe API::Issues, api: true do
end end
it 'returns group confidential issues for author' do 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 have_http_status(200)
expect(response).to include_pagination_headers expect(response).to include_pagination_headers
...@@ -353,7 +361,7 @@ describe API::Issues, api: true do ...@@ -353,7 +361,7 @@ describe API::Issues, api: true do
end end
it 'returns group confidential issues for assignee' do 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 have_http_status(200)
expect(response).to include_pagination_headers expect(response).to include_pagination_headers
...@@ -362,7 +370,7 @@ describe API::Issues, api: true do ...@@ -362,7 +370,7 @@ describe API::Issues, api: true do
end end
it 'returns group issues with confidential issues for project members' do 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 have_http_status(200)
expect(response).to include_pagination_headers expect(response).to include_pagination_headers
...@@ -371,7 +379,7 @@ describe API::Issues, api: true do ...@@ -371,7 +379,7 @@ describe API::Issues, api: true do
end end
it 'returns group confidential issues for admin' do 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 have_http_status(200)
expect(response).to include_pagination_headers expect(response).to include_pagination_headers
...@@ -460,7 +468,7 @@ describe API::Issues, api: true do ...@@ -460,7 +468,7 @@ describe API::Issues, api: true do
end end
it 'returns an array of issues in given milestone' do 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 have_http_status(200)
expect(response).to include_pagination_headers expect(response).to include_pagination_headers
......
...@@ -285,8 +285,16 @@ describe API::V3::Issues, api: true do ...@@ -285,8 +285,16 @@ describe API::V3::Issues, api: true do
end end
let(:base_url) { "/groups/#{group.id}/issues" } 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 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(response).to have_http_status(200)
expect(json_response).to be_an Array expect(json_response).to be_an Array
...@@ -295,7 +303,7 @@ describe API::V3::Issues, api: true do ...@@ -295,7 +303,7 @@ describe API::V3::Issues, api: true do
end end
it 'returns group confidential issues for author' do 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(response).to have_http_status(200)
expect(json_response).to be_an Array expect(json_response).to be_an Array
...@@ -303,7 +311,7 @@ describe API::V3::Issues, api: true do ...@@ -303,7 +311,7 @@ describe API::V3::Issues, api: true do
end end
it 'returns group confidential issues for assignee' do 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(response).to have_http_status(200)
expect(json_response).to be_an Array expect(json_response).to be_an Array
...@@ -311,7 +319,7 @@ describe API::V3::Issues, api: true do ...@@ -311,7 +319,7 @@ describe API::V3::Issues, api: true do
end end
it 'returns group issues with confidential issues for project members' do 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(response).to have_http_status(200)
expect(json_response).to be_an Array expect(json_response).to be_an Array
...@@ -319,7 +327,7 @@ describe API::V3::Issues, api: true do ...@@ -319,7 +327,7 @@ describe API::V3::Issues, api: true do
end end
it 'returns group confidential issues for admin' do 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(response).to have_http_status(200)
expect(json_response).to be_an Array expect(json_response).to be_an Array
...@@ -368,7 +376,7 @@ describe API::V3::Issues, api: true do ...@@ -368,7 +376,7 @@ describe API::V3::Issues, api: true do
end end
it 'returns an array of issues in given milestone' do 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(response).to have_http_status(200)
expect(json_response).to be_an Array expect(json_response).to be_an Array
......
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