Mercurial > hg > soundsoftware-site
comparison test/unit/lib/redmine/wiki_formatting/markdown_formatter.rb @ 1517:dffacf8a6908 redmine-2.5
Update to Redmine SVN revision 13367 on 2.5-stable branch
author | Chris Cannam |
---|---|
date | Tue, 09 Sep 2014 09:29:00 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
1516:b450a9d58aed | 1517:dffacf8a6908 |
---|---|
1 # Redmine - project management software | |
2 # Copyright (C) 2006-2014 Jean-Philippe Lang | |
3 # | |
4 # This program is free software; you can redistribute it and/or | |
5 # modify it under the terms of the GNU General Public License | |
6 # as published by the Free Software Foundation; either version 2 | |
7 # of the License, or (at your option) any later version. | |
8 # | |
9 # This program is distributed in the hope that it will be useful, | |
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 # GNU General Public License for more details. | |
13 # | |
14 # You should have received a copy of the GNU General Public License | |
15 # along with this program; if not, write to the Free Software | |
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |
17 | |
18 require File.expand_path('../../../../../test_helper', __FILE__) | |
19 | |
20 class Redmine::WikiFormatting::MarkdownFormatterTest < ActionView::TestCase | |
21 if Object.const_defined?(:Redcarpet) | |
22 | |
23 def setup | |
24 @formatter = Redmine::WikiFormatting::Markdown::Formatter | |
25 end | |
26 | |
27 def test_syntax_error_in_image_reference_should_not_raise_exception | |
28 assert @formatter.new("!>[](foo.png)").to_html | |
29 end | |
30 | |
31 # re-using the formatter after getting above error crashes the | |
32 # ruby interpreter. This seems to be related to | |
33 # https://github.com/vmg/redcarpet/issues/318 | |
34 def test_should_not_crash_redcarpet_after_syntax_error | |
35 @formatter.new("!>[](foo.png)").to_html rescue nil | |
36 assert @formatter.new("").to_html.present? | |
37 end | |
38 | |
39 def test_inline_style | |
40 assert_equal "<p><strong>foo</strong></p>", @formatter.new("**foo**").to_html.strip | |
41 end | |
42 | |
43 def test_not_set_intra_emphasis | |
44 assert_equal "<p>foo_bar_baz</p>", @formatter.new("foo_bar_baz").to_html.strip | |
45 end | |
46 | |
47 def test_wiki_links_should_be_preserved | |
48 text = 'This is a wiki link: [[Foo]]' | |
49 assert_include '[[Foo]]', @formatter.new(text).to_html | |
50 end | |
51 | |
52 def test_redmine_links_with_double_quotes_should_be_preserved | |
53 text = 'This is a redmine link: version:"1.0"' | |
54 assert_include 'version:"1.0"', @formatter.new(text).to_html | |
55 end | |
56 | |
57 def test_should_support_syntax_highligth | |
58 text = <<-STR | |
59 ~~~ruby | |
60 def foo | |
61 end | |
62 ~~~ | |
63 STR | |
64 assert_select_in @formatter.new(text).to_html, 'pre code.ruby.syntaxhl' do | |
65 assert_select 'span.keyword', :text => 'def' | |
66 end | |
67 end | |
68 | |
69 def test_external_links_should_have_external_css_class | |
70 text = 'This is a [link](http://example.net/)' | |
71 assert_equal '<p>This is a <a class="external" href="http://example.net/">link</a></p>', @formatter.new(text).to_html.strip | |
72 end | |
73 | |
74 def test_locals_links_should_not_have_external_css_class | |
75 text = 'This is a [link](/issues)' | |
76 assert_equal '<p>This is a <a href="/issues">link</a></p>', @formatter.new(text).to_html.strip | |
77 end | |
78 | |
79 end | |
80 end |