Commit cc1c7442 authored by Dylan Griffith's avatar Dylan Griffith

Merge branch...

Merge branch '342685-remove-dependency-proxy-menu-entry-when-user-can-t-access-the-page' into 'master'

Remove dependency proxy menu when user is not authorised

See merge request gitlab-org/gitlab!72687
parents 5612e4e5 e899dbf4
......@@ -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