diff options
author | Michael Koziarski <michael@koziarski.com> | 2008-03-03 04:01:35 +0000 |
---|---|---|
committer | Michael Koziarski <michael@koziarski.com> | 2008-03-03 04:01:35 +0000 |
commit | 51b6619d4e78d9948952dab4709274ab57f41206 (patch) | |
tree | bab7a4d988c9349f4d8241e38e09f30d62b0049b /actionpack/test/template/template_object_test.rb | |
parent | 10d9d0b6fe023df1be0d87ca95bb739bb7eb30ba (diff) | |
download | rails-51b6619d4e78d9948952dab4709274ab57f41206.tar.gz rails-51b6619d4e78d9948952dab4709274ab57f41206.tar.bz2 rails-51b6619d4e78d9948952dab4709274ab57f41206.zip |
Refactor partial rendering into a PartialTemplate class. [Pratik]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8976 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/test/template/template_object_test.rb')
-rw-r--r-- | actionpack/test/template/template_object_test.rb | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/actionpack/test/template/template_object_test.rb b/actionpack/test/template/template_object_test.rb new file mode 100644 index 0000000000..780df17f0c --- /dev/null +++ b/actionpack/test/template/template_object_test.rb @@ -0,0 +1,62 @@ +require 'abstract_unit' + +class TemplateObjectTest < Test::Unit::TestCase + LOAD_PATH_ROOT = File.join(File.dirname(__FILE__), '..', 'fixtures') + ActionView::TemplateFinder.process_view_paths(LOAD_PATH_ROOT) + + class TemplateTest < Test::Unit::TestCase + def setup + @view = ActionView::Base.new(LOAD_PATH_ROOT) + @path = "test/hello_world.erb" + end + + def test_should_create_valid_template + template = ActionView::Template.new(@view, @path, true) + + assert_kind_of ActionView::TemplateHandlers::ERB, template.handler + assert_equal "test/hello_world.erb", template.path + assert_nil template.instance_variable_get(:"@source") + assert_equal "erb", template.extension + end + + uses_mocha 'Template preparation tests' do + + def test_should_prepare_template_properly + template = ActionView::Template.new(@view, @path, true) + view = template.instance_variable_get(:"@view") + + view.expects(:evaluate_assigns) + template.handler.expects(:compile_template).with(template) + view.expects(:method_names).returns({}) + + template.prepare! + end + + end + end + + class PartialTemplateTest < Test::Unit::TestCase + def setup + @view = ActionView::Base.new(LOAD_PATH_ROOT) + @path = "test/partial_only" + end + + def test_should_create_valid_partial_template + template = ActionView::PartialTemplate.new(@view, @path, nil) + + assert_equal "test/_partial_only", template.path + assert_equal :partial_only, template.variable_name + + assert template.locals.has_key?(:object) + assert template.locals.has_key?(:partial_only) + end + + uses_mocha 'Partial template preparation tests' do + def test_should_prepare_on_initialization + ActionView::PartialTemplate.any_instance.expects(:prepare!) + template = ActionView::PartialTemplate.new(@view, @path, 1) + end + end + end + +end |