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,6 +137,7 @@ RSpec.describe Sidebars::Groups::Menus::PackagesRegistriesMenu do
stub_config(dependency_proxy: { enabled: dependency_enabled })
end
context 'when user can read dependency proxy' do
context 'when config dependency_proxy is enabled' do
let(:dependency_enabled) { true }
......@@ -153,6 +154,16 @@ RSpec.describe Sidebars::Groups::Menus::PackagesRegistriesMenu do
end
end
end
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
end
end
end
end
private
......
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