File tree 5 files changed +54
-22
lines changed
5 files changed +54
-22
lines changed Original file line number Diff line number Diff line change @@ -4,22 +4,14 @@ module Build
4
4
##
5
5
# Class that describes build badge metadata
6
6
#
7
- class Metadata
8
- include Gitlab ::Application . routes . url_helpers
9
- include ActionView ::Helpers ::AssetTagHelper
10
- include ActionView ::Helpers ::UrlHelper
11
-
7
+ class Metadata < Badge ::Metadata
12
8
def initialize ( badge )
13
9
@project = badge . project
14
10
@ref = badge . ref
15
11
end
16
12
17
- def to_html
18
- link_to ( image_tag ( image_url , alt : 'build status' ) , link_url )
19
- end
20
-
21
- def to_markdown
22
- "[](#{ link_url } )"
13
+ def title
14
+ 'build status'
23
15
end
24
16
25
17
def image_url
Original file line number Diff line number Diff line change @@ -4,23 +4,15 @@ module Coverage
4
4
##
5
5
# Class that describes coverage badge metadata
6
6
#
7
- class Metadata
8
- include Gitlab ::Application . routes . url_helpers
9
- include ActionView ::Helpers ::AssetTagHelper
10
- include ActionView ::Helpers ::UrlHelper
11
-
7
+ class Metadata < Badge ::Metadata
12
8
def initialize ( badge )
13
9
@project = badge . project
14
10
@ref = badge . ref
15
11
@job = badge . job
16
12
end
17
13
18
- def to_html
19
- link_to ( image_tag ( image_url , alt : 'coverage report' ) , link_url )
20
- end
21
-
22
- def to_markdown
23
- "[](#{ link_url } )"
14
+ def title
15
+ 'coverage report'
24
16
end
25
17
26
18
def image_url
Original file line number Diff line number Diff line change
1
+ module Gitlab
2
+ module Badge
3
+ ##
4
+ # Abstract class for badge metadata
5
+ #
6
+ class Metadata
7
+ include Gitlab ::Application . routes . url_helpers
8
+ include ActionView ::Helpers ::AssetTagHelper
9
+ include ActionView ::Helpers ::UrlHelper
10
+
11
+ def initialize ( badge )
12
+ @badge = badge
13
+ end
14
+
15
+ def to_html
16
+ link_to ( image_tag ( image_url , alt : title ) , link_url )
17
+ end
18
+
19
+ def to_markdown
20
+ "[](#{ link_url } )"
21
+ end
22
+
23
+ def title
24
+ raise NotImplementedError
25
+ end
26
+
27
+ def image_url
28
+ raise NotImplementedError
29
+ end
30
+
31
+ def link_url
32
+ raise NotImplementedError
33
+ end
34
+ end
35
+ end
36
+ end
Original file line number Diff line number Diff line change 7
7
8
8
it_behaves_like 'badge metadata'
9
9
10
+ describe '#title' do
11
+ it 'returns build status title' do
12
+ expect ( metadata . title ) . to eq 'build status'
13
+ end
14
+ end
15
+
10
16
describe '#image_url' do
11
17
it 'returns valid url' do
12
18
expect ( metadata . image_url ) . to include 'badges/feature/build.svg'
Original file line number Diff line number Diff line change 10
10
11
11
it_behaves_like 'badge metadata'
12
12
13
+ describe '#title' do
14
+ it 'returns coverage report title' do
15
+ expect ( metadata . title ) . to eq 'coverage report'
16
+ end
17
+ end
18
+
13
19
describe '#image_url' do
14
20
it 'returns valid url' do
15
21
expect ( metadata . image_url ) . to include 'badges/feature/coverage.svg'
You can’t perform that action at this time.
0 commit comments