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

labels_menu_spec.rb « menus « projects « sidebars « lib « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: e1420f9e61ba432a140d971331d705623a6e514b (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
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe Sidebars::Projects::Menus::LabelsMenu do
  let(:project) { build(:project) }
  let(:user) { project.owner }
  let(:context) { Sidebars::Projects::Context.new(current_user: user, container: project) }

  subject { described_class.new(context) }

  it 'does not contain any sub menu' do
    expect(subject.has_items?).to eq false
  end

  describe '#render?' do
    let(:issues_enabled) { true }

    before do
      allow(project).to receive(:issues_enabled?).and_return(issues_enabled)
    end

    context 'when feature flag :sidebar_refactor is enabled' do
      let(:issues_enabled) { false }

      it 'returns false' do
        expect(subject.render?).to be_falsey
      end
    end

    context 'when feature flag :sidebar_refactor is disabled' do
      before do
        stub_feature_flags(sidebar_refactor: false)
      end

      context 'when user can read labels' do
        context 'when issues feature is enabled' do
          it 'returns false' do
            expect(subject.render?).to be_falsey
          end
        end

        context 'when issues feature is disabled' do
          let(:issues_enabled) { false }

          it 'returns true' do
            expect(subject.render?).to be_truthy
          end
        end
      end

      context 'when user cannot read labels' do
        let(:user) { nil }

        it 'returns false' do
          expect(subject.render?).to be_falsey
        end
      end
    end
  end
end