Commit 35608618 authored by Fabio Pitino's avatar Fabio Pitino

Merge branch '231238-adjust-badge-key-limits' into 'master'

Adjust badge key text and width limits

Closes #231238

See merge request gitlab-org/gitlab!40199
parents 3a4ebc1e 3b704818
---
title: Adjust badge key text and width limits
merge_request: 40199
author: Fabian Schneider @fabsrc
type: changed
...@@ -25,7 +25,7 @@ module Gitlab ...@@ -25,7 +25,7 @@ module Gitlab
end end
def key_text def key_text
if @key_text && @key_text.size <= MAX_KEY_SIZE if @key_text && @key_text.size <= MAX_KEY_TEXT_SIZE
@key_text @key_text
else else
@entity.to_s @entity.to_s
...@@ -37,7 +37,7 @@ module Gitlab ...@@ -37,7 +37,7 @@ module Gitlab
end end
def key_width 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 @key_width
else else
62 62
......
...@@ -29,7 +29,7 @@ module Gitlab ...@@ -29,7 +29,7 @@ module Gitlab
end end
def key_text def key_text
if @key_text && @key_text.size <= MAX_KEY_SIZE if @key_text && @key_text.size <= MAX_KEY_TEXT_SIZE
@key_text @key_text
else else
@entity.to_s @entity.to_s
...@@ -41,7 +41,7 @@ module Gitlab ...@@ -41,7 +41,7 @@ module Gitlab
end end
def key_width 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 @key_width
else else
62 62
......
...@@ -6,7 +6,8 @@ module Gitlab ...@@ -6,7 +6,8 @@ module Gitlab
# Abstract template class for badges # Abstract template class for badges
# #
class Template class Template
MAX_KEY_SIZE = 128 MAX_KEY_TEXT_SIZE = 64
MAX_KEY_WIDTH = 512
def initialize(badge) def initialize(badge)
@entity = badge.entity @entity = badge.entity
......
...@@ -22,7 +22,7 @@ RSpec.describe Gitlab::Badge::Coverage::Template do ...@@ -22,7 +22,7 @@ RSpec.describe Gitlab::Badge::Coverage::Template do
context 'when its size is larger than the max allowed value' do context 'when its size is larger than the max allowed value' do
before 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 end
it 'returns default value' do it 'returns default value' do
...@@ -76,7 +76,7 @@ RSpec.describe Gitlab::Badge::Coverage::Template do ...@@ -76,7 +76,7 @@ RSpec.describe Gitlab::Badge::Coverage::Template do
context 'when it is larger than the max allowed value' do context 'when it is larger than the max allowed value' do
before do before do
allow(badge).to receive(:customization).and_return({ key_width: 129 }) allow(badge).to receive(:customization).and_return({ key_width: 513 })
end end
it 'returns default value' do it 'returns default value' do
......
...@@ -22,7 +22,7 @@ RSpec.describe Gitlab::Badge::Pipeline::Template do ...@@ -22,7 +22,7 @@ RSpec.describe Gitlab::Badge::Pipeline::Template do
context 'when its size is larger than the max allowed value' do context 'when its size is larger than the max allowed value' do
before 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 end
it 'returns default value' do it 'returns default value' do
...@@ -54,7 +54,7 @@ RSpec.describe Gitlab::Badge::Pipeline::Template do ...@@ -54,7 +54,7 @@ RSpec.describe Gitlab::Badge::Pipeline::Template do
context 'when it is larger than the max allowed value' do context 'when it is larger than the max allowed value' do
before do before do
allow(badge).to receive(:customization).and_return({ key_width: 129 }) allow(badge).to receive(:customization).and_return({ key_width: 513 })
end end
it 'returns default value' do 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