summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Hanreich <stefanhani@gmail.com>2017-05-11 20:04:36 +0200
committerStefan Hanreich <stefanhani@gmail.com>2017-05-11 20:04:36 +0200
commitac516151a63a4fe69363b208b4f53e74e27df94c (patch)
tree1803ac6cf7e4327a2e286ef51ef57f9e5105d9ae
parent18759f46c53148ff63291276e5f8bb8ac642711f (diff)
downloadgitlab-ce-ac516151a63a4fe69363b208b4f53e74e27df94c.tar.gz
Updated spec for build to include new ref_slug invariants
-rw-r--r--spec/models/ci/build_spec.rb24
1 files changed, 16 insertions, 8 deletions
diff --git a/spec/models/ci/build_spec.rb b/spec/models/ci/build_spec.rb
index e971b4bc3f9..407b49a1ff7 100644
--- a/spec/models/ci/build_spec.rb
+++ b/spec/models/ci/build_spec.rb
@@ -965,19 +965,27 @@ describe Ci::Build, :models do
end
describe '#ref_slug' do
+ let(:build) { build(:ci_build, ref: "'100%") }
+ subject { build.ref_slug }
+
+ it { is_expected.not_to start_with('-') }
+ it { is_expected.not_to end_with('-') }
+
{
- 'master' => 'master',
- '1-foo' => '1-foo',
- 'fix/1-foo' => 'fix-1-foo',
- 'fix-1-foo' => 'fix-1-foo',
- 'a' * 63 => 'a' * 63,
- 'a' * 64 => 'a' * 63,
- 'FOO' => 'foo'
+ 'master' => 'master',
+ '1-foo' => '1-foo',
+ 'fix/1-foo' => 'fix-1-foo',
+ 'fix-1-foo' => 'fix-1-foo',
+ 'a' * 63 => 'a' * 63,
+ 'a' * 64 => 'a' * 63,
+ 'FOO' => 'foo',
+ '-' + 'a' * 61 + '-' => 'a' * 61,
+ 'a' * 62 + ' ' => 'a' * 62,
}.each do |ref, slug|
it "transforms #{ref} to #{slug}" do
build.ref = ref
- expect(build.ref_slug).to eq(slug)
+ is_expected.to eq(slug)
end
end
end