summaryrefslogtreecommitdiff
path: root/spec/models/commit_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/models/commit_spec.rb')
-rw-r--r--spec/models/commit_spec.rb23
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