2016-10-02 23:12:59 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2017-04-21 16:32:02 -04:00
|
|
|
describe API::Boards do
|
2017-09-19 10:11:23 -04:00
|
|
|
set(:user) { create(:user) }
|
|
|
|
set(:non_member) { create(:user) }
|
|
|
|
set(:guest) { create(:user) }
|
|
|
|
set(:admin) { create(:user, :admin) }
|
2017-12-06 14:07:47 -05:00
|
|
|
set(:board_parent) { create(:project, :public, creator_id: user.id, namespace: user.namespace ) }
|
2017-09-19 10:11:23 -04:00
|
|
|
|
|
|
|
set(: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
|
|
|
|
|
2017-09-19 10:11:23 -04:00
|
|
|
set(: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
|
|
|
|
|
2017-09-19 10:11:23 -04:00
|
|
|
set(: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
|
|
|
|
|
2017-09-19 10:11:23 -04:00
|
|
|
set(:dev_list) do
|
2016-10-02 23:12:59 -04:00
|
|
|
create(:list, label: dev_label, position: 1)
|
|
|
|
end
|
|
|
|
|
2017-09-19 10:11:23 -04:00
|
|
|
set(:test_list) do
|
2016-10-02 23:12:59 -04:00
|
|
|
create(:list, label: test_label, position: 2)
|
|
|
|
end
|
|
|
|
|
2017-12-06 14:07:47 -05:00
|
|
|
set(:milestone) { create(:milestone, project: board_parent) }
|
|
|
|
set(:board_label) { create(:label, project: board_parent) }
|
|
|
|
set(:board) { create(:board, project: board_parent, lists: [dev_list, test_list]) }
|
2016-10-02 23:12:59 -04:00
|
|
|
|
2017-12-06 14:07:47 -05:00
|
|
|
it_behaves_like 'group and project boards', "/projects/:id/boards"
|
2016-10-02 23:12:59 -04:00
|
|
|
|
2017-12-06 14:07:47 -05:00
|
|
|
describe "POST /projects/:id/boards/lists" do
|
|
|
|
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)
|
2017-12-06 14:07:47 -05:00
|
|
|
board_parent.update(group: group)
|
2016-10-13 17:48:59 -04:00
|
|
|
|
2017-12-06 14:07:47 -05:00
|
|
|
post api(url, user), label_id: group_label.id
|
2016-10-13 17:48:59 -04:00
|
|
|
|
2017-10-19 14:28:19 -04:00
|
|
|
expect(response).to have_gitlab_http_status(201)
|
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)
|
|
|
|
board_parent.update(group: sub_group)
|
|
|
|
group.add_developer(user)
|
|
|
|
sub_group.add_developer(user)
|
|
|
|
|
|
|
|
post api(url, user), label_id: group_label.id
|
|
|
|
|
|
|
|
expect(response).to have_gitlab_http_status(201)
|
|
|
|
expect(json_response['label']['name']).to eq(group_label.title)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe "POST /groups/:id/boards/lists", :nested_groups do
|
|
|
|
set(:group) { create(:group) }
|
|
|
|
set(:board_parent) { create(:group, parent: group ) }
|
|
|
|
let(:url) { "/groups/#{board_parent.id}/boards/#{board.id}/lists" }
|
|
|
|
set(:board) { create(:board, group: board_parent) }
|
|
|
|
|
|
|
|
it 'creates a new board list for ancestor group labels' do
|
|
|
|
group.add_developer(user)
|
|
|
|
group_label = create(:group_label, group: group)
|
|
|
|
|
|
|
|
post api(url, user), label_id: group_label.id
|
|
|
|
|
|
|
|
expect(response).to have_gitlab_http_status(201)
|
|
|
|
expect(json_response['label']['name']).to eq(group_label.title)
|
|
|
|
end
|
2016-10-02 23:12:59 -04:00
|
|
|
end
|
|
|
|
end
|