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
Boxiang Sun
gitlab-ce
Commits
7b840c84
Commit
7b840c84
authored
Aug 11, 2016
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add coverage report badge metadata class
parent
cdb0caaf
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
66 additions
and
1 deletion
+66
-1
config/routes.rb
config/routes.rb
+4
-1
lib/gitlab/badge/coverage/metadata.rb
lib/gitlab/badge/coverage/metadata.rb
+38
-0
spec/lib/gitlab/badge/coverage/metadata_spec.rb
spec/lib/gitlab/badge/coverage/metadata_spec.rb
+24
-0
No files found.
config/routes.rb
View file @
7b840c84
...
@@ -869,7 +869,10 @@ Rails.application.routes.draw do
...
@@ -869,7 +869,10 @@ Rails.application.routes.draw do
resources
:badges
,
only:
[
:index
]
do
resources
:badges
,
only:
[
:index
]
do
collection
do
collection
do
scope
'*ref'
,
constraints:
{
ref:
Gitlab
::
Regex
.
git_reference_regex
}
do
scope
'*ref'
,
constraints:
{
ref:
Gitlab
::
Regex
.
git_reference_regex
}
do
get
:build
,
constraints:
{
format:
/svg/
}
constraints
format:
/svg/
do
get
:build
get
:coverage
end
end
end
end
end
end
end
...
...
lib/gitlab/badge/coverage/metadata.rb
0 → 100644
View file @
7b840c84
module
Gitlab
module
Badge
module
Coverage
##
# Class that describes coverage badge metadata
#
class
Metadata
include
Gitlab
::
Application
.
routes
.
url_helpers
include
ActionView
::
Helpers
::
AssetTagHelper
include
ActionView
::
Helpers
::
UrlHelper
def
initialize
(
badge
)
@project
=
badge
.
project
@ref
=
badge
.
ref
@job
=
badge
.
job
end
def
to_html
link_to
(
image_tag
(
image_url
,
alt:
'coverage report'
),
link_url
)
end
def
to_markdown
"[![coverage report](
#{
image_url
}
)](
#{
link_url
}
)"
end
def
image_url
coverage_namespace_project_badges_url
(
@project
.
namespace
,
@project
,
@ref
,
format: :svg
)
end
def
link_url
namespace_project_commits_url
(
@project
.
namespace
,
@project
,
id:
@ref
)
end
end
end
end
end
spec/lib/gitlab/badge/coverage/metadata_spec.rb
0 → 100644
View file @
7b840c84
require
'spec_helper'
require
'lib/gitlab/badge/shared/metadata'
describe
Gitlab
::
Badge
::
Coverage
::
Metadata
do
let
(
:badge
)
do
double
(
project:
create
(
:project
),
ref:
'feature'
,
job:
'test'
)
end
let
(
:metadata
)
{
described_class
.
new
(
badge
)
}
it_behaves_like
'badge metadata'
describe
'#image_url'
do
it
'returns valid url'
do
expect
(
metadata
.
image_url
).
to
include
'badges/feature/coverage.svg'
end
end
describe
'#link_url'
do
it
'returns valid link'
do
expect
(
metadata
.
link_url
).
to
include
'commits/feature'
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