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
cc244160
Commit
cc244160
authored
Aug 11, 2016
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Extract the abstract base class of badge metadata
parent
7b840c84
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
54 additions
and
22 deletions
+54
-22
lib/gitlab/badge/build/metadata.rb
lib/gitlab/badge/build/metadata.rb
+3
-11
lib/gitlab/badge/coverage/metadata.rb
lib/gitlab/badge/coverage/metadata.rb
+3
-11
lib/gitlab/badge/metadata.rb
lib/gitlab/badge/metadata.rb
+36
-0
spec/lib/gitlab/badge/build/metadata_spec.rb
spec/lib/gitlab/badge/build/metadata_spec.rb
+6
-0
spec/lib/gitlab/badge/coverage/metadata_spec.rb
spec/lib/gitlab/badge/coverage/metadata_spec.rb
+6
-0
No files found.
lib/gitlab/badge/build/metadata.rb
View file @
cc244160
...
...
@@ -4,22 +4,14 @@ module Gitlab
##
# Class that describes build badge metadata
#
class
Metadata
include
Gitlab
::
Application
.
routes
.
url_helpers
include
ActionView
::
Helpers
::
AssetTagHelper
include
ActionView
::
Helpers
::
UrlHelper
class
Metadata
<
Badge
::
Metadata
def
initialize
(
badge
)
@project
=
badge
.
project
@ref
=
badge
.
ref
end
def
to_html
link_to
(
image_tag
(
image_url
,
alt:
'build status'
),
link_url
)
end
def
to_markdown
"[![build status](
#{
image_url
}
)](
#{
link_url
}
)"
def
title
'build status'
end
def
image_url
...
...
lib/gitlab/badge/coverage/metadata.rb
View file @
cc244160
...
...
@@ -4,23 +4,15 @@ module Gitlab
##
# Class that describes coverage badge metadata
#
class
Metadata
include
Gitlab
::
Application
.
routes
.
url_helpers
include
ActionView
::
Helpers
::
AssetTagHelper
include
ActionView
::
Helpers
::
UrlHelper
class
Metadata
<
Badge
::
Metadata
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
}
)"
def
title
'coverage report'
end
def
image_url
...
...
lib/gitlab/badge/metadata.rb
0 → 100644
View file @
cc244160
module
Gitlab
module
Badge
##
# Abstract class for badge metadata
#
class
Metadata
include
Gitlab
::
Application
.
routes
.
url_helpers
include
ActionView
::
Helpers
::
AssetTagHelper
include
ActionView
::
Helpers
::
UrlHelper
def
initialize
(
badge
)
@badge
=
badge
end
def
to_html
link_to
(
image_tag
(
image_url
,
alt:
title
),
link_url
)
end
def
to_markdown
"[![
#{
title
}
](
#{
image_url
}
)](
#{
link_url
}
)"
end
def
title
raise
NotImplementedError
end
def
image_url
raise
NotImplementedError
end
def
link_url
raise
NotImplementedError
end
end
end
end
spec/lib/gitlab/badge/build/metadata_spec.rb
View file @
cc244160
...
...
@@ -7,6 +7,12 @@ describe Gitlab::Badge::Build::Metadata do
it_behaves_like
'badge metadata'
describe
'#title'
do
it
'returns build status title'
do
expect
(
metadata
.
title
).
to
eq
'build status'
end
end
describe
'#image_url'
do
it
'returns valid url'
do
expect
(
metadata
.
image_url
).
to
include
'badges/feature/build.svg'
...
...
spec/lib/gitlab/badge/coverage/metadata_spec.rb
View file @
cc244160
...
...
@@ -10,6 +10,12 @@ describe Gitlab::Badge::Coverage::Metadata do
it_behaves_like
'badge metadata'
describe
'#title'
do
it
'returns coverage report title'
do
expect
(
metadata
.
title
).
to
eq
'coverage report'
end
end
describe
'#image_url'
do
it
'returns valid url'
do
expect
(
metadata
.
image_url
).
to
include
'badges/feature/coverage.svg'
...
...
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