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
0605cdd7
Commit
0605cdd7
authored
Jul 20, 2017
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement proper associations with a persisted stage
parent
c7a7ef04
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
2 deletions
+23
-2
stage.rb
app/models/ci/stage.rb
+2
-2
stage_spec.rb
spec/models/ci/stage_spec.rb
+21
-0
No files found.
app/models/ci/stage.rb
View file @
0605cdd7
...
...
@@ -9,8 +9,8 @@ module Ci
belongs_to
:project
belongs_to
:pipeline
has_many
:
statuses
,
class_name:
'CommitStatus'
,
foreign_key: :commit
_id
has_many
:builds
,
foreign_key: :
commit
_id
has_many
:
commit_statuses
,
foreign_key: :stage
_id
has_many
:builds
,
foreign_key: :
stage
_id
validates
:project
,
presence:
true
,
unless: :importing?
validates
:pipeline
,
presence:
true
,
unless: :importing?
...
...
spec/models/ci/stage_spec.rb
View file @
0605cdd7
require
'spec_helper'
describe
Ci
::
Stage
,
:models
do
describe
'associations'
do
let
(
:stage
)
{
create
(
:ci_stage_entity
)
}
before
do
create
(
:ci_build
,
stage_id:
stage
.
id
)
create
(
:commit_status
,
stage_id:
stage
.
id
)
end
describe
'#commit_statuses'
do
it
'returns all commit statuses'
do
expect
(
stage
.
commit_statuses
.
count
).
to
be
2
end
end
describe
'#builds'
do
it
'returns only builds'
do
expect
(
stage
.
builds
).
to
be_one
end
end
end
describe
'#status'
do
context
'when stage is pending'
do
let
(
:stage
)
{
create
(
:ci_stage_entity
,
status:
'pending'
)
}
...
...
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