summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShinya Maeda <gitlab.shinyamaeda@gmail.com>2017-05-13 03:37:09 +0900
committerShinya Maeda <gitlab.shinyamaeda@gmail.com>2017-05-30 23:55:08 +0900
commitf8cb5fd65a8ed00f38368a6a050c940e72cc6f3e (patch)
tree4ec38d79506a154e2ad79728a8df3371e256047d
parent8743f765abc2281c664792f5016747f54d0fb7aa (diff)
downloadgitlab-ce-f8cb5fd65a8ed00f38368a6a050c940e72cc6f3e.tar.gz
Add own! method on PipleineSchedule
-rw-r--r--app/models/ci/pipeline_schedule.rb4
-rw-r--r--lib/api/pipeline_schedules.rb2
2 files changed, 5 insertions, 1 deletions
diff --git a/app/models/ci/pipeline_schedule.rb b/app/models/ci/pipeline_schedule.rb
index 58cf62513d3..623275b7269 100644
--- a/app/models/ci/pipeline_schedule.rb
+++ b/app/models/ci/pipeline_schedule.rb
@@ -24,6 +24,10 @@ module Ci
owner == current_user
end
+ def own!(user)
+ update!(owner: user)
+ end
+
def inactive?
!active?
end
diff --git a/lib/api/pipeline_schedules.rb b/lib/api/pipeline_schedules.rb
index 6e6bbb29e3a..81b88b17041 100644
--- a/lib/api/pipeline_schedules.rb
+++ b/lib/api/pipeline_schedules.rb
@@ -100,7 +100,7 @@ module API
pipeline_schedule = user_project.pipeline_schedules.find(params.delete(:pipeline_schedule_id))
return not_found!('PipelineSchedule') unless pipeline_schedule
- if pipeline_schedule.update(owner: current_user)
+ if pipeline_schedule.own!(current_user)
status :ok
present pipeline_schedule, with: Entities::PipelineSchedule
else