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
Léo-Paul Géneau
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
Show 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
...
@@ -4,22 +4,14 @@ module Gitlab
##
##
# Class that describes build badge metadata
# Class that describes build badge metadata
#
#
class
Metadata
class
Metadata
<
Badge
::
Metadata
include
Gitlab
::
Application
.
routes
.
url_helpers
include
ActionView
::
Helpers
::
AssetTagHelper
include
ActionView
::
Helpers
::
UrlHelper
def
initialize
(
badge
)
def
initialize
(
badge
)
@project
=
badge
.
project
@project
=
badge
.
project
@ref
=
badge
.
ref
@ref
=
badge
.
ref
end
end
def
to_html
def
title
link_to
(
image_tag
(
image_url
,
alt:
'build status'
),
link_url
)
'build status'
end
def
to_markdown
"[![build status](
#{
image_url
}
)](
#{
link_url
}
)"
end
end
def
image_url
def
image_url
...
...
lib/gitlab/badge/coverage/metadata.rb
View file @
cc244160
...
@@ -4,23 +4,15 @@ module Gitlab
...
@@ -4,23 +4,15 @@ module Gitlab
##
##
# Class that describes coverage badge metadata
# Class that describes coverage badge metadata
#
#
class
Metadata
class
Metadata
<
Badge
::
Metadata
include
Gitlab
::
Application
.
routes
.
url_helpers
include
ActionView
::
Helpers
::
AssetTagHelper
include
ActionView
::
Helpers
::
UrlHelper
def
initialize
(
badge
)
def
initialize
(
badge
)
@project
=
badge
.
project
@project
=
badge
.
project
@ref
=
badge
.
ref
@ref
=
badge
.
ref
@job
=
badge
.
job
@job
=
badge
.
job
end
end
def
to_html
def
title
link_to
(
image_tag
(
image_url
,
alt:
'coverage report'
),
link_url
)
'coverage report'
end
def
to_markdown
"[![coverage report](
#{
image_url
}
)](
#{
link_url
}
)"
end
end
def
image_url
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
...
@@ -7,6 +7,12 @@ describe Gitlab::Badge::Build::Metadata do
it_behaves_like
'badge metadata'
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
describe
'#image_url'
do
it
'returns valid url'
do
it
'returns valid url'
do
expect
(
metadata
.
image_url
).
to
include
'badges/feature/build.svg'
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
...
@@ -10,6 +10,12 @@ describe Gitlab::Badge::Coverage::Metadata do
it_behaves_like
'badge metadata'
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
describe
'#image_url'
do
it
'returns valid url'
do
it
'returns valid url'
do
expect
(
metadata
.
image_url
).
to
include
'badges/feature/coverage.svg'
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