aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/abstract
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack/test/abstract')
-rw-r--r--actionpack/test/abstract/abstract_controller_test.rb4
-rw-r--r--actionpack/test/abstract/layouts_test.rb118
-rw-r--r--actionpack/test/abstract/localized_cache_test.rb57
-rw-r--r--actionpack/test/abstract/render_test.rb61
4 files changed, 88 insertions, 152 deletions
diff --git a/actionpack/test/abstract/abstract_controller_test.rb b/actionpack/test/abstract/abstract_controller_test.rb
index 4ad87d9762..f70d497481 100644
--- a/actionpack/test/abstract/abstract_controller_test.rb
+++ b/actionpack/test/abstract/abstract_controller_test.rb
@@ -59,11 +59,11 @@ module AbstractController
end
def rendering_to_body
- self.response_body = render_to_body :_template_name => "naked_render.erb"
+ self.response_body = render_to_body :template => "naked_render.erb"
end
def rendering_to_string
- self.response_body = render_to_string :_template_name => "naked_render.erb"
+ self.response_body = render_to_string :template => "naked_render.erb"
end
end
diff --git a/actionpack/test/abstract/layouts_test.rb b/actionpack/test/abstract/layouts_test.rb
index b6d89ea489..65a50807fd 100644
--- a/actionpack/test/abstract/layouts_test.rb
+++ b/actionpack/test/abstract/layouts_test.rb
@@ -8,41 +8,52 @@ module AbstractControllerTests
include AbstractController::Rendering
include AbstractController::Layouts
+ def _prefix
+ "template"
+ end
+
self.view_paths = [ActionView::FixtureResolver.new(
- "layouts/hello.erb" => "With String <%= yield %>",
- "layouts/hello_override.erb" => "With Override <%= yield %>",
- "layouts/abstract_controller_tests/layouts/with_string_implied_child.erb" =>
- "With Implied <%= yield %>",
- "layouts/overwrite.erb" => "Overwrite <%= yield %>",
- "layouts/with_false_layout.erb" => "False Layout <%= yield %>"
+ "abstract_controller_tests/layouts/with_string_implied_child.erb" =>
+ "With Implied <%= yield %>",
+ "layouts/hello.erb" => "With String <%= yield %>",
+ "layouts/hello_override.erb" => "With Override <%= yield %>",
+ "layouts/overwrite.erb" => "Overwrite <%= yield %>",
+ "layouts/with_false_layout.erb" => "False Layout <%= yield %>"
)]
end
class Blank < Base
- self.view_paths = []
-
+ self.view_paths = ActionView::FixtureResolver.new("template/index.erb" => "Hello blank!")
+
def index
- render :_template => ActionView::Template::Text.new("Hello blank!")
+ render
end
end
class WithString < Base
layout "hello"
-
+
+ append_view_path ActionView::FixtureResolver.new(
+ "template/index.erb" => "Hello string!",
+ "template/overwrite_default.erb" => "Hello string!",
+ "template/overwrite_false.erb" => "Hello string!",
+ "template/overwrite_string.erb" => "Hello string!"
+ )
+
def index
- render :_template => ActionView::Template::Text.new("Hello string!")
+ render
end
def overwrite_default
- render :_template => ActionView::Template::Text.new("Hello string!"), :layout => :default
+ render :layout => :default
end
def overwrite_false
- render :_template => ActionView::Template::Text.new("Hello string!"), :layout => false
+ render :layout => false
end
def overwrite_string
- render :_template => ActionView::Template::Text.new("Hello string!"), :layout => "overwrite"
+ render :layout => "overwrite"
end
def overwrite_skip
@@ -70,18 +81,28 @@ module AbstractControllerTests
class WithProc < Base
layout proc { |c| "overwrite" }
+ append_view_path ActionView::FixtureResolver.new(
+ "template/index.erb" => "Hello proc!"
+ )
+
def index
- render :_template => ActionView::Template::Text.new("Hello proc!")
+ render
end
end
class WithSymbol < Base
layout :hello
-
+
+ append_view_path ActionView::FixtureResolver.new(
+ "template/index.erb" => "Hello symbol!"
+ )
+
def index
- render :_template => ActionView::Template::Text.new("Hello symbol!")
+ render
end
- private
+
+ private
+
def hello
"overwrite"
end
@@ -89,11 +110,17 @@ module AbstractControllerTests
class WithSymbolReturningString < Base
layout :no_hello
-
+
+ append_view_path ActionView::FixtureResolver.new(
+ "template/index.erb" => "Hello missing symbol!"
+ )
+
def index
- render :_template => ActionView::Template::Text.new("Hello missing symbol!")
+ render
end
- private
+
+ private
+
def no_hello
nil
end
@@ -101,19 +128,28 @@ module AbstractControllerTests
class WithSymbolReturningNil < Base
layout :nilz
-
+
+ append_view_path ActionView::FixtureResolver.new(
+ "template/index.erb" => "Hello nilz!"
+ )
+
def index
- render :_template => ActionView::Template::Text.new("Hello nilz!")
+ render
end
- def nilz() end
+ def nilz
+ end
end
class WithSymbolReturningObj < Base
layout :objekt
-
+
+ append_view_path ActionView::FixtureResolver.new(
+ "template/index.erb" => "Hello object!"
+ )
+
def index
- render :_template => ActionView::Template::Text.new("Hello nilz!")
+ render
end
def objekt
@@ -123,33 +159,49 @@ module AbstractControllerTests
class WithSymbolAndNoMethod < Base
layout :no_method
-
+
+ append_view_path ActionView::FixtureResolver.new(
+ "template/index.erb" => "Hello boom!"
+ )
+
def index
- render :_template => ActionView::Template::Text.new("Hello boom!")
+ render
end
end
class WithMissingLayout < Base
layout "missing"
-
+
+ append_view_path ActionView::FixtureResolver.new(
+ "template/index.erb" => "Hello missing!"
+ )
+
def index
- render :_template => ActionView::Template::Text.new("Hello missing!")
+ render
end
end
class WithFalseLayout < Base
layout false
-
+
+ append_view_path ActionView::FixtureResolver.new(
+ "template/index.erb" => "Hello false!"
+ )
+
def index
- render :_template => ActionView::Template::Text.new("Hello false!")
+ render
end
end
class WithNilLayout < Base
layout nil
+
+ append_view_path ActionView::FixtureResolver.new(
+ "template/index.erb" => "Hello nil!"
+ )
def index
- render :_template => ActionView::Template::Text.new("Hello nil!")
+ render
end
end
diff --git a/actionpack/test/abstract/localized_cache_test.rb b/actionpack/test/abstract/localized_cache_test.rb
deleted file mode 100644
index 8b0b0fff03..0000000000
--- a/actionpack/test/abstract/localized_cache_test.rb
+++ /dev/null
@@ -1,57 +0,0 @@
-require 'abstract_unit'
-
-module AbstractController
- module Testing
-
- class CachedController < AbstractController::Base
- include AbstractController::Rendering
- include AbstractController::LocalizedCache
-
- self.view_paths = [ActionView::FixtureResolver.new(
- "default.erb" => "With Default",
- "template.erb" => "With Template",
- "some/file.erb" => "With File",
- "template_name.erb" => "With Template Name"
- )]
- end
-
- class TestLocalizedCache < ActiveSupport::TestCase
-
- def setup
- @controller = CachedController.new
- CachedController.clear_template_caches!
- end
-
- def test_templates_are_cached
- @controller.render :template => "default.erb"
- assert_equal "With Default", @controller.response_body
-
- cached = @controller.class.template_cache
- assert_equal 1, cached.size
- assert_kind_of ActionView::Template, cached.values.first["default.erb"]
- end
-
- def test_cache_is_used
- CachedController.new.render :template => "default.erb"
-
- @controller.expects(:find_template).never
- @controller.render :template => "default.erb"
-
- assert_equal 1, @controller.class.template_cache.size
- end
-
- def test_cache_changes_with_locale
- CachedController.new.render :template => "default.erb"
-
- I18n.locale = :es
- @controller.render :template => "default.erb"
-
- assert_equal 2, @controller.class.template_cache.size
- ensure
- I18n.locale = :en
- end
-
- end
-
- end
-end
diff --git a/actionpack/test/abstract/render_test.rb b/actionpack/test/abstract/render_test.rb
index db924633ca..25dc8bd804 100644
--- a/actionpack/test/abstract/render_test.rb
+++ b/actionpack/test/abstract/render_test.rb
@@ -15,13 +15,8 @@ module AbstractController
"renderer/default.erb" => "With Default",
"renderer/string.erb" => "With String",
"renderer/symbol.erb" => "With Symbol",
- "renderer/template_name.erb" => "With Template Name",
"string/with_path.erb" => "With String With Path",
- "some/file.erb" => "With File",
- "with_format.html.erb" => "With html format",
- "with_format.xml.erb" => "With xml format",
- "with_locale.en.erb" => "With en locale",
- "with_locale.pl.erb" => "With pl locale"
+ "some/file.erb" => "With File"
)]
def template
@@ -55,30 +50,6 @@ module AbstractController
def symbol
render :symbol
end
-
- def template_name
- render :_template_name => :template_name
- end
-
- def object
- render :_template => ActionView::Template::Text.new("With Object")
- end
-
- def with_html_format
- render :template => "with_format", :format => :html
- end
-
- def with_xml_format
- render :template => "with_format", :format => :xml
- end
-
- def with_en_locale
- render :template => "with_locale"
- end
-
- def with_pl_locale
- render :template => "with_locale", :locale => :pl
- end
end
class TestRenderer < ActiveSupport::TestCase
@@ -126,36 +97,6 @@ module AbstractController
@controller.process(:string_with_path)
assert_equal "With String With Path", @controller.response_body
end
-
- def test_render_template_name
- @controller.process(:template_name)
- assert_equal "With Template Name", @controller.response_body
- end
-
- def test_render_object
- @controller.process(:object)
- assert_equal "With Object", @controller.response_body
- end
-
- def test_render_with_html_format
- @controller.process(:with_html_format)
- assert_equal "With html format", @controller.response_body
- end
-
- def test_render_with_xml_format
- @controller.process(:with_xml_format)
- assert_equal "With xml format", @controller.response_body
- end
-
- def test_render_with_en_locale
- @controller.process(:with_en_locale)
- assert_equal "With en locale", @controller.response_body
- end
-
- def test_render_with_pl_locale
- @controller.process(:with_pl_locale)
- assert_equal "With pl locale", @controller.response_body
- end
end
end
end