From a6d80426a91b4a647e7b4a1b8ace85a9ce3b58d1 Mon Sep 17 00:00:00 2001 From: Jacques Distler Date: Thu, 15 Jan 2009 22:42:09 -0600 Subject: [PATCH] Revert Revision 338 That didn't work with nested includes: A: [[!include B]] B: [[!include C]] C: fubar! Added a test for that issue. --- lib/chunks/include.rb | 1 + lib/wiki_content.rb | 3 +-- test/functional/wiki_controller_test.rb | 31 ++++++++++++++++++------- 3 files changed, 24 insertions(+), 11 deletions(-) diff --git a/lib/chunks/include.rb b/lib/chunks/include.rb index 2b91b700..81d1a9b8 100644 --- a/lib/chunks/include.rb +++ b/lib/chunks/include.rb @@ -32,6 +32,7 @@ class Include < WikiChunk::WikiReference when :show then renderer.display_content when :publish then renderer.display_published when :export then renderer.display_content_for_export + when :s5 then renderer.display_s5 else raise "Unsupported rendering mode #{@mode.inspect}" end diff --git a/lib/wiki_content.rb b/lib/wiki_content.rb index 5f04fb09..5ed9768c 100644 --- a/lib/wiki_content.rb +++ b/lib/wiki_content.rb @@ -177,8 +177,7 @@ class WikiContent < String def pre_render! unless @pre_rendered @chunks_by_type[Include].each{|chunk| chunk.unmask } - @pre_rendered = String.new - @pre_rendered = self + @pre_rendered = String.new(self) end @pre_rendered end diff --git a/test/functional/wiki_controller_test.rb b/test/functional/wiki_controller_test.rb index 2d8872e0..5721faa6 100755 --- a/test/functional/wiki_controller_test.rb +++ b/test/functional/wiki_controller_test.rb @@ -753,34 +753,47 @@ class WikiControllerTest < Test::Unit::TestCase r = process('show', 'id' => 'HomePage', 'web' => 'wiki1') assert_response :success - assert_match /Self-include: Recursive include detected: HomePage \342\206\222 HomePage<\/em>/, r.body + assert_match /Recursive include detected: HomePage \342\206\222 HomePage<\/em>/, r.body end def test_recursive_include_II - @wiki.write_page('wiki1', 'Foo', 'extra fun [[!include HomePage]]', Time.now, + @wiki.write_page('wiki1', 'Foo', "extra fun [[!include HomePage]]", Time.now, Author.new('AnotherAuthor', '127.0.0.2'), test_renderer) - @wiki.write_page('wiki1', 'HomePage', 'Recursive-include: [[!include Foo]]', Time.now, + @wiki.write_page('wiki1', 'HomePage', "Recursive-include:\n\n[[!include Foo]]", Time.now, Author.new('AnotherAuthor', '127.0.0.2'), test_renderer) r = process('show', 'id' => 'HomePage', 'web' => 'wiki1') assert_response :success - assert_match /Recursive-include: extra fun Recursive include detected: Foo \342\206\222 Foo<\/em>/, r.body + assert_match /

Recursive-include:<\/p>\n\n

extra fun Recursive include detected: Foo \342\206\222 Foo<\/em><\/p>/, r.body end def test_recursive_include_III - @wiki.write_page('wiki1', 'Bar', 'extra fun [[!include HomePage]]', Time.now, + @wiki.write_page('wiki1', 'Bar', "extra fun\n\n[[!include HomePage]]", Time.now, Author.new('AnotherAuthor', '127.0.0.2'), test_renderer) - @wiki.write_page('wiki1', 'Foo', '[[!include Bar]] [[!include Bar]]', Time.now, + @wiki.write_page('wiki1', 'Foo', "[[!include Bar]]\n\n[[!include Bar]]", Time.now, Author.new('AnotherAuthor', '127.0.0.2'), test_renderer) - @wiki.write_page('wiki1', 'HomePage', 'Recursive-include: [[!include Foo]]', Time.now, + @wiki.write_page('wiki1', 'HomePage', "Recursive-include:\n\n[[!include Foo]]", Time.now, Author.new('AnotherAuthor', '127.0.0.2'), test_renderer) r = process('show', 'id' => 'HomePage', 'web' => 'wiki1') assert_response :success - assert_match /Recursive-include: extra fun Recursive include detected: Bar \342\206\222 Bar<\/em>/, r.body - assert_match /extra fun Recursive-include: Recursive include detected: HomePage \342\206\222 HomePage<\/em>/, r.body + assert_match /

Recursive-include:<\/p>\n\n

extra fun<\/p>\nRecursive include detected: Bar \342\206\222 Bar<\/em>/, r.body + end + + def test_nonrecursive_include + @wiki.write_page('wiki1', 'Bar', "extra fun\n\n[[HomePage]]", Time.now, + Author.new('AnotherAuthor', '127.0.0.2'), test_renderer) + @wiki.write_page('wiki1', 'Foo', "[[!include Bar]]\n\n[[!include Bar]]", Time.now, + Author.new('AnotherAuthor', '127.0.0.2'), test_renderer) + @wiki.write_page('wiki1', 'HomePage', "Nonrecursive-include:\n\n[[!include Foo]]", Time.now, + Author.new('AnotherAuthor', '127.0.0.2'), test_renderer) + + r = process('show', 'id' => 'HomePage', 'web' => 'wiki1') + + assert_response :success + assert_match /

Nonrecursive-include:<\/p>\n\n

extra fun<\/p>\n\n

HomePage<\/a><\/p>/, r.body end def test_show_page_nonexistant_page