diff options
Diffstat (limited to 'actionpack/lib/action_controller')
-rw-r--r-- | actionpack/lib/action_controller/base/base.rb | 20 | ||||
-rw-r--r-- | actionpack/lib/action_controller/base/render.rb | 7 | ||||
-rw-r--r-- | actionpack/lib/action_controller/testing/assertions/response.rb | 10 |
3 files changed, 24 insertions, 13 deletions
diff --git a/actionpack/lib/action_controller/base/base.rb b/actionpack/lib/action_controller/base/base.rb index 1d0738588d..2063df54b4 100644 --- a/actionpack/lib/action_controller/base/base.rb +++ b/actionpack/lib/action_controller/base/base.rb @@ -494,8 +494,18 @@ module ActionController #:nodoc: end protected :filter_parameters end + + @@exempt_from_layout = [ActionView::TemplateHandlers::RJS] + + def exempt_from_layout(*types) + types.each do |type| + @@exempt_from_layout << + ActionView::Template.handler_class_for_extension(type) + end + + @@exempt_from_layout + end - delegate :exempt_from_layout, :to => 'ActionView::Template' end public @@ -856,13 +866,13 @@ module ActionController #:nodoc: return (performed? ? ret : default_render) if called begin - default_render - rescue ActionView::MissingTemplate => e - raise e unless e.action_name == action_name - # If the path is the same as the action_name, the action is completely missing + view_paths.find_by_parts(action_name, {:formats => formats, :locales => [I18n.locale]}, controller_path) + rescue => e raise UnknownAction, "No action responded to #{action_name}. Actions: " + "#{action_methods.sort.to_sentence}", caller end + + default_render end # Returns true if a render or redirect has already been performed. diff --git a/actionpack/lib/action_controller/base/render.rb b/actionpack/lib/action_controller/base/render.rb index 601c5429c3..4286577ec5 100644 --- a/actionpack/lib/action_controller/base/render.rb +++ b/actionpack/lib/action_controller/base/render.rb @@ -378,13 +378,14 @@ module ActionController # ==== Arguments # parts<Array[String, Array[Symbol*], String, Boolean]>:: # Example: ["show", [:html, :xml], "users", false] - def render_for_parts(parts, layout, options = {}) + def render_for_parts(parts, layout_details, options = {}) parts[1] = {:formats => parts[1], :locales => [I18n.locale]} tmp = view_paths.find_by_parts(*parts) - layout = _pick_layout(*layout) unless tmp.exempt_from_layout? - + layout = _pick_layout(*layout_details) unless + self.class.exempt_from_layout.include?(tmp.handler) + render_for_text( @template._render_template_with_layout(tmp, layout, options, parts[3])) end diff --git a/actionpack/lib/action_controller/testing/assertions/response.rb b/actionpack/lib/action_controller/testing/assertions/response.rb index c57cbecc44..574b8d6825 100644 --- a/actionpack/lib/action_controller/testing/assertions/response.rb +++ b/actionpack/lib/action_controller/testing/assertions/response.rb @@ -98,22 +98,22 @@ module ActionController clean_backtrace do case options when NilClass, String - rendered = @controller.response.rendered[:template].to_s + rendered = (@controller.response.rendered[:template] || []).map { |t| t.identifier } msg = build_message(message, "expecting <?> but rendering with <?>", - options, rendered) + options, rendered.join(', ')) assert_block(msg) do if options.nil? @controller.response.rendered[:template].blank? else - rendered.to_s.match(options) + rendered.any? { |t| t.match(options) } end end when Hash if expected_partial = options[:partial] partials = @controller.response.rendered[:partials] if expected_count = options[:count] - found = partials.detect { |p, _| p.to_s.match(expected_partial) } + found = partials.detect { |p, _| p.identifier.match(expected_partial) } actual_count = found.nil? ? 0 : found.second msg = build_message(message, "expecting ? to be rendered ? time(s) but rendered ? time(s)", @@ -123,7 +123,7 @@ module ActionController msg = build_message(message, "expecting partial <?> but action rendered <?>", options[:partial], partials.keys) - assert(partials.keys.any? { |p| p.to_s.match(expected_partial) }, msg) + assert(partials.keys.any? { |p| p.identifier.match(expected_partial) }, msg) end else assert @controller.response.rendered[:partials].empty?, |