BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
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
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
66 additions
and
1 deletion
+66
-1
routes.rb
config/routes.rb
+4
-1
metadata.rb
lib/gitlab/badge/coverage/metadata.rb
+38
-0
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
resources
:badges
,
only:
[
:index
]
do
collection
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
...
...
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