mirror of
https://github.com/github/rails.git
synced 2026-04-26 03:00:59 -04:00
Fix a regression and also fix broken test.
This commit is contained in:
@@ -64,10 +64,15 @@ module ActionView
|
||||
def resolve_layout(layout, keys)
|
||||
case layout
|
||||
when String
|
||||
if layout =~ /^\//
|
||||
with_fallbacks { find_template(layout, nil, false, keys, @details) }
|
||||
else
|
||||
find_template(layout, nil, false, keys, @details)
|
||||
begin
|
||||
if layout =~ /^\//
|
||||
with_fallbacks { 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
|
||||
when Proc
|
||||
resolve_layout(layout.call, keys)
|
||||
|
||||
@@ -71,7 +71,8 @@ module ControllerLayouts
|
||||
self.view_paths = [ActionView::FixtureResolver.new(
|
||||
"layouts/application.html.erb" => "<html><%= yield %></html>",
|
||||
"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
|
||||
@@ -94,10 +95,9 @@ module ControllerLayouts
|
||||
assert_response XML_INSTRUCT
|
||||
end
|
||||
|
||||
test "if an HTML template is explicitly provides for a JS template, an error is raised" do
|
||||
assert_raises ActionView::MissingTemplate do
|
||||
get :explicit, {}, "action_dispatch.show_exceptions" => false
|
||||
end
|
||||
test "a layout for JS is ignored even if explicitly provided for HTML" do
|
||||
get :explicit, { :format => "js" }
|
||||
assert_response "alert('foo');"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user