Commit e899dbf4 authored by Nicolò Maria Mezzopera's avatar Nicolò Maria Mezzopera Committed by Dylan Griffith

Remove dependency proxy menu when user is not authorised

parent 6ffc0491
......@@ -52,7 +52,7 @@ module Sidebars
end
def dependency_proxy_menu_item
unless context.group.dependency_proxy_feature_available?
unless can?(context.current_user, :read_dependency_proxy, context.group)
return ::Sidebars::NilMenuItem.new(item_id: :dependency_proxy)
end
......
......@@ -137,16 +137,27 @@ RSpec.describe Sidebars::Groups::Menus::PackagesRegistriesMenu do
stub_config(dependency_proxy: { enabled: dependency_enabled })
end
context 'when config dependency_proxy is enabled' do
let(:dependency_enabled) { true }
context 'when user can read dependency proxy' do
context 'when config dependency_proxy is enabled' do
let(:dependency_enabled) { true }
it 'the menu item is added to list of menu items' do
is_expected.not_to be_nil
it 'the menu item is added to list of menu items' do
is_expected.not_to be_nil
end
end
context 'when config dependency_proxy is not enabled' do
let(:dependency_enabled) { false }
it 'the menu item is not added to list of menu items' do
is_expected.to be_nil
end
end
end
context 'when config dependency_proxy is not enabled' do
let(:dependency_enabled) { false }
context 'when user cannot read dependency proxy' do
let(:user) { nil }
let(:dependency_enabled) { true }
it 'the menu item is not added to list of menu items' do
is_expected.to be_nil
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment