summaryrefslogtreecommitdiff
path: root/lib/gitlab/ci/badge/template.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/gitlab/ci/badge/template.rb')
-rw-r--r--lib/gitlab/ci/badge/template.rb13
1 files changed, 11 insertions, 2 deletions
diff --git a/lib/gitlab/ci/badge/template.rb b/lib/gitlab/ci/badge/template.rb
index 0580dad72ba..d514a8577bd 100644
--- a/lib/gitlab/ci/badge/template.rb
+++ b/lib/gitlab/ci/badge/template.rb
@@ -8,6 +8,7 @@ module Gitlab::Ci
class Template
MAX_KEY_TEXT_SIZE = 64
MAX_KEY_WIDTH = 512
+ DEFAULT_KEY_WIDTH = 62
def initialize(badge)
@entity = badge.entity
@@ -15,7 +16,11 @@ module Gitlab::Ci
end
def key_text
- raise NotImplementedError
+ if @key_text && @key_text.size <= MAX_KEY_TEXT_SIZE
+ @key_text
+ else
+ @entity.to_s
+ end
end
def value_text
@@ -23,7 +28,11 @@ module Gitlab::Ci
end
def key_width
- raise NotImplementedError
+ if @key_width && @key_width.between?(1, MAX_KEY_WIDTH)
+ @key_width
+ else
+ DEFAULT_KEY_WIDTH
+ end
end
def value_width