diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2012-10-20 14:49:32 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2012-10-20 14:49:32 +0000 |
commit | d29fa4735b5744f3288e9c33a9e81a5f36abcca1 (patch) | |
tree | a94c328505f4c4a8cba94bc16bf0f70b6a790f78 /test | |
parent | 0faab70be58c2b52963b9eb02cc941e32b3c44c7 (diff) | |
download | redmine-d29fa4735b5744f3288e9c33a9e81a5f36abcca1.tar.gz redmine-d29fa4735b5744f3288e9c33a9e81a5f36abcca1.zip |
Adds a macro for inserting collapsed text (#12167).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@10680 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test')
-rw-r--r-- | test/test_helper.rb | 5 | ||||
-rw-r--r-- | test/unit/lib/redmine/wiki_formatting/macros_test.rb | 30 |
2 files changed, 35 insertions, 0 deletions
diff --git a/test/test_helper.rb b/test/test_helper.rb index 3c2cece7b..91e0d8cc6 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -185,6 +185,11 @@ class ActiveSupport::TestCase assert !s.include?(expected), "\"#{expected}\" found in \"#{s}\"" end + def assert_select_in(text, *args, &block) + d = HTML::Document.new(CGI::unescapeHTML(String.new(text))).root + assert_select(d, *args, &block) + end + def assert_mail_body_match(expected, mail) if expected.is_a?(String) assert_include expected, mail_body(mail) diff --git a/test/unit/lib/redmine/wiki_formatting/macros_test.rb b/test/unit/lib/redmine/wiki_formatting/macros_test.rb index 53665d017..08b0af462 100644 --- a/test/unit/lib/redmine/wiki_formatting/macros_test.rb +++ b/test/unit/lib/redmine/wiki_formatting/macros_test.rb @@ -180,6 +180,36 @@ class Redmine::WikiFormatting::MacrosTest < ActionView::TestCase assert_include 'Page not found', textilizable(text) end + def test_macro_collapse + text = "{{collapse\n*Collapsed* block of text\n}}" + result = textilizable(text) + + assert_select_in result, 'div.collapsed-text' + assert_select_in result, 'strong', :text => 'Collapsed' + assert_select_in result, 'a.collapsible.collapsed', :text => 'Show' + assert_select_in result, 'a.collapsible', :text => 'Hide' + end + + def test_macro_collapse_with_one_arg + text = "{{collapse(Example)\n*Collapsed* block of text\n}}" + result = textilizable(text) + + assert_select_in result, 'div.collapsed-text' + assert_select_in result, 'strong', :text => 'Collapsed' + assert_select_in result, 'a.collapsible.collapsed', :text => 'Example' + assert_select_in result, 'a.collapsible', :text => 'Example' + end + + def test_macro_collapse_with_two_args + text = "{{collapse(Show example, Hide example)\n*Collapsed* block of text\n}}" + result = textilizable(text) + + assert_select_in result, 'div.collapsed-text' + assert_select_in result, 'strong', :text => 'Collapsed' + assert_select_in result, 'a.collapsible.collapsed', :text => 'Show example' + assert_select_in result, 'a.collapsible', :text => 'Hide example' + end + def test_macro_child_pages expected = "<p><ul class=\"pages-hierarchy\">\n" + "<li><a href=\"/projects/ecookbook/wiki/Child_1\">Child 1</a>\n" + |