diff options
author | Robert Speicher <rspeicher@gmail.com> | 2015-04-21 16:20:24 -0400 |
---|---|---|
committer | Robert Speicher <rspeicher@gmail.com> | 2015-04-25 14:40:40 -0400 |
commit | 2c8bfedb205d2da016f64ef8eb9d24a47d5f88d6 (patch) | |
tree | 4f3afb53a02bc5b77b55ce30a52dd97875521497 /spec | |
parent | 89775da8e5e823e9fe90dc1fc2959a8d861c9fc2 (diff) | |
download | gitlab-ce-2c8bfedb205d2da016f64ef8eb9d24a47d5f88d6.tar.gz |
Always use short SHAs as commit reference link text
Now when a user pastes a full SHA like
`d7f61affaf845f44b4cc995e34eb1606c47c8eff`, its link text will only show
`d7f61aff` for brevity.
Diffstat (limited to 'spec')
-rw-r--r-- | spec/lib/gitlab/markdown/commit_reference_filter_spec.rb | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/spec/lib/gitlab/markdown/commit_reference_filter_spec.rb b/spec/lib/gitlab/markdown/commit_reference_filter_spec.rb index 5efda4f9aa4..cc32a4fcf03 100644 --- a/spec/lib/gitlab/markdown/commit_reference_filter_spec.rb +++ b/spec/lib/gitlab/markdown/commit_reference_filter_spec.rb @@ -27,15 +27,23 @@ module Gitlab::Markdown it "links to a valid reference of #{size} characters" do doc = filter("See #{reference[0...size]}") - expect(doc.css('a').first.text).to eq reference[0...size] + expect(doc.css('a').first.text).to eq commit.short_id expect(doc.css('a').first.attr('href')). to eq urls.namespace_project_commit_url(project.namespace, project, reference) end end + it 'always uses the short ID as the link text' do + doc = filter("See #{commit.id}") + expect(doc.text).to eq "See #{commit.short_id}" + + doc = filter("See #{commit.id[0...6]}") + expect(doc.text).to eq "See #{commit.short_id}" + end + it 'links with adjacent text' do doc = filter("See (#{reference}.)") - expect(doc.to_html).to match(/\(<a.+>#{Regexp.escape(reference)}<\/a>\.\)/) + expect(doc.to_html).to match(/\(<a.+>#{commit.short_id}<\/a>\.\)/) end it 'ignores invalid commit IDs' do @@ -55,7 +63,7 @@ module Gitlab::Markdown allow_any_instance_of(Commit).to receive(:title).and_return(%{"></a>whatever<a title="}) doc = filter("See #{reference}") - expect(doc.text).to eq "See #{commit.id}" + expect(doc.text).to eq "See #{commit.short_id}" end it 'includes default classes' do @@ -100,7 +108,9 @@ module Gitlab::Markdown it 'links with adjacent text' do doc = filter("Fixed (#{reference}.)") - expect(doc.to_html).to match(/\(<a.+>#{Regexp.escape(reference)}<\/a>\.\)/) + + exp = Regexp.escape(project2.path_with_namespace) + expect(doc.to_html).to match(/\(<a.+>#{exp}@#{commit.short_id}<\/a>\.\)/) end it 'ignores invalid commit IDs on the referenced project' do |