Commit 3b704818 authored by Fabian Schneider's avatar Fabian Schneider Committed by Fabio Pitino

Adjust badge key text and width limits

parent 4c375307
---
title: Adjust badge key text and width limits
merge_request: 40199
author: Fabian Schneider @fabsrc
type: changed
......@@ -25,7 +25,7 @@ module Gitlab
end
def key_text
if @key_text && @key_text.size <= MAX_KEY_SIZE
if @key_text && @key_text.size <= MAX_KEY_TEXT_SIZE
@key_text
else
@entity.to_s
......@@ -37,7 +37,7 @@ module Gitlab
end
def key_width
if @key_width && @key_width.between?(1, MAX_KEY_SIZE)
if @key_width && @key_width.between?(1, MAX_KEY_WIDTH)
@key_width
else
62
......
......@@ -29,7 +29,7 @@ module Gitlab
end
def key_text
if @key_text && @key_text.size <= MAX_KEY_SIZE
if @key_text && @key_text.size <= MAX_KEY_TEXT_SIZE
@key_text
else
@entity.to_s
......@@ -41,7 +41,7 @@ module Gitlab
end
def key_width
if @key_width && @key_width.between?(1, MAX_KEY_SIZE)
if @key_width && @key_width.between?(1, MAX_KEY_WIDTH)
@key_width
else
62
......
......@@ -6,7 +6,8 @@ module Gitlab
# Abstract template class for badges
#
class Template
MAX_KEY_SIZE = 128
MAX_KEY_TEXT_SIZE = 64
MAX_KEY_WIDTH = 512
def initialize(badge)
@entity = badge.entity
......
......@@ -22,7 +22,7 @@ RSpec.describe Gitlab::Badge::Coverage::Template do
context 'when its size is larger than the max allowed value' do
before do
allow(badge).to receive(:customization).and_return({ key_text: 't' * 129 })
allow(badge).to receive(:customization).and_return({ key_text: 't' * 65 })
end
it 'returns default value' do
......@@ -76,7 +76,7 @@ RSpec.describe Gitlab::Badge::Coverage::Template do
context 'when it is larger than the max allowed value' do
before do
allow(badge).to receive(:customization).and_return({ key_width: 129 })
allow(badge).to receive(:customization).and_return({ key_width: 513 })
end
it 'returns default value' do
......
......@@ -22,7 +22,7 @@ RSpec.describe Gitlab::Badge::Pipeline::Template do
context 'when its size is larger than the max allowed value' do
before do
allow(badge).to receive(:customization).and_return({ key_text: 't' * 129 })
allow(badge).to receive(:customization).and_return({ key_text: 't' * 65 })
end
it 'returns default value' do
......@@ -54,7 +54,7 @@ RSpec.describe Gitlab::Badge::Pipeline::Template do
context 'when it is larger than the max allowed value' do
before do
allow(badge).to receive(:customization).and_return({ key_width: 129 })
allow(badge).to receive(:customization).and_return({ key_width: 513 })
end
it 'returns default value' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment