Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2014-02-11 22:32:21 +0400
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2014-02-11 22:32:21 +0400
commitc61512d4e18a873df229ba2fddb28dfddc423009 (patch)
tree06c847304eb50e7720e169a27d40048f49b4c362 /spec
parent6e47fbf5d9432c065199322a47bc465fccf9a132 (diff)
parent61748c993de8a38300c0c038cec5a07e6c324cd6 (diff)
Merge branch 'header-anchors' of github.com:cirosantilli/gitlab-elearn into cirosantilli-header-anchors
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> Conflicts: CHANGELOG
Diffstat (limited to 'spec')
-rw-r--r--spec/helpers/gitlab_markdown_helper_spec.rb17
1 files changed, 15 insertions, 2 deletions
diff --git a/spec/helpers/gitlab_markdown_helper_spec.rb b/spec/helpers/gitlab_markdown_helper_spec.rb
index 59abfb38ec0..a445c18f009 100644
--- a/spec/helpers/gitlab_markdown_helper_spec.rb
+++ b/spec/helpers/gitlab_markdown_helper_spec.rb
@@ -348,8 +348,21 @@ describe GitlabMarkdownHelper do
it "should handle references in headers" do
actual = "\n# Working around ##{issue.iid}\n## Apply !#{merge_request.iid}"
- markdown(actual).should match(%r{<h1[^<]*>Working around <a.+>##{issue.iid}</a></h1>})
- markdown(actual).should match(%r{<h2[^<]*>Apply <a.+>!#{merge_request.iid}</a></h2>})
+ markdown(actual, {no_header_anchors:true}).should match(%r{<h1[^<]*>Working around <a.+>##{issue.iid}</a></h1>})
+ markdown(actual, {no_header_anchors:true}).should match(%r{<h2[^<]*>Apply <a.+>!#{merge_request.iid}</a></h2>})
+ end
+
+ it "should add ids and links to headers" do
+ # Test every rule except nested tags.
+ text = '..Ab_c-d. e..'
+ id = 'ab_c-d-e'
+ markdown("# #{text}").should match(%r{<h1 id="#{id}">#{text}<a href="[^"]*##{id}"></a></h1>})
+ markdown("# #{text}", {no_header_anchors:true}).should == "<h1>#{text}</h1>"
+
+ id = 'link-text'
+ markdown("# [link text](url) ![img alt](url)").should match(
+ %r{<h1 id="#{id}"><a href="[^"]*url">link text</a> <img[^>]*><a href="[^"]*##{id}"></a></h1>}
+ )
end
it "should handle references in lists" do