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
Léo-Paul Géneau
gitlab-ce
Commits
c0827455
Commit
c0827455
authored
May 25, 2018
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add specs for stage detailed status and warnings
parent
887818d3
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
103 additions
and
1 deletion
+103
-1
spec/models/ci/stage_spec.rb
spec/models/ci/stage_spec.rb
+103
-1
No files found.
spec/models/ci/stage_spec.rb
View file @
c0827455
...
...
@@ -112,7 +112,71 @@ describe Ci::Stage, :models do
end
end
describe
'#index'
do
describe
'#detailed_status'
do
using
RSpec
::
Parameterized
::
TableSyntax
let
(
:user
)
{
create
(
:user
)
}
let
(
:stage
)
{
create
(
:ci_stage_entity
,
status: :created
)
}
subject
{
stage
.
detailed_status
(
user
)
}
where
(
:statuses
,
:label
)
do
%w[created]
|
:created
%w[success]
|
:passed
%w[pending]
|
:pending
%w[skipped]
|
:skipped
%w[canceled]
|
:canceled
%w[success failed]
|
:failed
%w[running pending]
|
:running
end
with_them
do
before
do
statuses
.
each
do
|
status
|
create
(
:commit_status
,
project:
stage
.
project
,
pipeline:
stage
.
pipeline
,
stage_id:
stage
.
id
,
status:
status
)
stage
.
update_status
end
end
it
'has a correct label'
do
expect
(
subject
.
label
).
to
eq
label
.
to_s
end
end
context
'when stage has warnings'
do
before
do
create
(
:ci_build
,
project:
stage
.
project
,
pipeline:
stage
.
pipeline
,
stage_id:
stage
.
id
,
status: :failed
,
allow_failure:
true
)
stage
.
update_status
end
it
'is passed with warnings'
do
expect
(
subject
.
label
).
to
eq
'passed with warnings'
end
end
end
describe
'#groups'
do
before
do
create
(
:ci_build
,
stage_id:
stage
.
id
,
name:
'rspec 0 1'
)
create
(
:ci_build
,
stage_id:
stage
.
id
,
name:
'rspec 0 2'
)
end
it
'groups stage builds by name'
do
expect
(
stage
.
groups
).
to
be_one
expect
(
stage
.
groups
.
first
.
name
).
to
eq
'rspec'
end
end
describe
'#position'
do
context
'when stage has been imported and does not have position index set'
do
before
do
stage
.
update_column
(
:position
,
nil
)
...
...
@@ -143,4 +207,42 @@ describe Ci::Stage, :models do
end
end
end
context
'when stage has warnings'
do
before
do
create
(
:ci_build
,
:failed
,
:allowed_to_fail
,
stage_id:
stage
.
id
)
end
describe
'#has_warnings?'
do
it
'returns true'
do
expect
(
stage
).
to
have_warnings
end
end
describe
'#number_of_warnings'
do
it
'returns a lazy stage warnings counter'
do
lazy_queries
=
ActiveRecord
::
QueryRecorder
.
new
do
stage
.
number_of_warnings
end
synced_queries
=
ActiveRecord
::
QueryRecorder
.
new
do
stage
.
number_of_warnings
.
to_i
end
expect
(
lazy_queries
.
count
).
to
eq
0
expect
(
synced_queries
.
count
).
to
eq
1
expect
(
stage
.
number_of_warnings
.
inspect
).
to
include
'BatchLoader'
expect
(
stage
.
number_of_warnings
).
to
eq
1
end
end
end
context
'when stage does not have warnings'
do
describe
'#has_warnings?'
do
it
'returns false'
do
expect
(
stage
).
not_to
have_warnings
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