Welcome to mirror list, hosted at ThFree Co, Russian Federation.

multiple_and_scoped_issue_boards_shared_examples.rb « api « requests « shared_examples « support « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: fa111ca5811c4ccdfc5b35b697e5c03f6aae7a3e (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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# frozen_string_literal: true

RSpec.shared_examples 'multiple and scoped issue boards' do |route_definition|
  let(:root_url) { route_definition.gsub(":id", board_parent.id.to_s) }

  context 'multiple issue boards' do
    before do
      board_parent.add_reporter(user)
      stub_licensed_features(multiple_group_issue_boards: true)
    end

    describe "POST #{route_definition}" do
      it 'creates a board' do
        post api(root_url, user), params: { name: "new board" }

        expect(response).to have_gitlab_http_status(:created)
        expect(response).to match_response_schema('public_api/v4/board', dir: "ee")
      end
    end

    describe "PUT #{route_definition}/:board_id" do
      let(:url) { "#{root_url}/#{board.id}" }

      it 'updates a board' do
        put api(url, user), params: { name: 'new name', weight: 4, labels: 'foo, bar' }

        expect(response).to have_gitlab_http_status(:ok)

        expect(response).to match_response_schema('public_api/v4/board', dir: "ee")

        board.reload

        expect(board.name).to eq('new name')
        expect(board.weight).to eq(4)
        expect(board.labels.map(&:title)).to contain_exactly('foo', 'bar')
      end

      it 'does not remove missing attributes from the board' do
        expect { put api(url, user), params: { name: 'new name' } }
          .to not_change { board.reload.assignee }
          .and not_change { board.reload.milestone }
          .and not_change { board.reload.weight }
          .and not_change { board.reload.labels.map(&:title).sort }

        expect(response).to have_gitlab_http_status(:ok)
        expect(response).to match_response_schema('public_api/v4/board', dir: "ee")
      end

      it 'allows removing optional attributes' do
        put api(url, user), params: { name: 'new name', assignee_id: nil, milestone_id: nil, weight: nil, labels: nil }

        expect(response).to have_gitlab_http_status(:ok)
        expect(response).to match_response_schema('public_api/v4/board', dir: "ee")

        board.reload

        expect(board.name).to eq('new name')
        expect(board.assignee).to be_nil
        expect(board.milestone).to be_nil
        expect(board.weight).to be_nil
        expect(board.labels).to be_empty
      end
    end

    describe "DELETE #{route_definition}/:board_id" do
      let(:url) { "#{root_url}/#{board.id}" }

      it 'deletes a board' do
        delete api(url, user)

        expect(response).to have_gitlab_http_status(:no_content)
      end
    end
  end

  context 'with the scoped_issue_board-feature available' do
    it 'returns the milestone when the `scoped_issue_board` feature is enabled' do
      stub_licensed_features(scoped_issue_board: true)

      get api(root_url, user)

      expect(json_response.first["milestone"]).not_to be_nil
    end

    it 'hides the milestone when the `scoped_issue_board` feature is disabled' do
      stub_licensed_features(scoped_issue_board: false)

      get api(root_url, user)

      expect(json_response.first["milestone"]).to be_nil
    end
  end
end