aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/controller/new_base/render_template_test.rb
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack/test/controller/new_base/render_template_test.rb')
-rw-r--r--actionpack/test/controller/new_base/render_template_test.rb54
1 files changed, 46 insertions, 8 deletions
diff --git a/actionpack/test/controller/new_base/render_template_test.rb b/actionpack/test/controller/new_base/render_template_test.rb
index 70cebbfd89..584f2d772c 100644
--- a/actionpack/test/controller/new_base/render_template_test.rb
+++ b/actionpack/test/controller/new_base/render_template_test.rb
@@ -4,17 +4,26 @@ module RenderTemplate
class WithoutLayoutController < ActionController::Base
self.view_paths = [ActionView::FixtureResolver.new(
- "test/basic.html.erb" => "Hello from basic.html.erb",
- "shared.html.erb" => "Elastica",
- "locals.html.erb" => "The secret is <%= secret %>",
- "xml_template.xml.builder" => "xml.html do\n xml.p 'Hello'\nend",
- "with_raw.html.erb" => "Hello <%=raw '<strong>this is raw</strong>' %>"
+ "test/basic.html.erb" => "Hello from basic.html.erb",
+ "shared.html.erb" => "Elastica",
+ "locals.html.erb" => "The secret is <%= secret %>",
+ "xml_template.xml.builder" => "xml.html do\n xml.p 'Hello'\nend",
+ "with_raw.html.erb" => "Hello <%=raw '<strong>this is raw</strong>' %>",
+ "with_implicit_raw.html.erb" => "Hello <%== '<strong>this is also raw</strong>' %>",
+ "test/with_json.html.erb" => "<%= render :template => 'test/with_json.json' %>",
+ "test/with_json.json.erb" => "<%= render :template => 'test/final' %>",
+ "test/final.json.erb" => "{ final: json }",
+ "test/with_error.html.erb" => "<%= idontexist %>"
)]
def index
render :template => "test/basic"
end
+ def html_with_json_inside_json
+ render :template => "test/with_json"
+ end
+
def index_without_key
render "test/basic"
end
@@ -42,6 +51,14 @@ module RenderTemplate
def with_raw
render :template => "with_raw"
end
+
+ def with_implicit_raw
+ render :template => "with_implicit_raw"
+ end
+
+ def with_error
+ render :template => "test/with_error"
+ end
end
class TestWithoutLayout < Rack::TestCase
@@ -87,6 +104,23 @@ module RenderTemplate
assert_body "Hello <strong>this is raw</strong>"
assert_status 200
+
+ get :with_implicit_raw
+
+ assert_body "Hello <strong>this is also raw</strong>"
+ assert_status 200
+ end
+
+ test "rendering a template with renders another template with other format that renders other template in the same format" do
+ get :html_with_json_inside_json
+ assert_content_type "text/html; charset=utf-8"
+ assert_response "{ final: json }"
+ end
+
+ test "rendering a template with error properly exceprts the code" do
+ get :with_error
+ assert_status 500
+ assert_match "undefined local variable or method `idontexist'", response.body
end
end
@@ -123,10 +157,14 @@ module RenderTemplate
describe "Rendering with :template using implicit or explicit layout"
test "rendering with implicit layout" do
- get "/render_template/with_layout"
+ with_routing do |set|
+ set.draw { match ':controller', :action => :index }
- assert_body "Hello from basic.html.erb, I'm here!"
- assert_status 200
+ get "/render_template/with_layout"
+
+ assert_body "Hello from basic.html.erb, I'm here!"
+ assert_status 200
+ end
end
test "rendering with layout => :true" do