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
1fb4ed21
Commit
1fb4ed21
authored
Mar 20, 2017
by
Jeff Stubler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Change coverage badge rounding for other CI system consistency
parent
5b73e0eb
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
24 additions
and
9 deletions
+24
-9
changelogs/unreleased/25327-coverage-badge-rounding.yml
changelogs/unreleased/25327-coverage-badge-rounding.yml
+5
-0
lib/gitlab/badge/coverage/report.rb
lib/gitlab/badge/coverage/report.rb
+1
-1
lib/gitlab/badge/coverage/template.rb
lib/gitlab/badge/coverage/template.rb
+2
-2
spec/features/projects/badges/coverage_spec.rb
spec/features/projects/badges/coverage_spec.rb
+2
-2
spec/lib/gitlab/badge/coverage/template_spec.rb
spec/lib/gitlab/badge/coverage/template_spec.rb
+14
-4
No files found.
changelogs/unreleased/25327-coverage-badge-rounding.yml
0 → 100644
View file @
1fb4ed21
---
title
:
Show coverage to two decimal points in coverage badge
merge_request
:
10083
author
:
Jeff Stubler
type
:
changed
lib/gitlab/badge/coverage/report.rb
View file @
1fb4ed21
...
...
@@ -23,7 +23,7 @@ module Gitlab
@coverage
||=
raw_coverage
return
unless
@coverage
@coverage
.
to_
i
@coverage
.
to_
f
.
round
(
2
)
end
def
metadata
...
...
lib/gitlab/badge/coverage/template.rb
View file @
1fb4ed21
...
...
@@ -25,7 +25,7 @@ module Gitlab
end
def
value_text
@status
?
"
#{
@status
}
%"
:
'unknown'
@status
?
(
"%.2f%%"
%
@status
)
:
'unknown'
end
def
key_width
...
...
@@ -33,7 +33,7 @@ module Gitlab
end
def
value_width
@status
?
36
:
58
@status
?
54
:
58
end
def
value_color
...
...
spec/features/projects/badges/coverage_spec.rb
View file @
1fb4ed21
...
...
@@ -18,7 +18,7 @@ feature 'test coverage badge' do
show_test_coverage_badge
expect_coverage_badge
(
'95%'
)
expect_coverage_badge
(
'95
.00
%'
)
end
scenario
'user requests coverage badge for specific job'
do
...
...
@@ -30,7 +30,7 @@ feature 'test coverage badge' do
show_test_coverage_badge
(
job:
'coverage'
)
expect_coverage_badge
(
'85%'
)
expect_coverage_badge
(
'85
.00
%'
)
end
scenario
'user requests coverage badge for pipeline without coverage'
do
...
...
spec/lib/gitlab/badge/coverage/template_spec.rb
View file @
1fb4ed21
require
'spec_helper'
describe
Gitlab
::
Badge
::
Coverage
::
Template
do
let
(
:badge
)
{
double
(
entity:
'coverage'
,
status:
90
)
}
let
(
:badge
)
{
double
(
entity:
'coverage'
,
status:
90
.00
)
}
let
(
:template
)
{
described_class
.
new
(
badge
)
}
describe
'#key_text'
do
...
...
@@ -13,7 +13,17 @@ describe Gitlab::Badge::Coverage::Template do
describe
'#value_text'
do
context
'when coverage is known'
do
it
'returns coverage percentage'
do
expect
(
template
.
value_text
).
to
eq
'90%'
expect
(
template
.
value_text
).
to
eq
'90.00%'
end
end
context
'when coverage is known to many digits'
do
before
do
allow
(
badge
).
to
receive
(
:status
).
and_return
(
92.349
)
end
it
'returns rounded coverage percentage'
do
expect
(
template
.
value_text
).
to
eq
'92.35%'
end
end
...
...
@@ -37,7 +47,7 @@ describe Gitlab::Badge::Coverage::Template do
describe
'#value_width'
do
context
'when coverage is known'
do
it
'is narrower when coverage is known'
do
expect
(
template
.
value_width
).
to
eq
36
expect
(
template
.
value_width
).
to
eq
54
end
end
...
...
@@ -113,7 +123,7 @@ describe Gitlab::Badge::Coverage::Template do
describe
'#width'
do
context
'when coverage is known'
do
it
'returns the key width plus value width'
do
expect
(
template
.
width
).
to
eq
98
expect
(
template
.
width
).
to
eq
116
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