2019-10-28 20:06:10 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-10-02 23:12:59 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-24 02:09:01 -04:00
|
|
|
RSpec.describe API::Boards do
|
2020-02-17 10:09:01 -05:00
|
|
|
let_it_be(:user) { create(:user) }
|
|
|
|
let_it_be(:non_member) { create(:user) }
|
|
|
|
let_it_be(:guest) { create(:user) }
|
|
|
|
let_it_be(:admin) { create(:user, :admin) }
|
|
|
|
let_it_be(:board_parent, reload: true) { create(:project, :public, creator_id: user.id, namespace: user.namespace ) }
|
2017-09-19 10:11:23 -04:00
|
|
|
|
2020-02-17 10:09:01 -05:00
|
|
|
let_it_be(:dev_label) do
|
2017-12-06 14:07:47 -05:00
|
|
|
create(:label, title: 'Development', color: '#FFAABB', project: board_parent)
|
2016-10-02 23:12:59 -04:00
|
|
|
end
|
|
|
|
|
2020-02-17 10:09:01 -05:00
|
|
|
let_it_be(:test_label) do
|
2017-12-06 14:07:47 -05:00
|
|
|
create(:label, title: 'Testing', color: '#FFAACC', project: board_parent)
|
2016-10-02 23:12:59 -04:00
|
|
|
end
|
|
|
|
|
2020-02-17 10:09:01 -05:00
|
|
|
let_it_be(:ux_label) do
|
2017-12-06 14:07:47 -05:00
|
|
|
create(:label, title: 'UX', color: '#FF0000', project: board_parent)
|
2016-10-02 23:12:59 -04:00
|
|
|
end
|
|
|
|
|
2020-02-17 10:09:01 -05:00
|
|
|
let_it_be(:dev_list) do
|
2016-10-02 23:12:59 -04:00
|
|
|
create(:list, label: dev_label, position: 1)
|
|
|
|
end
|
|
|
|
|
2020-02-17 10:09:01 -05:00
|
|
|
let_it_be(:test_list) do
|
2016-10-02 23:12:59 -04:00
|
|
|
create(:list, label: test_label, position: 2)
|
|
|
|
end
|
|
|
|
|
2020-02-17 10:09:01 -05:00
|
|
|
let_it_be(:milestone) { create(:milestone, project: board_parent) }
|
|
|
|
let_it_be(:board_label) { create(:label, project: board_parent) }
|
|
|
|
let_it_be(:board) { create(:board, project: board_parent, lists: [dev_list, test_list]) }
|
2016-10-02 23:12:59 -04:00
|
|
|
|
2019-01-16 07:09:29 -05:00
|
|
|
it_behaves_like 'group and project boards', "/projects/:id/boards"
|
2016-10-02 23:12:59 -04:00
|
|
|
|
2020-10-31 02:09:06 -04:00
|
|
|
describe "POST /projects/:id/boards" do
|
|
|
|
let(:url) { "/projects/#{board_parent.id}/boards" }
|
|
|
|
|
|
|
|
it 'creates a new issue board' do
|
|
|
|
post api(url, user), params: { name: 'foo' }
|
|
|
|
|
|
|
|
expect(response).to have_gitlab_http_status(:created)
|
|
|
|
expect(json_response['name']).to eq('foo')
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'fails to create a new board' do
|
|
|
|
post api(url, user), params: { some_name: 'foo' }
|
|
|
|
|
|
|
|
expect(response).to have_gitlab_http_status(:bad_request)
|
|
|
|
expect(json_response['error']).to eq('name is missing')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe "DELETE /projects/:id/boards/:board_id" do
|
|
|
|
let(:url) { "/projects/#{board_parent.id}/boards/#{board.id}" }
|
|
|
|
|
|
|
|
it 'delete the issue board' do
|
2022-07-21 08:10:03 -04:00
|
|
|
expect do
|
|
|
|
delete api(url, user)
|
2020-10-31 02:09:06 -04:00
|
|
|
|
2022-07-21 08:10:03 -04:00
|
|
|
expect(response).to have_gitlab_http_status(:no_content)
|
2022-07-29 14:08:58 -04:00
|
|
|
end.to change { board_parent.boards.count }.by(-1)
|
2020-10-31 02:09:06 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe "POST /projects/:id/boards/:board_id/lists" do
|
2017-12-06 14:07:47 -05:00
|
|
|
let(:url) { "/projects/#{board_parent.id}/boards/#{board.id}/lists" }
|
2016-10-02 23:12:59 -04:00
|
|
|
|
2016-10-13 17:48:59 -04:00
|
|
|
it 'creates a new issue board list for group labels' do
|
|
|
|
group = create(:group)
|
|
|
|
group_label = create(:group_label, group: group)
|
2020-09-03 14:08:29 -04:00
|
|
|
board_parent.update!(group: group)
|
2016-10-13 17:48:59 -04:00
|
|
|
|
2018-12-17 17:52:17 -05:00
|
|
|
post api(url, user), params: { label_id: group_label.id }
|
2016-10-13 17:48:59 -04:00
|
|
|
|
2020-02-21 07:09:07 -05:00
|
|
|
expect(response).to have_gitlab_http_status(:created)
|
2016-10-13 17:48:59 -04:00
|
|
|
expect(json_response['label']['name']).to eq(group_label.title)
|
|
|
|
expect(json_response['position']).to eq(3)
|
|
|
|
end
|
2018-04-04 11:40:29 -04:00
|
|
|
|
|
|
|
it 'creates a new board list for ancestor group labels' do
|
|
|
|
group = create(:group)
|
|
|
|
sub_group = create(:group, parent: group)
|
|
|
|
group_label = create(:group_label, group: group)
|
2020-09-03 14:08:29 -04:00
|
|
|
board_parent.update!(group: sub_group)
|
2018-04-04 11:40:29 -04:00
|
|
|
group.add_developer(user)
|
|
|
|
sub_group.add_developer(user)
|
|
|
|
|
2018-12-17 17:52:17 -05:00
|
|
|
post api(url, user), params: { label_id: group_label.id }
|
2018-04-04 11:40:29 -04:00
|
|
|
|
2020-02-21 07:09:07 -05:00
|
|
|
expect(response).to have_gitlab_http_status(:created)
|
2018-04-04 11:40:29 -04:00
|
|
|
expect(json_response['label']['name']).to eq(group_label.title)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-10-31 02:09:06 -04:00
|
|
|
describe "POST /groups/:id/boards/:board_id/lists" do
|
2020-02-17 10:09:01 -05:00
|
|
|
let_it_be(:group) { create(:group) }
|
|
|
|
let_it_be(:board_parent) { create(:group, parent: group ) }
|
2018-04-04 11:40:29 -04:00
|
|
|
let(:url) { "/groups/#{board_parent.id}/boards/#{board.id}/lists" }
|
2019-12-17 13:07:48 -05:00
|
|
|
|
2020-02-17 10:09:01 -05:00
|
|
|
let_it_be(:board) { create(:board, group: board_parent) }
|
2018-04-04 11:40:29 -04:00
|
|
|
|
|
|
|
it 'creates a new board list for ancestor group labels' do
|
|
|
|
group.add_developer(user)
|
|
|
|
group_label = create(:group_label, group: group)
|
|
|
|
|
2018-12-17 17:52:17 -05:00
|
|
|
post api(url, user), params: { label_id: group_label.id }
|
2018-04-04 11:40:29 -04:00
|
|
|
|
2020-02-21 07:09:07 -05:00
|
|
|
expect(response).to have_gitlab_http_status(:created)
|
2018-04-04 11:40:29 -04:00
|
|
|
expect(json_response['label']['name']).to eq(group_label.title)
|
|
|
|
end
|
2016-10-02 23:12:59 -04:00
|
|
|
end
|
|
|
|
end
|