diff options
author | micael.bergeron <micaelbergeron@gmail.com> | 2017-11-15 09:12:04 -0500 |
---|---|---|
committer | micael.bergeron <micaelbergeron@gmail.com> | 2017-11-15 09:21:05 -0500 |
commit | 4374a38f0e8fbd856458a60f47083fb4d084d695 (patch) | |
tree | de063112d0909ac1c4fe0ad2c25f4466951a9abf /spec/models/commit_spec.rb | |
parent | a4072db0198896242886d22c644ed91c1016aa8d (diff) | |
download | gitlab-ce-4374a38f0e8fbd856458a60f47083fb4d084d695.tar.gz |
fix the commit reference pattern from matching other entities
Diffstat (limited to 'spec/models/commit_spec.rb')
-rw-r--r-- | spec/models/commit_spec.rb | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/spec/models/commit_spec.rb b/spec/models/commit_spec.rb index e3cfa149e3a..3994eaba5d9 100644 --- a/spec/models/commit_spec.rb +++ b/spec/models/commit_spec.rb @@ -468,4 +468,27 @@ eos expect(described_class.valid_hash?('a' * 41)).to be false end end + + describe '.reference_pattern' do + where(:ref, :matches?) do + sha = Digest::SHA1.hexdigest 'thisisacommitid' + + [ + [sha.first(Commit::MIN_SHA_LENGTH - 1), false], + [sha.first(Commit::MIN_SHA_LENGTH), true], + [sha, true], + ['~' << sha, false], # labels + ['!' << sha, false], # merge_request + [':' << sha, false], # emoji + ['#' << sha, false], # issue + ['@' << sha, false], # user + ] + end + + with_them do + it "should match only on commit references" do + expect(Commit.reference_pattern.match(ref).present?).to eq(matches?) + end + end + end end |