diff --git a/actionpack/lib/action_controller/base.rb b/actionpack/lib/action_controller/base.rb index fcd3cb9bd32898983e48649024c01792d25f9948..ad2b68af21fa9d486e0d7a7a7dba9a33747d594f 100644 --- a/actionpack/lib/action_controller/base.rb +++ b/actionpack/lib/action_controller/base.rb @@ -2,7 +2,6 @@ module ActionController class Base < Metal abstract! - include AbstractController::Callbacks include AbstractController::Layouts include AbstractController::Translation @@ -23,6 +22,7 @@ class Base < Metal # Rails 2.x compatibility include ActionController::Compatibility + include ActionController::ImplicitRender include ActionController::Cookies include ActionController::Flash @@ -36,8 +36,12 @@ class Base < Metal # Add instrumentations hooks at the bottom, to ensure they instrument # all the methods properly. include ActionController::Instrumentation - include ImplicitRender + # Before callbacks should also be executed the earliest as possible, so + # also include them at the bottom. + include AbstractController::Callbacks + + # The same with rescue, append it at the end to wrap as much as possible. include ActionController::Rescue def self.inherited(klass) diff --git a/actionpack/lib/action_controller/metal/rendering.rb b/actionpack/lib/action_controller/metal/rendering.rb index 2167fe9a323d879db5eda4cff367dac404e8ab44..86bb810947dac9c8624db41f6ab7054ad5b2ca07 100644 --- a/actionpack/lib/action_controller/metal/rendering.rb +++ b/actionpack/lib/action_controller/metal/rendering.rb @@ -6,7 +6,7 @@ module Rendering include AbstractController::Rendering # Before processing, set the request formats in current controller formats. - def process(*) #:nodoc: + def process_action(*) #:nodoc: self.formats = request.formats.map { |x| x.to_sym } super end diff --git a/actionpack/test/controller/render_test.rb b/actionpack/test/controller/render_test.rb index e3c48693916d15129a530a40dacd53de0736eeac..20fcb87da6d45af6862ca06c91230880315d9ac7 100644 --- a/actionpack/test/controller/render_test.rb +++ b/actionpack/test/controller/render_test.rb @@ -617,6 +617,15 @@ def rescue_action(e) raise end + before_filter :only => :render_with_filters do + request.format = :xml + end + + # Ensure that the before filter is executed *before* self.formats is set. + def render_with_filters + render :action => :formatted_xml_erb + end + private def determine_layout @@ -1034,6 +1043,11 @@ def test_render_with_explicit_string_template assert_equal "Hello world!", @response.body end + def test_render_with_filters + get :render_with_filters + assert_equal "passed formatted xml erb", @response.body + end + # :ported: def test_double_render assert_raise(ActionController::DoubleRenderError) { get :double_render }