test/test_sourcehandler_page.rb in webgen-0.5.1 vs test/test_sourcehandler_page.rb in webgen-0.5.2
- old
+ new
@@ -1,23 +1,10 @@
require 'test/unit'
require 'helper'
require 'webgen/sourcehandler/page'
require 'stringio'
-class TestBlock < Test::Unit::TestCase
-
- def test_render
- block = Webgen::Block.new('content', 'some content', {'pipeline' => 'test'})
- context = {:processors => {}}
- assert_raise(RuntimeError) { block.render(context) }
- context[:processors]['test'] = lambda {|context| context[:content] = context[:content].reverse + context[:block].name }
- assert_equal('some content'.reverse + 'content', block.render(context)[:content])
- end
-
-end
-
-
class TestSourceHandlerPage < Test::Unit::TestCase
include Test::WebsiteHelper
def setup
@@ -30,10 +17,11 @@
@website.blackboard.add_service(:create_fragment_nodes) {nil}
@obj = Webgen::SourceHandler::Page.new
@root = Webgen::Node.new(Webgen::Tree.new.dummy_root, 'test/', 'test')
@path = path_with_meta_info('/index.page') {StringIO.new('content')}
@path.meta_info.update({'lang'=>'eo', 'test'=>'yes', 'sort_info'=>6})
+ @website.blackboard.add_service(:source_paths) {{@path.path => @path}}
end
def test_create_node
node = @obj.create_node(@root, @path.dup)
@@ -63,8 +51,19 @@
def test_render_node
node = @obj.create_node(@root, @path)
assert_equal("content", @obj.render_node(node))
assert_raise(RuntimeError) { @obj.render_node(node, 'other') }
+ end
+
+ def test_meta_info_changed
+ node = @obj.create_node(@root, @path)
+ @website.blackboard.dispatch_msg(:node_meta_info_changed?, node)
+ assert(node.meta_info_changed?)
+
+ node.dirty_meta_info = false
+ @website.cache.restore(@website.cache.dump)
+ @website.blackboard.dispatch_msg(:node_meta_info_changed?, node)
+ assert(!node.meta_info_changed?)
end
end