diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-09-28 01:36:15 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-09-28 01:36:15 +0300 |
commit | 7bcb9f25dad089706e8aaef5c87cb42ab804b827 (patch) | |
tree | b30bc0adbaa9d1103dad002b5387d13983c0d422 /spec/requests | |
parent | 5b91f2a1e51c291fb84ea60766791684fa982f22 (diff) |
Add latest changes from gitlab-org/security/gitlab@16-4-stable-ee
Diffstat (limited to 'spec/requests')
-rw-r--r-- | spec/requests/projects/ml/candidates_controller_spec.rb | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/spec/requests/projects/ml/candidates_controller_spec.rb b/spec/requests/projects/ml/candidates_controller_spec.rb index 4c7491970e1..78f31be26d1 100644 --- a/spec/requests/projects/ml/candidates_controller_spec.rb +++ b/spec/requests/projects/ml/candidates_controller_spec.rb @@ -6,7 +6,11 @@ RSpec.describe Projects::Ml::CandidatesController, feature_category: :mlops do let_it_be(:project) { create(:project, :repository) } let_it_be(:user) { project.first_owner } let_it_be(:experiment) { create(:ml_experiments, project: project, user: user) } - let_it_be(:candidate) { create(:ml_candidates, experiment: experiment, user: user, project: project) } + let_it_be(:candidate) do + create(:ml_candidates, experiment: experiment, user: user, project: project).tap do |c| + c.update!(ci_build: create(:ci_build)) + end + end let(:ff_value) { true } let(:candidate_iid) { candidate.iid } @@ -47,7 +51,13 @@ RSpec.describe Projects::Ml::CandidatesController, feature_category: :mlops do end describe 'GET show' do + let(:can_read_build) { true } + before do + allow(Ability).to receive(:allowed?) + .with(user, :read_build, candidate.ci_build) + .and_return(can_read_build) + show_candidate end @@ -64,6 +74,20 @@ RSpec.describe Projects::Ml::CandidatesController, feature_category: :mlops do expect { show_candidate }.not_to exceed_all_query_limit(control_count) end + context 'when user has permission to read the build' do + it 'includes ci build info' do + expect(assigns[:include_ci_info]).to eq(true) + end + end + + context 'when user has no permission to read the build' do + let(:can_read_build) { false } + + it 'sets include_ci_job to false' do + expect(assigns[:include_ci_info]).to eq(false) + end + end + it_behaves_like '404 if candidate does not exist' it_behaves_like 'requires read_model_experiments' end |