diff options
author | Sean McGivern <sean@mcgivern.me.uk> | 2018-04-06 20:14:47 +0300 |
---|---|---|
committer | Sean McGivern <sean@mcgivern.me.uk> | 2018-04-06 20:14:47 +0300 |
commit | f3fa98e93a0017af182ca18b7138a5f530432842 (patch) | |
tree | eb112a58840cc02d40cbecfb4dcd0de386cd7c34 /spec/lib | |
parent | 9e8f3058af2bd5a80dbff7f84d8c192895cee7d0 (diff) | |
parent | 4dd1f906fd60bebd433dc9c4b5879c1e575fb735 (diff) |
Merge branch '17939-osw-patch-support-gfm' into 'master'
Add support for patch link extension for commit links on GFM
Closes #17939
See merge request gitlab-org/gitlab-ce!18229
Diffstat (limited to 'spec/lib')
-rw-r--r-- | spec/lib/banzai/filter/commit_reference_filter_spec.rb | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/spec/lib/banzai/filter/commit_reference_filter_spec.rb b/spec/lib/banzai/filter/commit_reference_filter_spec.rb index 35f8792ff35..b18af806118 100644 --- a/spec/lib/banzai/filter/commit_reference_filter_spec.rb +++ b/spec/lib/banzai/filter/commit_reference_filter_spec.rb @@ -207,4 +207,35 @@ describe Banzai::Filter::CommitReferenceFilter do expect(reference_filter(act).to_html).to match(%r{<a.+>#{Regexp.escape(invalidate_reference(reference))}</a>}) end end + + context 'URL reference for a commit patch' do + let(:namespace) { create(:namespace) } + let(:project2) { create(:project, :public, :repository, namespace: namespace) } + let(:commit) { project2.commit } + let(:link) { urls.project_commit_url(project2, commit.id) } + let(:extension) { '.patch' } + let(:reference) { link + extension } + + it 'links to a valid reference' do + doc = reference_filter("See #{reference}") + + expect(doc.css('a').first.attr('href')) + .to eq reference + end + + it 'has valid text' do + doc = reference_filter("See #{reference}") + + expect(doc.text).to eq("See #{commit.reference_link_text(project)} (patch)") + end + + it 'does not link to patch when extension match is after the path' do + invalidate_commit_reference = reference_filter("#{link}/builds.patch") + + doc = reference_filter("See (#{invalidate_commit_reference})") + + expect(doc.css('a').first.attr('href')).to eq "#{link}/builds" + expect(doc.text).to eq("See (#{commit.reference_link_text(project)} (builds).patch)") + end + end end |