Add support to group labels on issues board API

parent bf710b51
...@@ -65,8 +65,8 @@ module API ...@@ -65,8 +65,8 @@ module API
requires :label_id, type: Integer, desc: 'The ID of an existing label' requires :label_id, type: Integer, desc: 'The ID of an existing label'
end end
post '/lists' do post '/lists' do
unless user_project.labels.exists?(params[:label_id]) unless available_labels.exists?(params[:label_id])
render_api_error!({ error: "Label not found!" }, 400) render_api_error!({ error: 'Label not found!' }, 400)
end end
authorize!(:admin_list, user_project) authorize!(:admin_list, user_project)
......
...@@ -106,9 +106,20 @@ describe API::API, api: true do ...@@ -106,9 +106,20 @@ describe API::API, api: true do
describe "POST /projects/:id/board/lists" do describe "POST /projects/:id/board/lists" do
let(:base_url) { "/projects/#{project.id}/boards/#{board.id}/lists" } let(:base_url) { "/projects/#{project.id}/boards/#{board.id}/lists" }
it 'creates a new issue board list' do it 'creates a new issue board list for group labels' do
post api(base_url, user), group = create(:group)
label_id: ux_label.id group_label = create(:group_label, group: group)
project.update(group: group)
post api(base_url, user), label_id: group_label.id
expect(response).to have_http_status(201)
expect(json_response['label']['name']).to eq(group_label.title)
expect(json_response['position']).to eq(3)
end
it 'creates a new issue board list for project labels' do
post api(base_url, user), label_id: ux_label.id
expect(response).to have_http_status(201) expect(response).to have_http_status(201)
expect(json_response['label']['name']).to eq(ux_label.title) expect(json_response['label']['name']).to eq(ux_label.title)
...@@ -116,15 +127,13 @@ describe API::API, api: true do ...@@ -116,15 +127,13 @@ describe API::API, api: true do
end end
it 'returns 400 when creating a new list if label_id is invalid' do it 'returns 400 when creating a new list if label_id is invalid' do
post api(base_url, user), post api(base_url, user), label_id: 23423
label_id: 23423
expect(response).to have_http_status(400) expect(response).to have_http_status(400)
end end
it "returns 403 for project members with guest role" do it 'returns 403 for project members with guest role' do
put api("#{base_url}/#{test_list.id}", guest), put api("#{base_url}/#{test_list.id}", guest), position: 1
position: 1
expect(response).to have_http_status(403) expect(response).to have_http_status(403)
end end
......
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