diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-06-05 18:09:47 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-06-05 18:09:47 +0300 |
commit | 18e9429b63f9a095b1ba3606856537b9ca291eac (patch) | |
tree | c675e9c6ef0209b4e8ebc7593165536d277a05fc /spec/requests | |
parent | 8dbc985bec96cad1e9a3315f38be27eb2374e5dc (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/requests')
-rw-r--r-- | spec/requests/projects/ml/candidates_controller_spec.rb | 18 | ||||
-rw-r--r-- | spec/requests/projects/ml/experiments_controller_spec.rb | 48 |
2 files changed, 27 insertions, 39 deletions
diff --git a/spec/requests/projects/ml/candidates_controller_spec.rb b/spec/requests/projects/ml/candidates_controller_spec.rb index 78c8e99e3f3..eec7af99063 100644 --- a/spec/requests/projects/ml/candidates_controller_spec.rb +++ b/spec/requests/projects/ml/candidates_controller_spec.rb @@ -10,11 +10,13 @@ RSpec.describe Projects::Ml::CandidatesController, feature_category: :mlops do let(:ff_value) { true } let(:candidate_iid) { candidate.iid } + let(:model_experiments_enabled) { true } before do - stub_feature_flags(ml_experiment_tracking: false) - stub_feature_flags(ml_experiment_tracking: project) if ff_value - + allow(Ability).to receive(:allowed?).and_call_original + allow(Ability).to receive(:allowed?) + .with(user, :read_model_experiments, project) + .and_return(model_experiments_enabled) sign_in(user) end @@ -32,9 +34,9 @@ RSpec.describe Projects::Ml::CandidatesController, feature_category: :mlops do end end - shared_examples '404 if feature flag disabled' do - context 'when :ml_experiment_tracking disabled' do - let(:ff_value) { false } + shared_examples '404 when model experiments is unavailable' do + context 'when user does not have access' do + let(:model_experiments_enabled) { false } it_behaves_like 'renders 404' end @@ -59,7 +61,7 @@ RSpec.describe Projects::Ml::CandidatesController, feature_category: :mlops do end it_behaves_like '404 if candidate does not exist' - it_behaves_like '404 if feature flag disabled' + it_behaves_like '404 when model experiments is unavailable' end describe 'DELETE #destroy' do @@ -81,7 +83,7 @@ RSpec.describe Projects::Ml::CandidatesController, feature_category: :mlops do end it_behaves_like '404 if candidate does not exist' - it_behaves_like '404 if feature flag disabled' + it_behaves_like '404 when model experiments is unavailable' end private diff --git a/spec/requests/projects/ml/experiments_controller_spec.rb b/spec/requests/projects/ml/experiments_controller_spec.rb index 5a8496a250a..e2d26e84f75 100644 --- a/spec/requests/projects/ml/experiments_controller_spec.rb +++ b/spec/requests/projects/ml/experiments_controller_spec.rb @@ -3,27 +3,25 @@ require 'spec_helper' RSpec.describe Projects::Ml::ExperimentsController, feature_category: :mlops do - let_it_be(:project_with_feature) { create(:project, :repository) } - let_it_be(:user) { project_with_feature.first_owner } - let_it_be(:project_without_feature) do - create(:project, :repository).tap { |p| p.add_developer(user) } - end - + let_it_be(:project) { create(:project, :repository) } + let_it_be(:user) { project.first_owner } let_it_be(:experiment) do - create(:ml_experiments, project: project_with_feature, user: user).tap do |e| + create(:ml_experiments, project: project, user: user).tap do |e| create(:ml_candidates, experiment: e, user: user) end end let(:params) { basic_params } let(:ff_value) { true } - let(:project) { project_with_feature } let(:basic_params) { { namespace_id: project.namespace.to_param, project_id: project } } let(:experiment_iid) { experiment.iid } + let(:model_experiments_enabled) { true } before do - stub_feature_flags(ml_experiment_tracking: false) - stub_feature_flags(ml_experiment_tracking: project_with_feature) if ff_value + allow(Ability).to receive(:allowed?).and_call_original + allow(Ability).to receive(:allowed?) + .with(user, :read_model_experiments, project) + .and_return(model_experiments_enabled) sign_in(user) end @@ -42,9 +40,9 @@ RSpec.describe Projects::Ml::ExperimentsController, feature_category: :mlops do end end - shared_examples '404 if feature flag disabled' do - context 'when :ml_experiment_tracking disabled' do - let(:ff_value) { false } + shared_examples '404 when model experiments is unavailable' do + context 'when user does not have access' do + let(:model_experiments_enabled) { false } it_behaves_like 'renders 404' end @@ -71,7 +69,7 @@ RSpec.describe Projects::Ml::ExperimentsController, feature_category: :mlops do describe 'pagination' do let_it_be(:experiments) do - create_list(:ml_experiments, 3, project: project_with_feature) + create_list(:ml_experiments, 3, project: project) end let(:params) { basic_params.merge(id: experiment.iid) } @@ -102,19 +100,7 @@ RSpec.describe Projects::Ml::ExperimentsController, feature_category: :mlops do end end - context 'when :ml_experiment_tracking is disabled for the project' do - let(:project) { project_without_feature } - - before do - list_experiments - end - - it 'responds with a 404' do - expect(response).to have_gitlab_http_status(:not_found) - end - end - - it_behaves_like '404 if feature flag disabled' do + it_behaves_like '404 when model experiments is unavailable' do before do list_experiments end @@ -225,7 +211,7 @@ RSpec.describe Projects::Ml::ExperimentsController, feature_category: :mlops do end it_behaves_like '404 if experiment does not exist' - it_behaves_like '404 if feature flag disabled' + it_behaves_like '404 when model experiments is unavailable' end end @@ -257,14 +243,14 @@ RSpec.describe Projects::Ml::ExperimentsController, feature_category: :mlops do end it_behaves_like '404 if experiment does not exist' - it_behaves_like '404 if feature flag disabled' + it_behaves_like '404 when model experiments is unavailable' end end end describe 'DELETE #destroy' do let_it_be(:experiment_for_deletion) do - create(:ml_experiments, project: project_with_feature, user: user).tap do |e| + create(:ml_experiments, project: project, user: user).tap do |e| create(:ml_candidates, experiment: e, user: user) end end @@ -282,7 +268,7 @@ RSpec.describe Projects::Ml::ExperimentsController, feature_category: :mlops do end it_behaves_like '404 if experiment does not exist' - it_behaves_like '404 if feature flag disabled' + it_behaves_like '404 when model experiments is unavailable' end private |