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
end
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)
end
......
......@@ -185,18 +185,25 @@
describe 'Model experiments' do
let(:item_id) { :model_experiments }
context 'when :ml_experiment_tracking is enabled' do
it 'shows the menu item' do
stub_feature_flags(ml_experiment_tracking: true)
before do
allow(Ability).to receive(:allowed?).and_call_original
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
end
end
context 'when :ml_experiment_tracking is disabled' do
it 'does not show the menu item' do
stub_feature_flags(ml_experiment_tracking: false)
context 'when user does not have access model experiments' do
let(:model_experiments_enabled) { false }
it 'does not show the menu item' do
is_expected.to be_nil
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