Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge [5909], [5927] from trunk. References #6742, #7026.

git-svn-id: http://svn-commit.rubyonrails.org/rails/branches/1-2-pre-release@5928 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
commit 2b6954aa8a7175c4f2ea36c9df8586301c4051a6 1 parent 68849e3
@jeremy jeremy authored
View
2  actionpack/CHANGELOG
@@ -1,5 +1,7 @@
*SVN*
+* Allow exempt_from_layout :rhtml. #6742, #7026 [dcmanges, Squeegy]
+
* Fix parsing of array[] CGI parameters so extra empty values aren't included. #6252 [Nicholas Seckar, aiwilliams, brentrowland]
* link_to_unless_current works with full URLs as well as paths. #6891 [Jarkko Laine, manfred, idrifter]
View
18 actionpack/lib/action_controller/base.rb
@@ -407,10 +407,13 @@ def filter_parameter_logging(*filter_words, &block)
# Don't render layouts for templates with the given extensions.
def exempt_from_layout(*extensions)
- regexps = extensions.collect do |extension|
- extension.is_a?(Regexp) ? extension : /\.#{Regexp.escape(extension.to_s)}$/
- end
- @@exempt_from_layout.merge regexps
+ @@exempt_from_layout.merge extensions.collect { |extension|
+ if extension.is_a?(Regexp)
+ extension
+ else
+ /\.#{Regexp.escape(extension.to_s)}$/
+ end
+ }
end
end
@@ -1190,10 +1193,9 @@ def template_public?(template_name = default_template_name)
end
def template_exempt_from_layout?(template_name = default_template_name)
- @@exempt_from_layout.any? { |ext| template_name =~ ext } or
- @template.pick_template_extension(template_name) == :rjs
- rescue
- false
+ extension = @template.pick_template_extension(template_name) rescue nil
+ name_with_extension = !template_name.include?('.') && extension ? "#{template_name}.#{extension}" : template_name
+ extension == :rjs || @@exempt_from_layout.any? { |ext| name_with_extension =~ ext }
end
def assert_existence_of_template_file(template_name)
View
11 actionpack/test/controller/layout_test.rb
@@ -75,6 +75,8 @@ def test_namespaced_controllers_auto_detect_layouts
class ExemptFromLayoutTest < Test::Unit::TestCase
def setup
@controller = LayoutTest.new
+ @request = ActionController::TestRequest.new
+ @response = ActionController::TestResponse.new
end
def test_rjs_exempt_from_layout
@@ -103,6 +105,15 @@ def test_add_regexp_to_exempt_from_layout
ActionController::Base.exempt_from_layout /\.rdoc/
assert @controller.send(:template_exempt_from_layout?, 'test.rdoc')
end
+
+ def test_rhtml_exempt_from_layout_status_should_prevent_layout_render
+ ActionController::Base.exempt_from_layout :rhtml
+ assert @controller.send(:template_exempt_from_layout?, 'test.rhtml')
+
+ get :hello
+ assert_equal 'hello.rhtml', @response.body
+ ActionController::Base.exempt_from_layout.delete(/\.rhtml$/)
+ end
end
Please sign in to comment.
Something went wrong with that request. Please try again.