summaryrefslogtreecommitdiff
path: root/spec/requests/api/boards_spec.rb
blob: c6c10025f7f2f03750370ed101b7e6bb397aaedf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
require 'spec_helper'

describe API::Boards do
  set(:user)        { create(:user) }
  set(:user2)       { create(:user) }
  set(:non_member)  { create(:user) }
  set(:guest)       { create(:user) }
  set(:admin)       { create(:user, :admin) }
  set(:board_parent) { create(:project, :public, creator_id: user.id, namespace: user.namespace ) }

  set(:dev_label) do
    create(:label, title: 'Development', color: '#FFAABB', project: board_parent)
  end

  set(:test_label) do
    create(:label, title: 'Testing', color: '#FFAACC', project: board_parent)
  end

  set(:ux_label) do
    create(:label, title: 'UX', color: '#FF0000', project: board_parent)
  end

  set(:dev_list) do
    create(:list, label: dev_label, position: 1)
  end

  set(:test_list) do
    create(:list, label: test_label, position: 2)
  end

  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]) }

  it_behaves_like 'group and project boards',  "/projects/:id/boards"

  describe "POST /projects/:id/boards/lists" do
    let(:url) { "/projects/#{board_parent.id}/boards/#{board.id}/lists" }

    it 'creates a new issue board list for group labels' do
      group = create(:group)
      group_label = create(:group_label, group: group)
      board_parent.update(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)
      expect(json_response['position']).to eq(3)
    end
  end
end