From d520fe07ad90cb610927e833060908bdc04fa550 Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Mon, 6 Apr 2015 11:18:47 -0400 Subject: [PATCH] Fix GitlabMarkdownHelper spec --- spec/helpers/gitlab_markdown_helper_spec.rb | 6 +++--- .../gitlab/markdown/commit_range_reference_filter_spec.rb | 8 ++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/spec/helpers/gitlab_markdown_helper_spec.rb b/spec/helpers/gitlab_markdown_helper_spec.rb index 1c88f49ff4f..3454935078c 100644 --- a/spec/helpers/gitlab_markdown_helper_spec.rb +++ b/spec/helpers/gitlab_markdown_helper_spec.rb @@ -51,8 +51,8 @@ describe GitlabMarkdownHelper do end it "should not touch HTML entities" do - allow(@project.issues).to receive(:where). - with(id: '39').and_return([issue]) + allow(@project).to receive(:issue_exists?). + with(39).and_return([issue]) actual = 'We'll accept good pull requests.' expect(gfm(actual)).to eq("We'll accept good pull requests.") end @@ -609,7 +609,7 @@ describe GitlabMarkdownHelper do end it "should leave ref-like href of 'manual' links untouched" do - expect(markdown("why not [inspect !#{merge_request.iid}](http://example.tld/#!#{merge_request.iid})")).to eq("

why not inspect !#{merge_request.iid}

\n") + expect(markdown("why not [inspect !#{merge_request.iid}](http://example.tld/#!#{merge_request.iid})")).to eq("

why not inspect !#{merge_request.iid}

\n") end it "should leave ref-like src of images untouched" do diff --git a/spec/lib/gitlab/markdown/commit_range_reference_filter_spec.rb b/spec/lib/gitlab/markdown/commit_range_reference_filter_spec.rb index 08bdf05eb96..3545d7f8085 100644 --- a/spec/lib/gitlab/markdown/commit_range_reference_filter_spec.rb +++ b/spec/lib/gitlab/markdown/commit_range_reference_filter_spec.rb @@ -38,6 +38,14 @@ module Gitlab::Markdown to eq urls.namespace_project_compare_url(project.namespace, project, from: commit1.id, to: commit2.id) end + it 'links to a valid short ID' do + reference = "#{commit1.short_id}...#{commit2.id}" + reference2 = "#{commit1.id}...#{commit2.short_id}" + + expect(filter("See #{reference}").css('a').first.text).to eq reference + expect(filter("See #{reference2}").css('a').first.text).to eq reference2 + end + it 'links with adjacent text' do doc = filter("See (#{reference}.)") expect(doc.to_html).to match(/\(#{Regexp.escape(reference)}<\/a>\.\)/) -- GitLab