diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-06-16 18:25:58 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-06-16 18:25:58 +0000 |
commit | a5f4bba440d7f9ea47046a0a561d49adf0a1e6d4 (patch) | |
tree | fb69158581673816a8cd895f9d352dcb3c678b1e /spec/support/shared_examples/ci | |
parent | d16b2e8639e99961de6ddc93909f3bb5c1445ba1 (diff) | |
download | gitlab-ce-14.0.0-rc42.tar.gz |
Add latest changes from gitlab-org/gitlab@14-0-stable-eev14.0.0-rc42
Diffstat (limited to 'spec/support/shared_examples/ci')
-rw-r--r-- | spec/support/shared_examples/ci/badge_template_shared_examples.rb | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/spec/support/shared_examples/ci/badge_template_shared_examples.rb b/spec/support/shared_examples/ci/badge_template_shared_examples.rb new file mode 100644 index 00000000000..94aec33ecc2 --- /dev/null +++ b/spec/support/shared_examples/ci/badge_template_shared_examples.rb @@ -0,0 +1,57 @@ +# frozen_string_literal: true + +RSpec.shared_examples 'a badge template' do |badge_type| + describe '#key_text' do + it "says #{badge_type} by default" do + expect(template.key_text).to eq(badge_type) + 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' * (::Gitlab::Ci::Badge::Template::MAX_KEY_TEXT_SIZE + 1) } ) + end + + it 'returns default value' do + expect(template.key_text).to eq(badge_type) + end + end + end + end + + describe '#key_width' do + let_it_be(:default_key_width) { ::Gitlab::Ci::Badge::Template::DEFAULT_KEY_WIDTH } + + it 'is fixed by default' do + expect(template.key_width).to eq(default_key_width) + 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: ::Gitlab::Ci::Badge::Template::MAX_KEY_WIDTH + 1 }) + end + + it 'returns default value' do + expect(template.key_width).to eq(default_key_width) + end + end + end + end +end |