summaryrefslogtreecommitdiff
path: root/spec/features/projects/labels/user_sees_links_to_issuables_spec.rb
blob: 7a9b9e6eac2cb016085d603fc40bd755dca345fe (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
# frozen_string_literal: true

require 'spec_helper'

describe 'Projects > Labels > User sees links to issuables' do
  set(:user) { create(:user) }

  before do
    label # creates the label
    project.add_developer(user)
    sign_in user
    visit project_labels_path(project)
  end

  context 'with a project label' do
    let(:label) { create(:label, project: project, title: 'bug') }

    context 'when merge requests and issues are enabled for the project' do
      let(:project) { create(:project, :public) }

      it 'shows links to MRs and issues' do
        page.within('.labels-container') do
          expect(page).to have_link('Merge requests')
          expect(page).to have_link('Issues')
        end
      end
    end

    context 'when issues are disabled for the project' do
      let(:project) { create(:project, :public, issues_access_level: ProjectFeature::DISABLED) }

      it 'shows links to MRs but not to issues' do
        page.within('.labels-container') do
          expect(page).to have_link('Merge requests')
          expect(page).not_to have_link('Issues')
        end
      end
    end

    context 'when merge requests are disabled for the project' do
      let(:project) { create(:project, :public, merge_requests_access_level: ProjectFeature::DISABLED) }

      it 'shows links to issues but not to MRs' do
        page.within('.labels-container') do
          expect(page).not_to have_link('Merge requests')
          expect(page).to have_link('Issues')
        end
      end
    end
  end

  context 'with a group label' do
    set(:group) { create(:group) }
    let(:label) { create(:group_label, group: group, title: 'bug') }

    context 'when merge requests and issues are enabled for the project' do
      let(:project) { create(:project, :public, namespace: group) }

      it 'shows links to MRs and issues' do
        page.within('.labels-container') do
          expect(page).to have_link('Merge requests')
          expect(page).to have_link('Issues')
        end
      end
    end

    context 'when issues are disabled for the project' do
      let(:project) { create(:project, :public, namespace: group, issues_access_level: ProjectFeature::DISABLED) }

      it 'shows links to MRs and issues' do
        page.within('.labels-container') do
          expect(page).to have_link('Merge requests')
          expect(page).to have_link('Issues')
        end
      end
    end

    context 'when merge requests are disabled for the project' do
      let(:project) { create(:project, :public, namespace: group, merge_requests_access_level: ProjectFeature::DISABLED) }

      it 'shows links to MRs and issues' do
        page.within('.labels-container') do
          expect(page).to have_link('Merge requests')
          expect(page).to have_link('Issues')
        end
      end
    end
  end
end