2019-10-29 00:06:10 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-10-03 03:12:59 +00:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-24 06:09:01 +00:00
|
|
|
RSpec.describe API::Boards do
|
2020-02-17 15:09:01 +00: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 14:11:23 +00:00
|
|
|
|
2020-02-17 15:09:01 +00:00
|
|
|
let_it_be(:dev_label) do
|
2017-12-06 19:07:47 +00:00
|
|
|
create(:label, title: 'Development', color: '#FFAABB', project: board_parent)
|
2016-10-03 03:12:59 +00:00
|
|
|
end
|
|
|
|
|
2020-02-17 15:09:01 +00:00
|
|
|
let_it_be(:test_label) do
|
2017-12-06 19:07:47 +00:00
|
|
|
create(:label, title: 'Testing', color: '#FFAACC', project: board_parent)
|
2016-10-03 03:12:59 +00:00
|
|
|
end
|
|
|
|
|
2020-02-17 15:09:01 +00:00
|
|
|
let_it_be(:ux_label) do
|
2017-12-06 19:07:47 +00:00
|
|
|
create(:label, title: 'UX', color: '#FF0000', project: board_parent)
|
2016-10-03 03:12:59 +00:00
|
|
|
end
|
|
|
|
|
2020-02-17 15:09:01 +00:00
|
|
|
let_it_be(:dev_list) do
|
2016-10-03 03:12:59 +00:00
|
|
|
create(:list, label: dev_label, position: 1)
|
|
|
|
end
|
|
|
|
|
2020-02-17 15:09:01 +00:00
|
|
|
let_it_be(:test_list) do
|
2016-10-03 03:12:59 +00:00
|
|
|
create(:list, label: test_label, position: 2)
|
|
|
|
end
|
|
|
|
|
2020-02-17 15:09:01 +00: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-03 03:12:59 +00:00
|
|
|
|
2019-01-16 12:09:29 +00:00
|
|
|
it_behaves_like 'group and project boards', "/projects/:id/boards"
|
2016-10-03 03:12:59 +00:00
|
|
|
|
2017-12-06 19:07:47 +00:00
|
|
|
describe "POST /projects/:id/boards/lists" do
|
|
|
|
let(:url) { "/projects/#{board_parent.id}/boards/#{board.id}/lists" }
|
2016-10-03 03:12:59 +00:00
|
|
|
|
2016-10-13 21:48:59 +00:00
|
|
|
it 'creates a new issue board list for group labels' do
|
|
|
|
group = create(:group)
|
|
|
|
group_label = create(:group_label, group: group)
|
2017-12-06 19:07:47 +00:00
|
|
|
board_parent.update(group: group)
|
2016-10-13 21:48:59 +00:00
|
|
|
|
2018-12-17 22:52:17 +00:00
|
|
|
post api(url, user), params: { label_id: group_label.id }
|
2016-10-13 21:48:59 +00:00
|
|
|
|
2020-02-21 12:09:07 +00:00
|
|
|
expect(response).to have_gitlab_http_status(:created)
|
2016-10-13 21:48:59 +00:00
|
|
|
expect(json_response['label']['name']).to eq(group_label.title)
|
|
|
|
expect(json_response['position']).to eq(3)
|
|
|
|
end
|
2018-04-04 15:40:29 +00: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)
|
|
|
|
board_parent.update(group: sub_group)
|
|
|
|
group.add_developer(user)
|
|
|
|
sub_group.add_developer(user)
|
|
|
|
|
2018-12-17 22:52:17 +00:00
|
|
|
post api(url, user), params: { label_id: group_label.id }
|
2018-04-04 15:40:29 +00:00
|
|
|
|
2020-02-21 12:09:07 +00:00
|
|
|
expect(response).to have_gitlab_http_status(:created)
|
2018-04-04 15:40:29 +00:00
|
|
|
expect(json_response['label']['name']).to eq(group_label.title)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-07-24 09:20:54 +00:00
|
|
|
describe "POST /groups/:id/boards/lists" do
|
2020-02-17 15:09:01 +00:00
|
|
|
let_it_be(:group) { create(:group) }
|
|
|
|
let_it_be(:board_parent) { create(:group, parent: group ) }
|
2018-04-04 15:40:29 +00:00
|
|
|
let(:url) { "/groups/#{board_parent.id}/boards/#{board.id}/lists" }
|
2019-12-17 18:07:48 +00:00
|
|
|
|
2020-02-17 15:09:01 +00:00
|
|
|
let_it_be(:board) { create(:board, group: board_parent) }
|
2018-04-04 15:40:29 +00: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 22:52:17 +00:00
|
|
|
post api(url, user), params: { label_id: group_label.id }
|
2018-04-04 15:40:29 +00:00
|
|
|
|
2020-02-21 12:09:07 +00:00
|
|
|
expect(response).to have_gitlab_http_status(:created)
|
2018-04-04 15:40:29 +00:00
|
|
|
expect(json_response['label']['name']).to eq(group_label.title)
|
|
|
|
end
|
2016-10-03 03:12:59 +00:00
|
|
|
end
|
|
|
|
end
|