Skip to content
Snippets Groups Projects
Commit a4511879 authored by Eduardo Bonet's avatar Eduardo Bonet :speech_balloon:
Browse files

Shows Model experiments menu only if enabled

If model experiments is disabled, or user does not have access to model
experiments in that project, hides the menu.

Changelog: changed
parent 5f239e59
No related branches found
No related tags found
1 merge request!121670Hides model experiments menu if it is not enabled
...@@ -91,7 +91,7 @@ def harbor_registry_menu_item ...@@ -91,7 +91,7 @@ def harbor_registry_menu_item
end end
def model_experiments_menu_item def model_experiments_menu_item
if Feature.disabled?(:ml_experiment_tracking, context.project) unless can?(context.current_user, :read_model_experiments, context.project)
return ::Sidebars::NilMenuItem.new(item_id: :model_experiments) return ::Sidebars::NilMenuItem.new(item_id: :model_experiments)
end end
......
...@@ -185,18 +185,25 @@ ...@@ -185,18 +185,25 @@
describe 'Model experiments' do describe 'Model experiments' do
let(:item_id) { :model_experiments } let(:item_id) { :model_experiments }
context 'when :ml_experiment_tracking is enabled' do before do
it 'shows the menu item' do allow(Ability).to receive(:allowed?).and_call_original
stub_feature_flags(ml_experiment_tracking: true) allow(Ability).to receive(:allowed?)
.with(user, :read_model_experiments, project)
.and_return(model_experiments_enabled)
end
context 'when user can access model experiments' do
let(:model_experiments_enabled) { true }
it 'shows the menu item' do
is_expected.not_to be_nil is_expected.not_to be_nil
end end
end end
context 'when :ml_experiment_tracking is disabled' do context 'when user does not have access model experiments' do
it 'does not show the menu item' do let(:model_experiments_enabled) { false }
stub_feature_flags(ml_experiment_tracking: false)
it 'does not show the menu item' do
is_expected.to be_nil is_expected.to be_nil
end end
end end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment