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

ci_cd_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: 6116fff792a7d3ac5c0936e0499ead5861f07bed (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
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe Sidebars::Projects::Menus::CiCdMenu do
  let(:project) { build(:project) }
  let(:user) { project.first_owner }
  let(:can_view_pipeline_editor) { true }
  let(:context) { Sidebars::Projects::Context.new(current_user: user, container: project, current_ref: 'master', can_view_pipeline_editor: can_view_pipeline_editor) }

  subject { described_class.new(context) }

  describe '#render?' do
    context 'when user cannot read builds' do
      let(:user) { nil }

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

    context 'when user can read builds' do
      it 'returns true' do
        expect(subject.render?).to eq true
      end
    end
  end

  describe 'Menu items' do
    subject { described_class.new(context).renderable_items.index { |e| e.item_id == item_id } }

    describe 'Pipelines Editor' do
      let(:item_id) { :pipelines_editor }

      context 'when user cannot view pipeline editor' do
        let(:can_view_pipeline_editor) { false }

        it 'does not include pipeline editor menu item' do
          is_expected.to be_nil
        end
      end

      context 'when user can view pipeline editor' do
        it 'includes pipeline editor menu item' do
          is_expected.not_to be_nil
        end
      end
    end

    describe 'Artifacts' do
      let(:item_id) { :artifacts }

      it 'includes artifacts menu item' do
        is_expected.not_to be_nil
      end
    end
  end
end