summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorShinya Maeda <shinya@gitlab.com>2017-06-28 21:28:29 +0900
committerShinya Maeda <shinya@gitlab.com>2017-07-05 18:36:19 +0900
commita91f581e6d8434f420ac3277be11214a4d087850 (patch)
tree9542594aaa55a4847e1189cf2a5e5fed00010bdc /app
parentdf6e51fb7dfa81b982b87d47a49f3aa615fae8f1 (diff)
downloadgitlab-ce-a91f581e6d8434f420ac3277be11214a4d087850.tar.gz
Revert extra validation for duplication between same keys on a submit
Diffstat (limited to 'app')
-rw-r--r--app/controllers/projects/pipeline_schedules_controller.rb3
-rw-r--r--app/services/ci/create_pipeline_schedule_service.rb30
2 files changed, 3 insertions, 30 deletions
diff --git a/app/controllers/projects/pipeline_schedules_controller.rb b/app/controllers/projects/pipeline_schedules_controller.rb
index 86c9628d917..9bcdfc2b510 100644
--- a/app/controllers/projects/pipeline_schedules_controller.rb
+++ b/app/controllers/projects/pipeline_schedules_controller.rb
@@ -33,8 +33,7 @@ class Projects::PipelineSchedulesController < Projects::ApplicationController
end
def update
- if Ci::CreatePipelineScheduleService
- .new(@project, current_user, schedule_params).update(schedule)
+ if schedule.update(schedule_params)
redirect_to namespace_project_pipeline_schedules_path(@project.namespace.becomes(Namespace), @project)
else
render :edit
diff --git a/app/services/ci/create_pipeline_schedule_service.rb b/app/services/ci/create_pipeline_schedule_service.rb
index 4c9cb5c66c6..cd40deb6187 100644
--- a/app/services/ci/create_pipeline_schedule_service.rb
+++ b/app/services/ci/create_pipeline_schedule_service.rb
@@ -1,39 +1,13 @@
module Ci
class CreatePipelineScheduleService < BaseService
def execute
- pipeline_schedule = project.pipeline_schedules.build(pipeline_schedule_params)
-
- if variable_keys_duplicated?
- pipeline_schedule.errors.add('variables.key', "keys are duplicated")
-
- return pipeline_schedule
- end
-
- pipeline_schedule.save
- pipeline_schedule
- end
-
- def update(pipeline_schedule)
- if variable_keys_duplicated?
- pipeline_schedule.errors.add('variables.key', "keys are duplicated")
-
- return false
- end
-
- pipeline_schedule.update(pipeline_schedule_params)
+ project.pipeline_schedules.create(pipeline_schedule_params)
end
private
def pipeline_schedule_params
- @pipeline_schedule_params ||= params.merge(owner: current_user)
- end
-
- def variable_keys_duplicated?
- attributes = pipeline_schedule_params['variables_attributes']
- return false unless attributes.is_a?(Array)
-
- attributes.map { |v| v['key'] }.uniq.length != attributes.length
+ params.merge(owner: current_user)
end
end
end