Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Jérome Perrin
gitlab-ce
Commits
e66b0414
Commit
e66b0414
authored
Jan 18, 2017
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve readability of specs for pipeline stages
parent
cff9c16b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
64 additions
and
39 deletions
+64
-39
spec/models/ci/pipeline_spec.rb
spec/models/ci/pipeline_spec.rb
+64
-39
No files found.
spec/models/ci/pipeline_spec.rb
View file @
e66b0414
...
@@ -122,55 +122,80 @@ describe Ci::Pipeline, models: true do
...
@@ -122,55 +122,80 @@ describe Ci::Pipeline, models: true do
end
end
end
end
describe
'
#
stages'
do
describe
'
pipeline
stages'
do
before
do
before
do
create
(
:commit_status
,
pipeline:
pipeline
,
stage:
'build'
,
name:
'linux'
,
stage_idx:
0
,
status:
'success'
)
create
(
:commit_status
,
pipeline:
pipeline
,
create
(
:commit_status
,
pipeline:
pipeline
,
stage:
'build'
,
name:
'mac'
,
stage_idx:
0
,
status:
'failed'
)
stage:
'build'
,
create
(
:commit_status
,
pipeline:
pipeline
,
stage:
'deploy'
,
name:
'staging'
,
stage_idx:
2
,
status:
'running'
)
name:
'linux'
,
create
(
:commit_status
,
pipeline:
pipeline
,
stage:
'test'
,
name:
'rspec'
,
stage_idx:
1
,
status:
'success'
)
stage_idx:
0
,
end
status:
'success'
)
subject
{
pipeline
.
stages
}
create
(
:commit_status
,
pipeline:
pipeline
,
stage:
'build'
,
context
'stages list'
do
name:
'mac'
,
it
'returns ordered list of stages'
do
stage_idx:
0
,
expect
(
subject
.
map
(
&
:name
)).
to
eq
(
%w[build test deploy]
)
status:
'failed'
)
create
(
:commit_status
,
pipeline:
pipeline
,
stage:
'deploy'
,
name:
'staging'
,
stage_idx:
2
,
status:
'running'
)
create
(
:commit_status
,
pipeline:
pipeline
,
stage:
'test'
,
name:
'rspec'
,
stage_idx:
1
,
status:
'success'
)
end
describe
'#stages'
do
subject
{
pipeline
.
stages
}
context
'stages list'
do
it
'returns ordered list of stages'
do
expect
(
subject
.
map
(
&
:name
)).
to
eq
(
%w[build test deploy]
)
end
end
end
end
it
'returns a valid number of stages'
do
context
'stages with statuses'
do
expect
(
pipeline
.
stages_count
).
to
eq
(
3
)
let
(
:statuses
)
do
end
subject
.
map
{
|
stage
|
[
stage
.
name
,
stage
.
status
]
}
end
it
'returns a valid names of stages'
do
it
'returns list of stages with correct statuses'
do
expect
(
pipeline
.
stages_name
).
to
eq
([
'build'
,
'test'
,
'deploy'
])
expect
(
statuses
).
to
eq
([[
'build'
,
'failed'
],
end
[
'test'
,
'success'
],
[
'deploy'
,
'running'
]])
end
context
'stages with statuses'
do
context
'when commit status is retried'
do
let
(
:statuses
)
do
before
do
subject
.
map
do
|
stage
|
create
(
:commit_status
,
pipeline:
pipeline
,
[
stage
.
name
,
stage
.
status
]
stage:
'build'
,
name:
'mac'
,
stage_idx:
0
,
status:
'success'
)
end
it
'ignores the previous state'
do
expect
(
statuses
).
to
eq
([[
'build'
,
'success'
],
[
'test'
,
'success'
],
[
'deploy'
,
'running'
]])
end
end
end
end
end
end
it
'returns list of stages with statuses'
do
describe
'#stages_count'
do
expect
(
statuses
).
to
eq
([[
'build'
,
'failed'
],
it
'returns a valid number of stages'
do
[
'test'
,
'success'
],
expect
(
pipeline
.
stages_count
).
to
eq
(
3
)
[
'deploy'
,
'running'
]
])
end
end
end
context
'when build is retried'
do
describe
'#stages_name'
do
before
do
it
'returns a valid names of stages'
do
create
(
:commit_status
,
pipeline:
pipeline
,
stage:
'build'
,
name:
'mac'
,
stage_idx:
0
,
status:
'success'
)
expect
(
pipeline
.
stages_name
).
to
eq
([
'build'
,
'test'
,
'deploy'
])
end
it
'ignores the previous state'
do
expect
(
statuses
).
to
eq
([[
'build'
,
'success'
],
[
'test'
,
'success'
],
[
'deploy'
,
'running'
]
])
end
end
end
end
end
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