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:
authorShinya Maeda <shinya@gitlab.com>2017-08-21 20:21:37 +0300
committerShinya Maeda <shinya@gitlab.com>2017-09-04 15:10:34 +0300
commit03f72f0f419b7e05fe9207c90b92b02ef7291cd1 (patch)
tree944103f6d4c8bb2ed8dec2db36aeecf1b2b7b2f7 /lib/api/pipeline_schedules.rb
parent278ac9ed5db6b191b42b52457492e551759f9d7d (diff)
Add spec (Halfway)
Diffstat (limited to 'lib/api/pipeline_schedules.rb')
-rw-r--r--lib/api/pipeline_schedules.rb103
1 files changed, 50 insertions, 53 deletions
diff --git a/lib/api/pipeline_schedules.rb b/lib/api/pipeline_schedules.rb
index e82b974c8cd..ffb9a09834d 100644
--- a/lib/api/pipeline_schedules.rb
+++ b/lib/api/pipeline_schedules.rb
@@ -120,74 +120,71 @@ module API
destroy_conditionally!(pipeline_schedule)
end
+ desc 'Create a new pipeline schedule variable' do
+ success Entities::Variable
+ end
params do
requires :pipeline_schedule_id, type: Integer, desc: 'The pipeline schedule id'
+ requires :key, type: String, desc: 'The key of the variable'
+ requires :value, type: String, desc: 'The value of the variable'
end
- resource :variables, requirements: { pipeline_schedule_id: %r{[^/]+} } do
- desc 'Create a new pipeline schedule variable' do
- success Entities::PipelineScheduleDetails
- end
- params do
- requires :key, type: String, desc: 'The key of the variable'
- requires :value, type: String, desc: 'The value of the variable'
- end
- post ':id/pipeline_schedules/:pipeline_schedule_id/variables' do
- authorize! :read_pipeline_schedule, user_project
-
- not_found!('PipelineSchedule') unless pipeline_schedule
- authorize! :update_pipeline_schedule, pipeline_schedule
+ post ':id/pipeline_schedules/:pipeline_schedule_id/variables' do
+ authorize! :read_pipeline_schedule, user_project
- variable_params = declared_params(include_missing: false)
- variable = pipeline_schedule.variables.create(variable_params)
+ not_found!('PipelineSchedule') unless pipeline_schedule
+ authorize! :update_pipeline_schedule, pipeline_schedule
- if variable.persisted?
- present variable, with: Entities::Variable
- else
- render_validation_error!(variable)
- end
+ variable_params = declared_params(include_missing: false)
+ variable = pipeline_schedule.variables.create(variable_params)
+ if variable.persisted?
+ present variable, with: Entities::Variable
+ else
+ render_validation_error!(variable)
end
+ end
- desc 'Edit a pipeline schedule variable' do
- success Entities::PipelineScheduleDetails
- end
- params do
- optional :key, type: String, desc: 'The key of the variable'
- optional :value, type: String, desc: 'The value of the variable'
- end
- put ':id/pipeline_schedules/:pipeline_schedule_id/variables/:key' do
- authorize! :read_pipeline_schedule, user_project
+ desc 'Edit a pipeline schedule variable' do
+ success Entities::Variable
+ end
+ params do
+ requires :pipeline_schedule_id, type: Integer, desc: 'The pipeline schedule id'
+ requires :key, type: String, desc: 'The key of the variable'
+ optional :value, type: String, desc: 'The value of the variable'
+ end
+ put ':id/pipeline_schedules/:pipeline_schedule_id/variables/:key' do
+ authorize! :read_pipeline_schedule, user_project
- not_found!('PipelineSchedule') unless pipeline_schedule
- authorize! :update_pipeline_schedule, pipeline_schedule
+ not_found!('PipelineSchedule') unless pipeline_schedule
+ authorize! :update_pipeline_schedule, pipeline_schedule
- variable = pipeline_schedule.variables.find_by(key: params[:key])
- not_found!('Variable') unless variable
+ variable = pipeline_schedule.variables.find_by(key: params[:key])
+ not_found!('Variable') unless variable
- if variable.update(declared_params(include_missing: false))
- present variable, with: Entities::Variable
- else
- render_validation_error!(variable)
- end
+ if variable.update(declared_params(include_missing: false))
+ present variable, with: Entities::Variable
+ else
+ render_validation_error!(variable)
end
+ end
- desc 'Delete a pipeline schedule variable' do
- success Entities::PipelineScheduleDetails
- end
- params do
- requires :key, type: String, desc: 'The key of the variable'
- end
- delete ':id/pipeline_schedules/:pipeline_schedule_id/variables/:key' do
- authorize! :read_pipeline_schedule, user_project
+ desc 'Delete a pipeline schedule variable' do
+ success Entities::Variable
+ end
+ params do
+ requires :pipeline_schedule_id, type: Integer, desc: 'The pipeline schedule id'
+ requires :key, type: String, desc: 'The key of the variable'
+ end
+ delete ':id/pipeline_schedules/:pipeline_schedule_id/variables/:key' do
+ authorize! :read_pipeline_schedule, user_project
- not_found!('PipelineSchedule') unless pipeline_schedule
- authorize! :admin_pipeline_schedule, pipeline_schedule
+ not_found!('PipelineSchedule') unless pipeline_schedule
+ authorize! :admin_pipeline_schedule, pipeline_schedule
- variable = pipeline_schedule.variables.find_by(key: params[:key])
- not_found!('Variable') unless variable
+ variable = pipeline_schedule.variables.find_by(key: params[:key])
+ not_found!('Variable') unless variable
- status :accepted
- present variable, with: Entities::Variable
- end
+ status :accepted
+ present variable, with: Entities::Variable
end
end