提交 ebd71fd0 编写于 作者: J José Valim

Fix a regression and also fix broken test.

上级 94dcbe81
...@@ -64,10 +64,15 @@ def find_layout(layout, keys) ...@@ -64,10 +64,15 @@ def find_layout(layout, keys)
def resolve_layout(layout, keys) def resolve_layout(layout, keys)
case layout case layout
when String when String
if layout =~ /^\// begin
with_fallbacks { find_template(layout, nil, false, keys, @details) } if layout =~ /^\//
else with_fallbacks { find_template(layout, nil, false, keys, @details) }
find_template(layout, nil, false, keys, @details) else
find_template(layout, nil, false, keys, @details)
end
rescue ActionView::MissingTemplate
all_details = @details.merge(:formats => @lookup_context.default_formats)
raise unless template_exists?(layout, nil, false, keys, all_details)
end end
when Proc when Proc
resolve_layout(layout.call, keys) resolve_layout(layout.call, keys)
......
...@@ -71,7 +71,8 @@ class MismatchFormatController < ::ApplicationController ...@@ -71,7 +71,8 @@ class MismatchFormatController < ::ApplicationController
self.view_paths = [ActionView::FixtureResolver.new( self.view_paths = [ActionView::FixtureResolver.new(
"layouts/application.html.erb" => "<html><%= yield %></html>", "layouts/application.html.erb" => "<html><%= yield %></html>",
"controller_layouts/mismatch_format/index.xml.builder" => "xml.instruct!", "controller_layouts/mismatch_format/index.xml.builder" => "xml.instruct!",
"controller_layouts/mismatch_format/implicit.builder" => "xml.instruct!" "controller_layouts/mismatch_format/implicit.builder" => "xml.instruct!",
"controller_layouts/mismatch_format/explicit.js.erb" => "alert('foo');"
)] )]
def explicit def explicit
...@@ -94,10 +95,9 @@ class MismatchFormatTest < Rack::TestCase ...@@ -94,10 +95,9 @@ class MismatchFormatTest < Rack::TestCase
assert_response XML_INSTRUCT assert_response XML_INSTRUCT
end end
test "if an HTML template is explicitly provides for a JS template, an error is raised" do test "a layout for JS is ignored even if explicitly provided for HTML" do
assert_raises ActionView::MissingTemplate do get :explicit, { :format => "js" }
get :explicit, {}, "action_dispatch.show_exceptions" => false assert_response "alert('foo');"
end
end end
end end
end end
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册