diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-05-30 00:08:35 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-05-30 00:08:35 +0300 |
commit | d8b32df644a632b143d6b9967311301a2fc83a6b (patch) | |
tree | 130722547715d1f65104529d8a09b1ba123776d6 /spec/lib/gitlab/badge | |
parent | b64a8161c9442d82897a341d6bf935dd3e748b06 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/lib/gitlab/badge')
-rw-r--r-- | spec/lib/gitlab/badge/coverage/report_spec.rb | 2 | ||||
-rw-r--r-- | spec/lib/gitlab/badge/coverage/template_spec.rb | 46 | ||||
-rw-r--r-- | spec/lib/gitlab/badge/pipeline/template_spec.rb | 50 |
3 files changed, 92 insertions, 6 deletions
diff --git a/spec/lib/gitlab/badge/coverage/report_spec.rb b/spec/lib/gitlab/badge/coverage/report_spec.rb index 560072a3d83..284ca53a996 100644 --- a/spec/lib/gitlab/badge/coverage/report_spec.rb +++ b/spec/lib/gitlab/badge/coverage/report_spec.rb @@ -7,7 +7,7 @@ describe Gitlab::Badge::Coverage::Report do let(:job_name) { nil } let(:badge) do - described_class.new(project, 'master', job_name) + described_class.new(project, 'master', opts: { job: job_name }) end describe '#entity' do diff --git a/spec/lib/gitlab/badge/coverage/template_spec.rb b/spec/lib/gitlab/badge/coverage/template_spec.rb index b51d707a61d..3940b37830e 100644 --- a/spec/lib/gitlab/badge/coverage/template_spec.rb +++ b/spec/lib/gitlab/badge/coverage/template_spec.rb @@ -3,13 +3,33 @@ require 'spec_helper' describe Gitlab::Badge::Coverage::Template do - let(:badge) { double(entity: 'coverage', status: 90.00) } + let(:badge) { double(entity: 'coverage', status: 90.00, customization: {}) } let(:template) { described_class.new(badge) } describe '#key_text' do - it 'is always says coverage' do + it 'says coverage by default' do expect(template.key_text).to eq 'coverage' end + + context 'when custom key_text is defined' do + before do + allow(badge).to receive(:customization).and_return({ key_text: "custom text" }) + end + + it 'returns custom value' do + expect(template.key_text).to eq "custom text" + end + + 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 }) + end + + it 'returns default value' do + expect(template.key_text).to eq 'coverage' + end + end + end end describe '#value_text' do @@ -41,9 +61,29 @@ describe Gitlab::Badge::Coverage::Template do end describe '#key_width' do - it 'has a fixed key width' do + it 'is fixed by default' do expect(template.key_width).to eq 62 end + + context 'when custom key_width is defined' do + before do + allow(badge).to receive(:customization).and_return({ key_width: 101 }) + end + + it 'returns custom value' do + expect(template.key_width).to eq 101 + end + + context 'when it is larger than the max allowed value' do + before do + allow(badge).to receive(:customization).and_return({ key_width: 129 }) + end + + it 'returns default value' do + expect(template.key_width).to eq 62 + end + end + end end describe '#value_width' do diff --git a/spec/lib/gitlab/badge/pipeline/template_spec.rb b/spec/lib/gitlab/badge/pipeline/template_spec.rb index da95c7219a4..751a5d6645e 100644 --- a/spec/lib/gitlab/badge/pipeline/template_spec.rb +++ b/spec/lib/gitlab/badge/pipeline/template_spec.rb @@ -3,13 +3,33 @@ require 'spec_helper' describe Gitlab::Badge::Pipeline::Template do - let(:badge) { double(entity: 'pipeline', status: 'success') } + let(:badge) { double(entity: 'pipeline', status: 'success', customization: {}) } let(:template) { described_class.new(badge) } describe '#key_text' do - it 'is always says pipeline' do + it 'says pipeline by default' do expect(template.key_text).to eq 'pipeline' end + + context 'when custom key_text is defined' do + before do + allow(badge).to receive(:customization).and_return({ key_text: 'custom text' }) + end + + it 'returns custom value' do + expect(template.key_text).to eq 'custom text' + end + + 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 }) + end + + it 'returns default value' do + expect(template.key_text).to eq 'pipeline' + end + end + end end describe '#value_text' do @@ -18,6 +38,32 @@ describe Gitlab::Badge::Pipeline::Template do end end + describe '#key_width' do + it 'is fixed by default' do + expect(template.key_width).to eq 62 + end + + context 'when custom key_width is defined' do + before do + allow(badge).to receive(:customization).and_return({ key_width: 101 }) + end + + it 'returns custom value' do + expect(template.key_width).to eq 101 + end + + context 'when it is larger than the max allowed value' do + before do + allow(badge).to receive(:customization).and_return({ key_width: 129 }) + end + + it 'returns default value' do + expect(template.key_width).to eq 62 + end + end + end + end + describe 'widths and text anchors' do it 'has fixed width and text anchors' do expect(template.width).to eq 116 |