BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
22d8460b
Commit
22d8460b
authored
Jul 04, 2017
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add some validations to persisted stage model
parent
a17c90b2
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
8 deletions
+11
-8
stage.rb
app/models/ci/stage.rb
+5
-0
has_status.rb
app/models/concerns/has_status.rb
+4
-8
stages.rb
spec/factories/ci/stages.rb
+2
-0
No files found.
app/models/ci/stage.rb
View file @
22d8460b
module
Ci
class
Stage
<
ActiveRecord
::
Base
extend
Ci
::
Model
include
Importable
include
HasStatus
enumerated_status!
...
...
@@ -10,5 +11,9 @@ module Ci
has_many
:statuses
,
class_name:
'CommitStatus'
,
foreign_key: :commit_id
has_many
:builds
,
foreign_key: :commit_id
validates
:project
,
presence:
true
,
unless: :importing?
validates
:pipeline
,
presence:
true
,
unless: :importing?
validates
:name
,
presence:
true
,
unless: :importing?
end
end
app/models/concerns/has_status.rb
View file @
22d8460b
...
...
@@ -12,6 +12,10 @@ module HasStatus
failed:
4
,
canceled:
5
,
skipped:
6
,
manual:
7
}
class_methods
do
def
enumerated_status!
enum
status:
HasStatus
::
STATUSES_ENUM
end
def
status_sql
scope_relevant
=
respond_to?
(
:exclude_ignored
)
?
exclude_ignored
:
all
scope_warnings
=
respond_to?
(
:failed_but_allowed
)
?
failed_but_allowed
:
none
...
...
@@ -56,14 +60,6 @@ module HasStatus
def
all_state_names
state_machines
.
values
.
flat_map
(
&
:states
).
flat_map
{
|
s
|
s
.
map
(
&
:name
)
}
end
private
def
enumerated_status!
@status_strategy
=
:enumerator
enum
status:
HasStatus
::
STATUSES_ENUM
end
end
included
do
...
...
spec/factories/ci/stages.rb
View file @
22d8460b
...
...
@@ -19,6 +19,8 @@ FactoryGirl.define do
factory
:ci_stage_entity
,
class:
Ci
::
Stage
do
project
factory: :empty_project
pipeline
factory: :ci_empty_pipeline
name
'test'
status
'pending'
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment