aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test
diff options
context:
space:
mode:
authorJosé Valim <jose.valim@gmail.com>2010-10-07 21:30:19 +0200
committerJosé Valim <jose.valim@gmail.com>2010-10-07 21:31:31 +0200
commitc7760809bfc8e19362272b71b23a294d48195d65 (patch)
tree1666edc988670ebe6ccc966a778ebae1759b7f43 /actionpack/test
parentc563f10f3e8083bebe32200fa065748c8bcb65c9 (diff)
downloadrails-c7760809bfc8e19362272b71b23a294d48195d65.tar.gz
rails-c7760809bfc8e19362272b71b23a294d48195d65.tar.bz2
rails-c7760809bfc8e19362272b71b23a294d48195d65.zip
Allow cache to be temporarily disabled through lookup_context.
Diffstat (limited to 'actionpack/test')
-rw-r--r--actionpack/test/controller/new_base/render_template_test.rb13
-rw-r--r--actionpack/test/template/lookup_context_test.rb21
2 files changed, 33 insertions, 1 deletions
diff --git a/actionpack/test/controller/new_base/render_template_test.rb b/actionpack/test/controller/new_base/render_template_test.rb
index 8f5f51d70b..d31193a063 100644
--- a/actionpack/test/controller/new_base/render_template_test.rb
+++ b/actionpack/test/controller/new_base/render_template_test.rb
@@ -11,7 +11,8 @@ module RenderTemplate
"with_raw.html.erb" => "Hello <%=raw '<strong>this is 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/final.json.erb" => "{ final: json }",
+ "test/with_error.html.erb" => "<%= idontexist %>"
)]
def index
@@ -49,6 +50,10 @@ module RenderTemplate
def with_raw
render :template => "with_raw"
end
+
+ def with_error
+ render :template => "test/with_error"
+ end
end
class TestWithoutLayout < Rack::TestCase
@@ -101,6 +106,12 @@ module RenderTemplate
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
class WithLayoutController < ::ApplicationController
diff --git a/actionpack/test/template/lookup_context_test.rb b/actionpack/test/template/lookup_context_test.rb
index cc71cb42d0..55d581e512 100644
--- a/actionpack/test/template/lookup_context_test.rb
+++ b/actionpack/test/template/lookup_context_test.rb
@@ -163,4 +163,25 @@ class LookupContextTest < ActiveSupport::TestCase
template = @lookup_context.find("foo", "test", true)
assert_equal "Bar", template.source
end
+
+ test "can disable the cache on demand" do
+ @lookup_context.view_paths = ActionView::FixtureResolver.new("test/_foo.erb" => "Foo")
+ old_template = @lookup_context.find("foo", "test", true)
+
+ template = @lookup_context.find("foo", "test", true)
+ assert_equal template, old_template
+
+ assert @lookup_context.cache
+ template = @lookup_context.disable_cache do
+ assert !@lookup_context.cache
+ @lookup_context.find("foo", "test", true)
+ end
+ assert @lookup_context.cache
+
+ assert_not_equal template, old_template
+ end
+
+ test "can have cache disabled on initialization" do
+ assert !ActionView::LookupContext.new(FIXTURE_LOAD_PATH, :cache => false).cache
+ end
end \ No newline at end of file