debian-mirror-gitlab/spec/lib/sidebars/projects/menus/deployments_menu_spec.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

97 lines
2.5 KiB
Ruby
Raw Normal View History

2021-06-08 01:23:25 +05:30
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Sidebars::Projects::Menus::DeploymentsMenu do
2022-10-11 01:57:18 +05:30
let_it_be(:project, reload: true) { create(:project, :repository) }
2021-06-08 01:23:25 +05:30
2022-04-04 11:22:00 +05:30
let(:user) { project.first_owner }
2021-06-08 01:23:25 +05:30
let(:context) { Sidebars::Projects::Context.new(current_user: user, container: project) }
describe '#render?' do
subject { described_class.new(context) }
context 'when menu does not have any menu items' do
it 'returns false' do
allow(subject).to receive(:has_renderable_items?).and_return(false)
expect(subject.render?).to be false
end
end
context 'when menu has menu items' do
it 'returns true' do
expect(subject.render?).to be true
end
end
end
describe 'Menu Items' do
subject { described_class.new(context).renderable_items.index { |e| e.item_id == item_id } }
shared_examples 'access rights checks' do
specify { is_expected.not_to be_nil }
describe 'when the user does not have access' do
let(:user) { nil }
specify { is_expected.to be_nil }
end
2022-10-11 01:57:18 +05:30
describe 'when the feature is disabled' do
before do
project.update_attribute("#{item_id}_access_level", 'disabled')
end
it { is_expected.to be_nil }
end
2022-11-25 23:54:43 +05:30
end
shared_examples 'split_operations_visibility_permissions FF disabled' do
before do
stub_feature_flags(split_operations_visibility_permissions: false)
end
2022-10-11 01:57:18 +05:30
2022-11-25 23:54:43 +05:30
it { is_expected.not_to be_nil }
context 'and the feature is disabled' do
2022-10-11 01:57:18 +05:30
before do
2022-11-25 23:54:43 +05:30
project.update_attribute("#{item_id}_access_level", 'disabled')
2022-10-11 01:57:18 +05:30
end
it { is_expected.not_to be_nil }
2022-11-25 23:54:43 +05:30
end
2022-10-11 01:57:18 +05:30
2022-11-25 23:54:43 +05:30
context 'and operations is disabled' do
before do
project.update_attribute(:operations_access_level, 'disabled')
2022-10-11 01:57:18 +05:30
end
2022-11-25 23:54:43 +05:30
it do
is_expected.to be_nil if [:environments, :feature_flags].include?(item_id)
2022-10-11 01:57:18 +05:30
end
end
2021-06-08 01:23:25 +05:30
end
describe 'Feature Flags' do
let(:item_id) { :feature_flags }
it_behaves_like 'access rights checks'
2022-11-25 23:54:43 +05:30
it_behaves_like 'split_operations_visibility_permissions FF disabled'
2021-06-08 01:23:25 +05:30
end
describe 'Environments' do
let(:item_id) { :environments }
it_behaves_like 'access rights checks'
2022-11-25 23:54:43 +05:30
it_behaves_like 'split_operations_visibility_permissions FF disabled'
2021-06-08 01:23:25 +05:30
end
describe 'Releases' do
let(:item_id) { :releases }
it_behaves_like 'access rights checks'
end
end
end