Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-07-28 21:11:01 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-07-28 21:11:01 +0300
commit7c5f1bfac791045e54386b9c9bb56ee24afc68ca (patch)
treea11c8dff3994899c25acacb383c0a70522a24cd1 /spec/controllers
parentd62fd6e04c272d48dccde4033529ca97c27502f6 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/controllers')
-rw-r--r--spec/controllers/projects/pipeline_schedules_controller_spec.rb38
1 files changed, 34 insertions, 4 deletions
diff --git a/spec/controllers/projects/pipeline_schedules_controller_spec.rb b/spec/controllers/projects/pipeline_schedules_controller_spec.rb
index 6d810fdcd51..e4d87daa8d7 100644
--- a/spec/controllers/projects/pipeline_schedules_controller_spec.rb
+++ b/spec/controllers/projects/pipeline_schedules_controller_spec.rb
@@ -6,8 +6,8 @@ RSpec.describe Projects::PipelineSchedulesController, feature_category: :continu
include AccessMatchersForController
let_it_be(:user) { create(:user) }
- let_it_be(:project) { create(:project, :public, :repository) }
- let_it_be(:pipeline_schedule) { create(:ci_pipeline_schedule, project: project) }
+ let_it_be_with_reload(:project) { create(:project, :public, :repository) }
+ let_it_be_with_reload(:pipeline_schedule) { create(:ci_pipeline_schedule, project: project) }
before do
project.add_developer(user)
@@ -137,6 +137,20 @@ RSpec.describe Projects::PipelineSchedulesController, feature_category: :continu
expect(v.variable_type).to eq("file")
end
end
+
+ context 'when the user is not allowed to create a pipeline schedule with variables' do
+ before do
+ project.update!(restrict_user_defined_variables: true)
+ end
+
+ it 'does not create a new schedule' do
+ expect { go }
+ .to not_change { Ci::PipelineSchedule.count }
+ .and not_change { Ci::PipelineScheduleVariable.count }
+
+ expect(response).to have_gitlab_http_status(:ok)
+ end
+ end
end
context 'when variables_attributes has two variables and duplicated' do
@@ -149,8 +163,8 @@ RSpec.describe Projects::PipelineSchedulesController, feature_category: :continu
it 'returns an error that the keys of variable are duplicated' do
expect { go }
- .to change { Ci::PipelineSchedule.count }.by(0)
- .and change { Ci::PipelineScheduleVariable.count }.by(0)
+ .to not_change { Ci::PipelineSchedule.count }
+ .and not_change { Ci::PipelineScheduleVariable.count }
expect(assigns(:schedule).errors['variables']).not_to be_empty
end
@@ -213,6 +227,22 @@ RSpec.describe Projects::PipelineSchedulesController, feature_category: :continu
expect(pipeline_schedule.variables.last.key).to eq('AAA')
expect(pipeline_schedule.variables.last.value).to eq('AAA123')
end
+
+ context 'when the user is not allowed to update pipeline schedule variables' do
+ before do
+ project.update!(restrict_user_defined_variables: true)
+ end
+
+ it 'does not update the schedule' do
+ expect { go }
+ .to not_change { Ci::PipelineScheduleVariable.count }
+
+ expect(response).to have_gitlab_http_status(:ok)
+
+ pipeline_schedule.reload
+ expect(pipeline_schedule.variables).to be_empty
+ end
+ end
end
context 'when params include two duplicated variables' do