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

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/lib/sidebars/projects/menus/ci_cd_menu_spec.rb')
-rw-r--r--spec/lib/sidebars/projects/menus/ci_cd_menu_spec.rb70
1 files changed, 70 insertions, 0 deletions
diff --git a/spec/lib/sidebars/projects/menus/ci_cd_menu_spec.rb b/spec/lib/sidebars/projects/menus/ci_cd_menu_spec.rb
new file mode 100644
index 00000000000..dee2716e4c2
--- /dev/null
+++ b/spec/lib/sidebars/projects/menus/ci_cd_menu_spec.rb
@@ -0,0 +1,70 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe Sidebars::Projects::Menus::CiCdMenu do
+ let(:project) { build(:project) }
+ let(:user) { project.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 }
+
+ context 'when feature flag :artifacts_management_page is disabled' do
+ it 'does not include artifacts menu item' do
+ stub_feature_flags(artifacts_management_page: false)
+
+ is_expected.to be_nil
+ end
+ end
+
+ context 'when feature flag :artifacts_management_page is enabled' do
+ it 'includes artifacts menu item' do
+ stub_feature_flags(artifacts_management_page: true)
+
+ is_expected.not_to be_nil
+ end
+ end
+ end
+ end
+end