diff options
author | Shinya Maeda <shinya@gitlab.com> | 2017-07-05 21:00:22 +0900 |
---|---|---|
committer | Shinya Maeda <shinya@gitlab.com> | 2017-07-05 21:00:22 +0900 |
commit | dbd0111390fd24da8782cadcd52471ad002e12da (patch) | |
tree | d02a42c980b7d9221663cefea57b2f5c27169eea | |
parent | 46076f15994d4af3bf9f6c70ec36547abf2d20af (diff) | |
download | gitlab-ce-dbd0111390fd24da8782cadcd52471ad002e12da.tar.gz |
Revert unnecesarry changes
-rw-r--r-- | app/models/ci/build.rb | 7 | ||||
-rw-r--r-- | spec/models/ci/build_spec.rb | 18 | ||||
-rw-r--r-- | spec/support/matchers/access_matchers_for_controller.rb | 2 |
3 files changed, 17 insertions, 10 deletions
diff --git a/app/models/ci/build.rb b/app/models/ci/build.rb index 841ad90a9cc..6c5b27a7ac5 100644 --- a/app/models/ci/build.rb +++ b/app/models/ci/build.rb @@ -176,9 +176,12 @@ module Ci # * Lowercased # * Anything not matching [a-z0-9-] is replaced with a - # * Maximum length is 63 bytes + # * First/Last Character is not a hyphen def ref_slug - slugified = ref.to_s.downcase - slugified.gsub(/[^a-z0-9]/, '-')[0..62] + ref.to_s + .downcase + .gsub(/[^a-z0-9]/, '-')[0..62] + .gsub(/(\A-+|-+\z)/, '') end # Variables whose value does not depend on environment diff --git a/spec/models/ci/build_spec.rb b/spec/models/ci/build_spec.rb index 42b86a77f17..211356f415a 100644 --- a/spec/models/ci/build_spec.rb +++ b/spec/models/ci/build_spec.rb @@ -998,13 +998,17 @@ describe Ci::Build, :models do describe '#ref_slug' do { - '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, + '-' + 'a' * 63 + '-' => 'a' * 62, + 'a' * 62 + ' ' => 'a' * 62 }.each do |ref, slug| it "transforms #{ref} to #{slug}" do build.ref = ref diff --git a/spec/support/matchers/access_matchers_for_controller.rb b/spec/support/matchers/access_matchers_for_controller.rb index 40d6e221428..ff60bd0c0ae 100644 --- a/spec/support/matchers/access_matchers_for_controller.rb +++ b/spec/support/matchers/access_matchers_for_controller.rb @@ -65,7 +65,7 @@ module AccessMatchersForController end matcher :be_allowed_for do |role| - match do |action, &block| + match do |action| user = emulate_user(role, @membership) update_owner(@objects, user) action.call |