1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

An exception is raised if a layout is missing only if the layout is missing for all mimes

This commit is contained in:
Yehuda Katz + Carl Lerche 2009-06-16 13:44:51 -07:00
parent 01a4bc84b8
commit dd58f4021d
4 changed files with 5 additions and 11 deletions

View file

@ -140,6 +140,8 @@ module AbstractController
rescue NameError => e
raise NoMethodError,
"You specified #{@_layout.inspect} as the layout, but no such method was found"
rescue ActionView::MissingTemplate
_find_by_parts(_layout({}), {})
end
end

View file

@ -176,7 +176,7 @@ module ActionController
super
return if (options.key?(:text) || options.key?(:inline) || options.key?(:partial)) && !options.key?(:layout)
layout = options.key?(:layout) ? options[:layout] : :none
layout = options.key?(:layout) ? options[:layout] : :default
options[:_layout] = _layout_for_option(layout, options[:_template].details)
end
@ -184,7 +184,7 @@ module ActionController
case name
when String then _layout_for_name(name, details)
when true then _default_layout(details, true)
when :none then _default_layout(details, false)
when :default then _default_layout(details, false)
when false, nil then nil
else
raise ArgumentError,

View file

@ -124,8 +124,8 @@ module ActionController #:nodoc:
@controller.formats = [mime_type.to_sym]
end
@controller.content_type = mime_type
@controller.template.formats = [mime_type.to_sym]
@response.content_type = mime_type
block_given? ? block.call : @controller.send(:render, :action => @controller.action_name)
end

View file

@ -467,14 +467,6 @@ class MimeControllerTest < ActionController::TestCase
assert_equal '<html><div id="iphone">Hello iPhone future from iPhone!</div></html>', @response.body
assert_equal "text/html", @response.content_type
end
def test_format_with_custom_response_type_and_request_headers_with_only_one_layout_present
get :iphone_with_html_response_type_without_layout
assert_equal '<html><div id="html_missing">Hello future from Firefox!</div></html>', @response.body
@request.accept = "text/iphone"
assert_raise(ActionView::MissingTemplate) { get :iphone_with_html_response_type_without_layout }
end
end
class AbstractPostController < ActionController::Base