Revert Revision 338
That didn't work with nested includes: A: [[!include B]] B: [[!include C]] C: fubar! Added a test for that issue.
This commit is contained in:
parent
41006d20ef
commit
a6d80426a9
3 changed files with 24 additions and 11 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -753,34 +753,47 @@ class WikiControllerTest < Test::Unit::TestCase
|
|||
r = process('show', 'id' => 'HomePage', 'web' => 'wiki1')
|
||||
|
||||
assert_response :success
|
||||
assert_match /Self-include: <em>Recursive include detected: HomePage \342\206\222 HomePage<\/em>/, r.body
|
||||
assert_match /<em>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 <em>Recursive include detected: Foo \342\206\222 Foo<\/em>/, r.body
|
||||
assert_match /<p>Recursive-include:<\/p>\n\n<p>extra fun <em>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 <em>Recursive include detected: Bar \342\206\222 Bar<\/em>/, r.body
|
||||
assert_match /extra fun Recursive-include: <em>Recursive include detected: HomePage \342\206\222 HomePage<\/em>/, r.body
|
||||
assert_match /<p>Recursive-include:<\/p>\n\n<p>extra fun<\/p>\n<em>Recursive 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 /<p>Nonrecursive-include:<\/p>\n\n<p>extra fun<\/p>\n\n<p><a class='existingWikiWord' href='http:\/\/test.host\/wiki1\/show\/HomePage'>HomePage<\/a><\/p>/, r.body
|
||||
end
|
||||
|
||||
def test_show_page_nonexistant_page
|
||||
|
|
Loading…
Reference in a new issue