summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorGrzegorz Bizon <grzesiek.bizon@gmail.com>2018-04-17 12:56:04 +0200
committerGrzegorz Bizon <grzesiek.bizon@gmail.com>2018-04-24 11:07:37 +0200
commitf0d59b95f1da0293345705fe0b2c629b911a5b5e (patch)
tree258cb7e7c36257540cf9ee124f041fe66cd07d0b /app
parent43dd213b8c0c1d306ace25f6d307b7e777c944cd (diff)
downloadgitlab-ce-f0d59b95f1da0293345705fe0b2c629b911a5b5e.tar.gz
Validate presence of a stage index in the model
Diffstat (limited to 'app')
-rw-r--r--app/models/ci/stage.rb9
-rw-r--r--app/services/ci/ensure_stage_service.rb1
2 files changed, 7 insertions, 3 deletions
diff --git a/app/models/ci/stage.rb b/app/models/ci/stage.rb
index 75b8ea2a371..ea0b7d6655b 100644
--- a/app/models/ci/stage.rb
+++ b/app/models/ci/stage.rb
@@ -13,9 +13,12 @@ module Ci
has_many :statuses, class_name: 'CommitStatus', foreign_key: :stage_id
has_many :builds, foreign_key: :stage_id
- validates :project, presence: true, unless: :importing?
- validates :pipeline, presence: true, unless: :importing?
- validates :name, presence: true, unless: :importing?
+ with_options unless: :importing? do
+ validates :project, presence: true
+ validates :pipeline, presence: true
+ validates :name, presence: true
+ validates :index, presence: true
+ end
after_initialize do |stage|
self.status = DEFAULT_STATUS if self.status.nil?
diff --git a/app/services/ci/ensure_stage_service.rb b/app/services/ci/ensure_stage_service.rb
index 87f19b333de..447cbfd73f5 100644
--- a/app/services/ci/ensure_stage_service.rb
+++ b/app/services/ci/ensure_stage_service.rb
@@ -42,6 +42,7 @@ module Ci
def create_stage
Ci::Stage.create!(name: @build.stage,
+ index: @build.stage_idx,
pipeline: @build.pipeline,
project: @build.project)
end