From 208d2d4090878c34e0132d1be08aa7f1587602d1 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Mon, 14 Mar 2011 20:29:06 +0000 Subject: [PATCH] Moved text formatting tests from application_helper tests to formatter tests. git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@5132 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- test/unit/helpers/application_helper_test.rb | 105 ----------------- .../wiki_formatting/textile_formatter_test.rb | 109 ++++++++++++++++++ 2 files changed, 109 insertions(+), 105 deletions(-) diff --git a/test/unit/helpers/application_helper_test.rb b/test/unit/helpers/application_helper_test.rb index aa2c62776..6d46aedf0 100644 --- a/test/unit/helpers/application_helper_test.rb +++ b/test/unit/helpers/application_helper_test.rb @@ -602,111 +602,6 @@ RAW assert textilizable(raw).gsub("\n", "").include?(expected) end - def test_blockquote - # orig raw text - raw = <<-RAW -John said: -> Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas sed libero. -> Nullam commodo metus accumsan nulla. Curabitur lobortis dui id dolor. -> * Donec odio lorem, -> * sagittis ac, -> * malesuada in, -> * adipiscing eu, dolor. -> -> >Nulla varius pulvinar diam. Proin id arcu id lorem scelerisque condimentum. Proin vehicula turpis vitae lacus. -> Proin a tellus. Nam vel neque. - -He's right. -RAW - - # expected html - expected = <<-EXPECTED -

John said:

-
-Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas sed libero. -Nullam commodo metus accumsan nulla. Curabitur lobortis dui id dolor. - -
-

Nulla varius pulvinar diam. Proin id arcu id lorem scelerisque condimentum. Proin vehicula turpis vitae lacus.

-
-

Proin a tellus. Nam vel neque.

-
-

He's right.

-EXPECTED - - assert_equal expected.gsub(%r{\s+}, ''), textilizable(raw).gsub(%r{\s+}, '') - end - - def test_table - raw = <<-RAW -This is a table with empty cells: - -|cell11|cell12|| -|cell21||cell23| -|cell31|cell32|cell33| -RAW - - expected = <<-EXPECTED -

This is a table with empty cells:

- - - - - -
cell11cell12
cell21cell23
cell31cell32cell33
-EXPECTED - - assert_equal expected.gsub(%r{\s+}, ''), textilizable(raw).gsub(%r{\s+}, '') - end - - def test_table_with_line_breaks - raw = <<-RAW -This is a table with line breaks: - -|cell11 -continued|cell12|| -|-cell21-||cell23 -cell23 line2 -cell23 *line3*| -|cell31|cell32 -cell32 line2|cell33| - -RAW - - expected = <<-EXPECTED -

This is a table with line breaks:

- - - - - - - - - - - - - - - - - -
cell11
continued
cell12
cell21cell23
cell23 line2
cell23 line3
cell31cell32
cell32 line2
cell33
-EXPECTED - - assert_equal expected.gsub(%r{\s+}, ''), textilizable(raw).gsub(%r{\s+}, '') - end - - def test_textile_should_not_mangle_brackets - assert_equal '

[msg1][msg2]

', textilizable('[msg1][msg2]') - end - def test_default_formatter Setting.text_formatting = 'unknown' text = 'a *link*: http://www.example.net/' diff --git a/test/unit/lib/redmine/wiki_formatting/textile_formatter_test.rb b/test/unit/lib/redmine/wiki_formatting/textile_formatter_test.rb index 69b410e83..a221b6c8d 100644 --- a/test/unit/lib/redmine/wiki_formatting/textile_formatter_test.rb +++ b/test/unit/lib/redmine/wiki_formatting/textile_formatter_test.rb @@ -92,6 +92,111 @@ class Redmine::WikiFormatting::TextileFormatterTest < HelperTestCase ) end + def test_blockquote + # orig raw text + raw = <<-RAW +John said: +> Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas sed libero. +> Nullam commodo metus accumsan nulla. Curabitur lobortis dui id dolor. +> * Donec odio lorem, +> * sagittis ac, +> * malesuada in, +> * adipiscing eu, dolor. +> +> >Nulla varius pulvinar diam. Proin id arcu id lorem scelerisque condimentum. Proin vehicula turpis vitae lacus. +> Proin a tellus. Nam vel neque. + +He's right. +RAW + + # expected html + expected = <<-EXPECTED +

John said:

+
+Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas sed libero. +Nullam commodo metus accumsan nulla. Curabitur lobortis dui id dolor. + +
+

Nulla varius pulvinar diam. Proin id arcu id lorem scelerisque condimentum. Proin vehicula turpis vitae lacus.

+
+

Proin a tellus. Nam vel neque.

+
+

He's right.

+EXPECTED + + assert_equal expected.gsub(%r{\s+}, ''), to_html(raw).gsub(%r{\s+}, '') + end + + def test_table + raw = <<-RAW +This is a table with empty cells: + +|cell11|cell12|| +|cell21||cell23| +|cell31|cell32|cell33| +RAW + + expected = <<-EXPECTED +

This is a table with empty cells:

+ + + + + +
cell11cell12
cell21cell23
cell31cell32cell33
+EXPECTED + + assert_equal expected.gsub(%r{\s+}, ''), to_html(raw).gsub(%r{\s+}, '') + end + + def test_table_with_line_breaks + raw = <<-RAW +This is a table with line breaks: + +|cell11 +continued|cell12|| +|-cell21-||cell23 +cell23 line2 +cell23 *line3*| +|cell31|cell32 +cell32 line2|cell33| + +RAW + + expected = <<-EXPECTED +

This is a table with line breaks:

+ + + + + + + + + + + + + + + + + +
cell11
continued
cell12
cell21cell23
cell23 line2
cell23 line3
cell31cell32
cell32 line2
cell33
+EXPECTED + + assert_equal expected.gsub(%r{\s+}, ''), to_html(raw).gsub(%r{\s+}, '') + end + + def test_textile_should_not_mangle_brackets + assert_equal '

[msg1][msg2]

', to_html('[msg1][msg2]') + end + private def assert_html_output(to_test, expect_paragraph = true) @@ -99,4 +204,8 @@ class Redmine::WikiFormatting::TextileFormatterTest < HelperTestCase assert_equal(( expect_paragraph ? "

#{expected}

" : expected ), @formatter.new(text).to_html, "Formatting the following text failed:\n===\n#{text}\n===\n") end end + + def to_html(text) + @formatter.new(text).to_html + end end -- 2.39.5