##// END OF EJS Templates
Moved text formatting tests from application_helper tests to formatter tests....
Jean-Philippe Lang -
r5012:208d2d409087
parent child
Show More
@@ -602,111 +602,6 RAW
602 assert textilizable(raw).gsub("\n", "").include?(expected)
602 assert textilizable(raw).gsub("\n", "").include?(expected)
603 end
603 end
604
604
605 def test_blockquote
606 # orig raw text
607 raw = <<-RAW
608 John said:
609 > Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas sed libero.
610 > Nullam commodo metus accumsan nulla. Curabitur lobortis dui id dolor.
611 > * Donec odio lorem,
612 > * sagittis ac,
613 > * malesuada in,
614 > * adipiscing eu, dolor.
615 >
616 > >Nulla varius pulvinar diam. Proin id arcu id lorem scelerisque condimentum. Proin vehicula turpis vitae lacus.
617 > Proin a tellus. Nam vel neque.
618
619 He's right.
620 RAW
621
622 # expected html
623 expected = <<-EXPECTED
624 <p>John said:</p>
625 <blockquote>
626 Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas sed libero.
627 Nullam commodo metus accumsan nulla. Curabitur lobortis dui id dolor.
628 <ul>
629 <li>Donec odio lorem,</li>
630 <li>sagittis ac,</li>
631 <li>malesuada in,</li>
632 <li>adipiscing eu, dolor.</li>
633 </ul>
634 <blockquote>
635 <p>Nulla varius pulvinar diam. Proin id arcu id lorem scelerisque condimentum. Proin vehicula turpis vitae lacus.</p>
636 </blockquote>
637 <p>Proin a tellus. Nam vel neque.</p>
638 </blockquote>
639 <p>He's right.</p>
640 EXPECTED
641
642 assert_equal expected.gsub(%r{\s+}, ''), textilizable(raw).gsub(%r{\s+}, '')
643 end
644
645 def test_table
646 raw = <<-RAW
647 This is a table with empty cells:
648
649 |cell11|cell12||
650 |cell21||cell23|
651 |cell31|cell32|cell33|
652 RAW
653
654 expected = <<-EXPECTED
655 <p>This is a table with empty cells:</p>
656
657 <table>
658 <tr><td>cell11</td><td>cell12</td><td></td></tr>
659 <tr><td>cell21</td><td></td><td>cell23</td></tr>
660 <tr><td>cell31</td><td>cell32</td><td>cell33</td></tr>
661 </table>
662 EXPECTED
663
664 assert_equal expected.gsub(%r{\s+}, ''), textilizable(raw).gsub(%r{\s+}, '')
665 end
666
667 def test_table_with_line_breaks
668 raw = <<-RAW
669 This is a table with line breaks:
670
671 |cell11
672 continued|cell12||
673 |-cell21-||cell23
674 cell23 line2
675 cell23 *line3*|
676 |cell31|cell32
677 cell32 line2|cell33|
678
679 RAW
680
681 expected = <<-EXPECTED
682 <p>This is a table with line breaks:</p>
683
684 <table>
685 <tr>
686 <td>cell11<br />continued</td>
687 <td>cell12</td>
688 <td></td>
689 </tr>
690 <tr>
691 <td><del>cell21</del></td>
692 <td></td>
693 <td>cell23<br/>cell23 line2<br/>cell23 <strong>line3</strong></td>
694 </tr>
695 <tr>
696 <td>cell31</td>
697 <td>cell32<br/>cell32 line2</td>
698 <td>cell33</td>
699 </tr>
700 </table>
701 EXPECTED
702
703 assert_equal expected.gsub(%r{\s+}, ''), textilizable(raw).gsub(%r{\s+}, '')
704 end
705
706 def test_textile_should_not_mangle_brackets
707 assert_equal '<p>[msg1][msg2]</p>', textilizable('[msg1][msg2]')
708 end
709
710 def test_default_formatter
605 def test_default_formatter
711 Setting.text_formatting = 'unknown'
606 Setting.text_formatting = 'unknown'
712 text = 'a *link*: http://www.example.net/'
607 text = 'a *link*: http://www.example.net/'
@@ -92,6 +92,111 class Redmine::WikiFormatting::TextileFormatterTest < HelperTestCase
92 )
92 )
93 end
93 end
94
94
95 def test_blockquote
96 # orig raw text
97 raw = <<-RAW
98 John said:
99 > Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas sed libero.
100 > Nullam commodo metus accumsan nulla. Curabitur lobortis dui id dolor.
101 > * Donec odio lorem,
102 > * sagittis ac,
103 > * malesuada in,
104 > * adipiscing eu, dolor.
105 >
106 > >Nulla varius pulvinar diam. Proin id arcu id lorem scelerisque condimentum. Proin vehicula turpis vitae lacus.
107 > Proin a tellus. Nam vel neque.
108
109 He's right.
110 RAW
111
112 # expected html
113 expected = <<-EXPECTED
114 <p>John said:</p>
115 <blockquote>
116 Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas sed libero.
117 Nullam commodo metus accumsan nulla. Curabitur lobortis dui id dolor.
118 <ul>
119 <li>Donec odio lorem,</li>
120 <li>sagittis ac,</li>
121 <li>malesuada in,</li>
122 <li>adipiscing eu, dolor.</li>
123 </ul>
124 <blockquote>
125 <p>Nulla varius pulvinar diam. Proin id arcu id lorem scelerisque condimentum. Proin vehicula turpis vitae lacus.</p>
126 </blockquote>
127 <p>Proin a tellus. Nam vel neque.</p>
128 </blockquote>
129 <p>He's right.</p>
130 EXPECTED
131
132 assert_equal expected.gsub(%r{\s+}, ''), to_html(raw).gsub(%r{\s+}, '')
133 end
134
135 def test_table
136 raw = <<-RAW
137 This is a table with empty cells:
138
139 |cell11|cell12||
140 |cell21||cell23|
141 |cell31|cell32|cell33|
142 RAW
143
144 expected = <<-EXPECTED
145 <p>This is a table with empty cells:</p>
146
147 <table>
148 <tr><td>cell11</td><td>cell12</td><td></td></tr>
149 <tr><td>cell21</td><td></td><td>cell23</td></tr>
150 <tr><td>cell31</td><td>cell32</td><td>cell33</td></tr>
151 </table>
152 EXPECTED
153
154 assert_equal expected.gsub(%r{\s+}, ''), to_html(raw).gsub(%r{\s+}, '')
155 end
156
157 def test_table_with_line_breaks
158 raw = <<-RAW
159 This is a table with line breaks:
160
161 |cell11
162 continued|cell12||
163 |-cell21-||cell23
164 cell23 line2
165 cell23 *line3*|
166 |cell31|cell32
167 cell32 line2|cell33|
168
169 RAW
170
171 expected = <<-EXPECTED
172 <p>This is a table with line breaks:</p>
173
174 <table>
175 <tr>
176 <td>cell11<br />continued</td>
177 <td>cell12</td>
178 <td></td>
179 </tr>
180 <tr>
181 <td><del>cell21</del></td>
182 <td></td>
183 <td>cell23<br/>cell23 line2<br/>cell23 <strong>line3</strong></td>
184 </tr>
185 <tr>
186 <td>cell31</td>
187 <td>cell32<br/>cell32 line2</td>
188 <td>cell33</td>
189 </tr>
190 </table>
191 EXPECTED
192
193 assert_equal expected.gsub(%r{\s+}, ''), to_html(raw).gsub(%r{\s+}, '')
194 end
195
196 def test_textile_should_not_mangle_brackets
197 assert_equal '<p>[msg1][msg2]</p>', to_html('[msg1][msg2]')
198 end
199
95 private
200 private
96
201
97 def assert_html_output(to_test, expect_paragraph = true)
202 def assert_html_output(to_test, expect_paragraph = true)
@@ -99,4 +204,8 class Redmine::WikiFormatting::TextileFormatterTest < HelperTestCase
99 assert_equal(( expect_paragraph ? "<p>#{expected}</p>" : expected ), @formatter.new(text).to_html, "Formatting the following text failed:\n===\n#{text}\n===\n")
204 assert_equal(( expect_paragraph ? "<p>#{expected}</p>" : expected ), @formatter.new(text).to_html, "Formatting the following text failed:\n===\n#{text}\n===\n")
100 end
205 end
101 end
206 end
207
208 def to_html(text)
209 @formatter.new(text).to_html
210 end
102 end
211 end
General Comments 0
You need to be logged in to leave comments. Login now