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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
42496ece
Commit
42496ece
authored
Aug 18, 2016
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Render coverage badge for latest successful pipeline
parent
ac73de50
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
41 additions
and
29 deletions
+41
-29
lib/gitlab/badge/coverage/report.rb
lib/gitlab/badge/coverage/report.rb
+1
-2
spec/lib/gitlab/badge/coverage/report_spec.rb
spec/lib/gitlab/badge/coverage/report_spec.rb
+40
-27
No files found.
lib/gitlab/badge/coverage/report.rb
View file @
42496ece
...
...
@@ -13,8 +13,7 @@ module Gitlab
@job
=
job
@pipeline
=
@project
.
pipelines
.
where
(
ref:
@ref
)
.
where
(
sha:
@project
.
commit
(
@ref
).
try
(
:sha
))
.
latest_successful_for
(
@ref
)
.
first
end
...
...
spec/lib/gitlab/badge/coverage/report_spec.rb
View file @
42496ece
...
...
@@ -44,20 +44,19 @@ describe Gitlab::Badge::Coverage::Report do
end
end
context
'pipeline exists'
do
let!
(
:pipeline
)
do
create
(
:ci_pipeline
,
project:
project
,
sha:
project
.
commit
.
id
,
ref:
'master'
)
context
'
when latest successful
pipeline exists'
do
before
do
create
_pipeline
do
|
pipeline
|
create
(
:ci_build
,
:success
,
pipeline:
pipeline
,
name:
'first'
,
coverage:
40
)
create
(
:ci_build
,
:success
,
pipeline:
pipeline
,
coverage:
60
)
end
context
'builds exist'
do
before
do
create
(
:ci_build
,
name:
'first'
,
pipeline:
pipeline
,
coverage:
40
)
create
(
:ci_build
,
pipeline:
pipeline
,
coverage:
60
)
create_pipeline
do
|
pipeline
|
create
(
:ci_build
,
:failed
,
pipeline:
pipeline
,
coverage:
10
)
end
end
context
'
particular job specified'
do
context
'when
particular job specified'
do
let
(
:job_name
)
{
'first'
}
it
'returns coverage for the particular job'
do
...
...
@@ -65,7 +64,7 @@ describe Gitlab::Badge::Coverage::Report do
end
end
context
'
particular job not specified'
do
context
'when
particular job not specified'
do
let
(
:job_name
)
{
''
}
it
'returns arithemetic mean for the pipeline'
do
...
...
@@ -74,7 +73,13 @@ describe Gitlab::Badge::Coverage::Report do
end
end
context
'builds do not exist'
do
context
'when only failed pipeline exists'
do
before
do
create_pipeline
do
|
pipeline
|
create
(
:ci_build
,
:failed
,
pipeline:
pipeline
,
coverage:
10
)
end
end
it_behaves_like
'unknown coverage report'
context
'particular job specified'
do
...
...
@@ -85,9 +90,17 @@ describe Gitlab::Badge::Coverage::Report do
end
end
end
end
context
'pipeline does not exist'
do
it_behaves_like
'unknown coverage report'
end
def
create_pipeline
opts
=
{
project:
project
,
sha:
project
.
commit
.
id
,
ref:
'master'
}
create
(
:ci_pipeline
,
opts
).
tap
do
|
pipeline
|
yield
pipeline
pipeline
.
build_updated
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