debian-mirror-gitlab/spec/requests/api/boards_spec.rb

114 lines
3.6 KiB
Ruby
Raw Normal View History

2019-12-26 22:10:19 +05:30
# frozen_string_literal: true
2016-11-03 12:29:30 +05:30
require 'spec_helper'
2020-07-28 23:09:34 +05:30
RSpec.describe API::Boards do
2020-03-13 15:44:24 +05:30
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 ) }
2016-11-03 12:29:30 +05:30
2020-03-13 15:44:24 +05:30
let_it_be(:dev_label) do
2018-03-17 18:26:18 +05:30
create(:label, title: 'Development', color: '#FFAABB', project: board_parent)
2016-11-03 12:29:30 +05:30
end
2020-03-13 15:44:24 +05:30
let_it_be(:test_label) do
2018-03-17 18:26:18 +05:30
create(:label, title: 'Testing', color: '#FFAACC', project: board_parent)
2016-11-03 12:29:30 +05:30
end
2020-03-13 15:44:24 +05:30
let_it_be(:ux_label) do
2018-03-17 18:26:18 +05:30
create(:label, title: 'UX', color: '#FF0000', project: board_parent)
2016-11-03 12:29:30 +05:30
end
2020-03-13 15:44:24 +05:30
let_it_be(:dev_list) do
2016-11-03 12:29:30 +05:30
create(:list, label: dev_label, position: 1)
end
2020-03-13 15:44:24 +05:30
let_it_be(:test_list) do
2016-11-03 12:29:30 +05:30
create(:list, label: test_label, position: 2)
end
2020-03-13 15:44:24 +05:30
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-11-03 12:29:30 +05:30
2019-03-02 22:35:43 +05:30
it_behaves_like 'group and project boards', "/projects/:id/boards"
2016-11-03 12:29:30 +05:30
2021-01-29 00:20:46 +05:30
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
delete api(url, user)
expect(response).to have_gitlab_http_status(:no_content)
end
end
describe "POST /projects/:id/boards/:board_id/lists" do
2018-03-17 18:26:18 +05:30
let(:url) { "/projects/#{board_parent.id}/boards/#{board.id}/lists" }
2016-11-03 12:29:30 +05:30
it 'creates a new issue board list for group labels' do
group = create(:group)
group_label = create(:group_label, group: group)
2020-11-24 15:15:51 +05:30
board_parent.update!(group: group)
2016-11-03 12:29:30 +05:30
2019-02-15 15:39:39 +05:30
post api(url, user), params: { label_id: group_label.id }
2016-11-03 12:29:30 +05:30
2020-04-08 14:13:33 +05:30
expect(response).to have_gitlab_http_status(:created)
2016-11-03 12:29:30 +05:30
expect(json_response['label']['name']).to eq(group_label.title)
expect(json_response['position']).to eq(3)
end
2018-05-09 12:01:36 +05:30
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-11-24 15:15:51 +05:30
board_parent.update!(group: sub_group)
2018-05-09 12:01:36 +05:30
group.add_developer(user)
sub_group.add_developer(user)
2019-02-15 15:39:39 +05:30
post api(url, user), params: { label_id: group_label.id }
2018-05-09 12:01:36 +05:30
2020-04-08 14:13:33 +05:30
expect(response).to have_gitlab_http_status(:created)
2018-05-09 12:01:36 +05:30
expect(json_response['label']['name']).to eq(group_label.title)
end
end
2021-01-29 00:20:46 +05:30
describe "POST /groups/:id/boards/:board_id/lists" do
2020-03-13 15:44:24 +05:30
let_it_be(:group) { create(:group) }
let_it_be(:board_parent) { create(:group, parent: group ) }
2018-05-09 12:01:36 +05:30
let(:url) { "/groups/#{board_parent.id}/boards/#{board.id}/lists" }
2020-01-01 13:55:28 +05:30
2020-03-13 15:44:24 +05:30
let_it_be(:board) { create(:board, group: board_parent) }
2018-05-09 12:01:36 +05:30
it 'creates a new board list for ancestor group labels' do
group.add_developer(user)
group_label = create(:group_label, group: group)
2019-02-15 15:39:39 +05:30
post api(url, user), params: { label_id: group_label.id }
2018-05-09 12:01:36 +05:30
2020-04-08 14:13:33 +05:30
expect(response).to have_gitlab_http_status(:created)
2018-05-09 12:01:36 +05:30
expect(json_response['label']['name']).to eq(group_label.title)
end
2016-11-03 12:29:30 +05:30
end
end