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 ...@@ -52,7 +52,7 @@ module Sidebars
end end
def dependency_proxy_menu_item 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) return ::Sidebars::NilMenuItem.new(item_id: :dependency_proxy)
end end
......
...@@ -137,16 +137,27 @@ RSpec.describe Sidebars::Groups::Menus::PackagesRegistriesMenu do ...@@ -137,16 +137,27 @@ RSpec.describe Sidebars::Groups::Menus::PackagesRegistriesMenu do
stub_config(dependency_proxy: { enabled: dependency_enabled }) stub_config(dependency_proxy: { enabled: dependency_enabled })
end end
context 'when config dependency_proxy is enabled' do context 'when user can read dependency proxy' do
let(:dependency_enabled) { true } context 'when config dependency_proxy is enabled' do
let(:dependency_enabled) { true }
it 'the menu item is added to list of menu items' do it 'the menu item is added to list of menu items' do
is_expected.not_to be_nil 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
end end
context 'when config dependency_proxy is not enabled' do context 'when user cannot read dependency proxy' do
let(:dependency_enabled) { false } let(:user) { nil }
let(:dependency_enabled) { true }
it 'the menu item is not added to list of menu items' do it 'the menu item is not added to list of menu items' do
is_expected.to be_nil 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