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:
authorGrzegorz Bizon <grzesiek.bizon@gmail.com>2017-10-11 16:32:19 +0300
committerGrzegorz Bizon <grzesiek.bizon@gmail.com>2017-11-06 13:04:09 +0300
commit164b1df59025e9685e243dd89d943ff5b1122b44 (patch)
treea26685f9fa72e83320ff9d543f790afe449a076a /app/models/commit_status.rb
parente2828a60679495d716ed3824959794f4d5fbf5bb (diff)
Extract ensure stage service from commit status class
Diffstat (limited to 'app/models/commit_status.rb')
-rw-r--r--app/models/commit_status.rb30
1 files changed, 3 insertions, 27 deletions
diff --git a/app/models/commit_status.rb b/app/models/commit_status.rb
index 12e187024dd..6b07dbdf3ea 100644
--- a/app/models/commit_status.rb
+++ b/app/models/commit_status.rb
@@ -50,13 +50,9 @@ class CommitStatus < ActiveRecord::Base
#
# These are pages deployments and external statuses.
#
- before_create do |status|
- next if status.stage_id.present? || importing?
-
- ensure_pipeline_stage! do |stage|
- status.run_after_commit do
- StageUpdateWorker.perform_async(stage.id)
- end
+ before_create unless: :importing? do
+ Ci::EnsureStageService.new(project, user).execute(self) do |stage|
+ self.run_after_commit { StageUpdateWorker.perform_async(stage.id) }
end
end
@@ -188,24 +184,4 @@ class CommitStatus < ActiveRecord::Base
v =~ /\d+/ ? v.to_i : v
end
end
-
- private
-
- def ensure_pipeline_stage!
- (find_stage || create_stage!).tap do |stage|
- self.stage_id = stage.id
-
- yield stage
- end
- end
-
- def find_stage
- pipeline.stages.find_by(name: stage)
- end
-
- def create_stage!
- Ci::Stage.create!(name: stage,
- pipeline: pipeline,
- project: project)
- end
end