diff options
author | Ciro Santillli <ciro.santilli@gmail.com> | 2014-02-04 11:48:33 +0400 |
---|---|---|
committer | Ciro Santillli <ciro.santilli@gmail.com> | 2014-02-11 19:23:33 +0400 |
commit | 61748c993de8a38300c0c038cec5a07e6c324cd6 (patch) | |
tree | af9693096914e2de64eaf5bdde06f59b90317eaa /spec | |
parent | 1284f21c073e42c44b9faa7b0ad1ec90b66ca8fb (diff) |
Headers have ids and link to their own id.
Diffstat (limited to 'spec')
-rw-r--r-- | spec/helpers/gitlab_markdown_helper_spec.rb | 17 |
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 |