aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2007-09-30 22:59:24 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2007-09-30 22:59:24 +0000
commit860cf2d44e01114af8ce83fffee3689df812a55c (patch)
tree35e3291052fb24eb13e3ca712ee0cebac6a9b6df /actionpack
parent6ca789bf005caadd4200b6bf788521dfe1d40287 (diff)
downloadrails-860cf2d44e01114af8ce83fffee3689df812a55c.tar.gz
rails-860cf2d44e01114af8ce83fffee3689df812a55c.tar.bz2
rails-860cf2d44e01114af8ce83fffee3689df812a55c.zip
Fixed that render template did not honor exempt_from_layout (closes #9698) [pezra]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7701 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack')
-rw-r--r--actionpack/CHANGELOG2
-rw-r--r--actionpack/lib/action_controller/layout.rb6
-rw-r--r--actionpack/test/controller/layout_test.rb18
-rw-r--r--actionpack/test/fixtures/layout_tests/alt/hello.rhtml1
4 files changed, 24 insertions, 3 deletions
diff --git a/actionpack/CHANGELOG b/actionpack/CHANGELOG
index 71dfdd8b3f..6816d18261 100644
--- a/actionpack/CHANGELOG
+++ b/actionpack/CHANGELOG
@@ -1,5 +1,7 @@
*2.0.0 [Preview Release]* (September 29th, 2007) [Includes duplicates of changes from 1.12.2 - 1.13.3]
+* Fixed that render template did not honor exempt_from_layout #9698 [pezra]
+
* Better error messages if you leave out the :secret option for request forgery protection. Closes #9670 [rick]
* Allow ability to disable request forgery protection, disable it in test mode by default. Closes #9693 [lifofifo]
diff --git a/actionpack/lib/action_controller/layout.rb b/actionpack/lib/action_controller/layout.rb
index c41e14736c..27ff16c835 100644
--- a/actionpack/lib/action_controller/layout.rb
+++ b/actionpack/lib/action_controller/layout.rb
@@ -277,8 +277,8 @@ module ActionController #:nodoc:
def candidate_for_layout?(options)
(options.has_key?(:layout) && options[:layout] != false) ||
- options.values_at(:text, :xml, :json, :file, :inline, :partial, :nothing).compact.empty? &&
- !template_exempt_from_layout?(default_template_name(options[:action] || options[:template]))
+ options.values_at(:text, :xml, :json, :file, :inline, :partial, :nothing).compact.empty? &&
+ !template_exempt_from_layout?(options[:template] || default_template_name(options[:action]))
end
def pick_layout(template_with_options, options)
@@ -320,4 +320,4 @@ module ActionController #:nodoc:
end
end
end
-end \ No newline at end of file
+end
diff --git a/actionpack/test/controller/layout_test.rb b/actionpack/test/controller/layout_test.rb
index cad5720742..f194539fcf 100644
--- a/actionpack/test/controller/layout_test.rb
+++ b/actionpack/test/controller/layout_test.rb
@@ -180,8 +180,26 @@ class LayoutSetInResponseTest < Test::Unit::TestCase
get :hello
assert_nil @response.layout
end
+
+ def test_exempt_from_layout_honored_by_render_template
+ ActionController::Base.exempt_from_layout :rhtml
+ @controller = RenderWithTemplateOptionController.new
+
+ assert @controller.send(:template_exempt_from_layout?, 'alt/hello.rhtml')
+
+ get :hello
+ assert_equal "alt/hello.rhtml", @response.body.strip
+
+ ensure
+ ActionController::Base.exempt_from_layout.delete(/\.rhtml$/)
+ end
end
+class RenderWithTemplateOptionController < LayoutTest
+ def hello
+ render :template => 'alt/hello'
+ end
+end
class SetsNonExistentLayoutFile < LayoutTest
layout "nofile.rhtml"
diff --git a/actionpack/test/fixtures/layout_tests/alt/hello.rhtml b/actionpack/test/fixtures/layout_tests/alt/hello.rhtml
new file mode 100644
index 0000000000..fcda6cf97a
--- /dev/null
+++ b/actionpack/test/fixtures/layout_tests/alt/hello.rhtml
@@ -0,0 +1 @@
+alt/hello.rhtml