diff options
35 files changed, 76 insertions, 232 deletions
diff --git a/actionpack/CHANGELOG.md b/actionpack/CHANGELOG.md index cc09bcb771..6bff470003 100644 --- a/actionpack/CHANGELOG.md +++ b/actionpack/CHANGELOG.md @@ -21,6 +21,21 @@ ## Rails 3.2.0 (unreleased) ## +* Add `config.action_dispatch.default_charset` to configure default charset for ActionDispatch::Response. *Carlos Antonio da Silva* + +* Deprecate setting default charset at controller level, use the new `config.action_dispatch.default_charset` instead. *Carlos Antonio da Silva* + +* Deprecate ActionController::UnknownAction in favour of AbstractController::ActionNotFound. *Carlos Antonio da Silva* + +* Deprecate ActionController::DoubleRenderError in favour of AbstractController::DoubleRenderError. *Carlos Antonio da Silva* + +* Deprecate method_missing handling for not found actions, use action_missing instead. *Carlos Antonio da Silva* + +* Deprecate ActionController#performed?, check for response_body presence instead. *Carlos Antonio da Silva* + +* Deprecate ActionController#rescue_action, ActionController#initialize_template_class, and ActionController#assign_shortcuts. + These methods were not being used internally anymore and are going to be removed in Rails 4. *Carlos Antonio da Silva* + * Use a BodyProxy instead of including a Module that responds to close. Closes #4441 if Active Record is disabled assets are delivered correctly *Santiago Pastorino* @@ -45,7 +60,7 @@ <%= f.button %> <% end %> -* Date helpers accept a new option, `:use_two_digit_numbers = true`, that renders select boxes for months and days with a leading zero without changing the respective values. +* Date helpers accept a new option, `:use_two_digit_numbers = true`, that renders select boxes for months and days with a leading zero without changing the respective values. For example, this is useful for displaying ISO8601-style dates such as '2011-08-01'. *Lennart Fridén and Kim Persson* * Make ActiveSupport::Benchmarkable a default module for ActionController::Base, so the #benchmark method is once again available in the controller context like it used to be *DHH* diff --git a/actionpack/lib/action_controller/base.rb b/actionpack/lib/action_controller/base.rb index b6d441d544..3b82231b15 100644 --- a/actionpack/lib/action_controller/base.rb +++ b/actionpack/lib/action_controller/base.rb @@ -116,7 +116,7 @@ module ActionController # # Title: <%= @post.title %> # - # You don't have to rely on the automated rendering. For example, actions that could result in the rendering of different templates + # You don't have to rely on the automated rendering. For example, actions that could result in the rendering of different templates # will use the manual rendering methods: # # def search @@ -133,7 +133,7 @@ module ActionController # == Redirects # # Redirects are used to move from one action to another. For example, after a <tt>create</tt> action, which stores a blog entry to the - # database, we might like to show the user the new entry. Because we're following good DRY principles (Don't Repeat Yourself), we're + # database, we might like to show the user the new entry. Because we're following good DRY principles (Don't Repeat Yourself), we're # going to reuse (and redirect to) a <tt>show</tt> action that we'll assume has already been created. The code might look like this: # # def create @@ -228,8 +228,11 @@ module ActionController include mod end - # Rails 2.x compatibility - include ActionController::Compatibility + # Define some internal variables that should not be propagated to the view. + self.protected_instance_variables = [ + :@_status, :@_headers, :@_params, :@_env, :@_response, :@_request, + :@_view_runtime, :@_stream, :@_url_options, :@_action_has_layout + ] ActiveSupport.run_load_hooks(:action_controller, self) end diff --git a/actionpack/lib/action_controller/metal/compatibility.rb b/actionpack/lib/action_controller/metal/compatibility.rb deleted file mode 100644 index 43719d5808..0000000000 --- a/actionpack/lib/action_controller/metal/compatibility.rb +++ /dev/null @@ -1,58 +0,0 @@ -module ActionController - module Compatibility - extend ActiveSupport::Concern - - class ::ActionController::ActionControllerError < StandardError #:nodoc: - end - - # Temporary hax - included do - ::ActionController::UnknownAction = ::AbstractController::ActionNotFound - ::ActionController::DoubleRenderError = ::AbstractController::DoubleRenderError - - # ROUTES TODO: This should be handled by a middleware and route generation - # should be able to handle SCRIPT_NAME - self.config.relative_url_root = ENV['RAILS_RELATIVE_URL_ROOT'] - - class << self - delegate :default_charset=, :to => "ActionDispatch::Response" - end - - self.protected_instance_variables = [ - :@_status, :@_headers, :@_params, :@_env, :@_response, :@_request, - :@_view_runtime, :@_stream, :@_url_options, :@_action_has_layout - ] - - def rescue_action(env) - raise env["action_dispatch.rescue.exception"] - end - end - - # For old tests - def initialize_template_class(*) end - def assign_shortcuts(*) end - - def _normalize_options(options) - options[:text] = nil if options.delete(:nothing) == true - options[:text] = " " if options.key?(:text) && options[:text].nil? - super - end - - def render_to_body(options) - options[:template].sub!(/^\//, '') if options.key?(:template) - super || " " - end - - def _handle_method_missing - method_missing(@_action_name.to_sym) - end - - def method_for_action(action_name) - super || (respond_to?(:method_missing) && "_handle_method_missing") - end - - def performed? - response_body - end - end -end diff --git a/actionpack/lib/action_controller/metal/exceptions.rb b/actionpack/lib/action_controller/metal/exceptions.rb index 07024d0a9a..ece9ba3725 100644 --- a/actionpack/lib/action_controller/metal/exceptions.rb +++ b/actionpack/lib/action_controller/metal/exceptions.rb @@ -43,4 +43,4 @@ module ActionController class UnknownHttpMethod < ActionControllerError #:nodoc: end -end
\ No newline at end of file +end diff --git a/actionpack/lib/action_controller/metal/rendering.rb b/actionpack/lib/action_controller/metal/rendering.rb index 70fd79bb8b..a677cdf15d 100644 --- a/actionpack/lib/action_controller/metal/rendering.rb +++ b/actionpack/lib/action_controller/metal/rendering.rb @@ -29,6 +29,10 @@ module ActionController self.response_body = nil end + def render_to_body(*) + super || " " + end + private # Normalize arguments by catching blocks and setting them on :update. @@ -44,6 +48,10 @@ module ActionController options[:text] = options[:text].to_text end + if options.delete(:nothing) || (options.key?(:text) && options[:text].nil?) + options[:text] = " " + end + if options[:status] options[:status] = Rack::Utils.status_code(options[:status]) end diff --git a/actionpack/lib/action_controller/metal/streaming.rb b/actionpack/lib/action_controller/metal/streaming.rb index 0e46402962..e9783e6919 100644 --- a/actionpack/lib/action_controller/metal/streaming.rb +++ b/actionpack/lib/action_controller/metal/streaming.rb @@ -216,7 +216,7 @@ module ActionController #:nodoc: end end - # Call render_to_body if we are streaming instead of usual +render+. + # Call render_body if we are streaming instead of usual +render+. def _render_template(options) #:nodoc: if options.delete(:stream) Rack::Chunked::Body.new view_renderer.render_body(view_context, options) diff --git a/actionpack/lib/action_dispatch/railtie.rb b/actionpack/lib/action_dispatch/railtie.rb index 46c06386d8..35f901c575 100644 --- a/actionpack/lib/action_dispatch/railtie.rb +++ b/actionpack/lib/action_dispatch/railtie.rb @@ -11,6 +11,7 @@ module ActionDispatch config.action_dispatch.ignore_accept_header = false config.action_dispatch.rescue_templates = { } config.action_dispatch.rescue_responses = { } + config.action_dispatch.default_charset = nil config.action_dispatch.rack_cache = { :metastore => "rails:/", @@ -21,7 +22,7 @@ module ActionDispatch initializer "action_dispatch.configure" do |app| ActionDispatch::Http::URL.tld_length = app.config.action_dispatch.tld_length ActionDispatch::Request.ignore_accept_header = app.config.action_dispatch.ignore_accept_header - ActionDispatch::Response.default_charset = app.config.encoding + ActionDispatch::Response.default_charset = app.config.action_dispatch.default_charset || app.config.encoding ActionDispatch::ExceptionWrapper.rescue_responses.merge!(config.action_dispatch.rescue_responses) ActionDispatch::ExceptionWrapper.rescue_templates.merge!(config.action_dispatch.rescue_templates) diff --git a/actionpack/lib/action_view/lookup_context.rb b/actionpack/lib/action_view/lookup_context.rb index 90d88ca967..90c4a2759a 100644 --- a/actionpack/lib/action_view/lookup_context.rb +++ b/actionpack/lib/action_view/lookup_context.rb @@ -152,6 +152,7 @@ module ActionView def normalize_name(name, prefixes) #:nodoc: prefixes = nil if prefixes.blank? parts = name.to_s.split('/') + parts.shift if parts.first.empty? name = parts.pop return name, prefixes || [""] if parts.empty? diff --git a/actionpack/lib/action_view/test_case.rb b/actionpack/lib/action_view/test_case.rb index c734c914db..b00f69e636 100644 --- a/actionpack/lib/action_view/test_case.rb +++ b/actionpack/lib/action_view/test_case.rb @@ -233,10 +233,8 @@ module ActionView super end end - end include Behavior - end end diff --git a/actionpack/test/activerecord/active_record_store_test.rb b/actionpack/test/activerecord/active_record_store_test.rb index 768ac713ca..2fe7959f5a 100644 --- a/actionpack/test/activerecord/active_record_store_test.rb +++ b/actionpack/test/activerecord/active_record_store_test.rb @@ -33,8 +33,6 @@ class ActiveRecordStoreTest < ActionDispatch::IntegrationTest session[:foo] = "baz" head :ok end - - def rescue_action(e) raise end end def setup @@ -225,16 +223,16 @@ class ActiveRecordStoreTest < ActionDispatch::IntegrationTest assert_equal session_id, cookies['_session_id'] end end - + def test_incoming_invalid_session_id_via_cookie_should_be_ignored with_test_route_set do open_session do |sess| sess.cookies['_session_id'] = 'INVALID' - + sess.get '/set_session_value' new_session_id = sess.cookies['_session_id'] assert_not_equal 'INVALID', new_session_id - + sess.get '/get_session_value' new_session_id_2 = sess.cookies['_session_id'] assert_equal new_session_id, new_session_id_2 @@ -248,7 +246,7 @@ class ActiveRecordStoreTest < ActionDispatch::IntegrationTest sess.get '/set_session_value', :_session_id => 'INVALID' new_session_id = sess.cookies['_session_id'] assert_not_equal 'INVALID', new_session_id - + sess.get '/get_session_value' new_session_id_2 = sess.cookies['_session_id'] assert_equal new_session_id, new_session_id_2 diff --git a/actionpack/test/controller/assert_select_test.rb b/actionpack/test/controller/assert_select_test.rb index 5eef8a32d7..d3359e79a6 100644 --- a/actionpack/test/controller/assert_select_test.rb +++ b/actionpack/test/controller/assert_select_test.rb @@ -47,10 +47,6 @@ class AssertSelectTest < ActionController::TestCase render :text=>@content, :layout=>false, :content_type=>Mime::XML @content = nil end - - def rescue_action(e) - raise e - end end tests AssertSelectController diff --git a/actionpack/test/controller/base_test.rb b/actionpack/test/controller/base_test.rb index c5c48bc559..b95a524612 100644 --- a/actionpack/test/controller/base_test.rb +++ b/actionpack/test/controller/base_test.rb @@ -40,29 +40,6 @@ class NonEmptyController < ActionController::Base end end -class MethodMissingController < ActionController::Base - hide_action :shouldnt_be_called - def shouldnt_be_called - raise "NO WAY!" - end - -protected - - def method_missing(selector) - render :text => selector.to_s - end -end - -class AnotherMethodMissingController < ActionController::Base - cattr_accessor :_exception - rescue_from Exception, :with => :_exception= - - protected - def method_missing(*attrs, &block) - super - end -end - class DefaultUrlOptionsController < ActionController::Base def from_view render :inline => "<%= #{params[:route]} %>" @@ -159,32 +136,10 @@ class PerformActionTest < ActionController::TestCase assert_equal exception.message, "The action 'non_existent' could not be found for EmptyController" end - def test_get_on_priv_should_show_selector - use_controller MethodMissingController - get :shouldnt_be_called - assert_response :success - assert_equal 'shouldnt_be_called', @response.body - end - - def test_method_missing_is_not_an_action_name - use_controller MethodMissingController - assert !@controller.__send__(:action_method?, 'method_missing') - - get :method_missing - assert_response :success - assert_equal 'method_missing', @response.body - end - - def test_method_missing_should_recieve_symbol - use_controller AnotherMethodMissingController - get :some_action - assert_kind_of NameError, @controller._exception - end - def test_get_on_hidden_should_fail use_controller NonEmptyController - assert_raise(ActionController::UnknownAction) { get :hidden_action } - assert_raise(ActionController::UnknownAction) { get :another_hidden_action } + assert_raise(AbstractController::ActionNotFound) { get :hidden_action } + assert_raise(AbstractController::ActionNotFound) { get :another_hidden_action } end end diff --git a/actionpack/test/controller/caching_test.rb b/actionpack/test/controller/caching_test.rb index 34a38a5567..bb4fb7bf07 100644 --- a/actionpack/test/controller/caching_test.rb +++ b/actionpack/test/controller/caching_test.rb @@ -686,8 +686,6 @@ class FragmentCachingTest < ActionController::TestCase @controller.params = @params @controller.request = @request @controller.response = @response - @controller.send(:initialize_template_class, @response) - @controller.send(:assign_shortcuts, @request, @response) end def test_fragment_cache_key @@ -795,10 +793,6 @@ class FunctionalCachingController < CachingController format.xml end end - - def rescue_action(e) - raise e - end end class FunctionalFragmentCachingTest < ActionController::TestCase diff --git a/actionpack/test/controller/capture_test.rb b/actionpack/test/controller/capture_test.rb index a217510434..72263156d9 100644 --- a/actionpack/test/controller/capture_test.rb +++ b/actionpack/test/controller/capture_test.rb @@ -28,8 +28,6 @@ class CaptureController < ActionController::Base def proper_block_detection @todo = "some todo" end - - def rescue_action(e) raise end end class CaptureTest < ActionController::TestCase diff --git a/actionpack/test/controller/content_type_test.rb b/actionpack/test/controller/content_type_test.rb index a312b7c32a..03d5d27cf4 100644 --- a/actionpack/test/controller/content_type_test.rb +++ b/actionpack/test/controller/content_type_test.rb @@ -48,8 +48,6 @@ class OldContentTypeController < ActionController::Base format.rss { render :text => "hello world!", :content_type => Mime::XML } end end - - def rescue_action(e) raise end end class ContentTypeTest < ActionController::TestCase @@ -70,12 +68,12 @@ class ContentTypeTest < ActionController::TestCase end def test_render_changed_charset_default - OldContentTypeController.default_charset = "utf-16" + ActionDispatch::Response.default_charset = "utf-16" get :render_defaults assert_equal "utf-16", @response.charset assert_equal Mime::HTML, @response.content_type ensure - OldContentTypeController.default_charset = "utf-8" + ActionDispatch::Response.default_charset = "utf-8" end # :ported: @@ -107,12 +105,12 @@ class ContentTypeTest < ActionController::TestCase end def test_nil_default_for_erb - OldContentTypeController.default_charset = nil + ActionDispatch::Response.default_charset = nil get :render_default_for_erb assert_equal Mime::HTML, @response.content_type assert_nil @response.charset, @response.headers.inspect ensure - OldContentTypeController.default_charset = "utf-8" + ActionDispatch::Response.default_charset = "utf-8" end def test_default_for_erb diff --git a/actionpack/test/controller/filters_test.rb b/actionpack/test/controller/filters_test.rb index 9ad0dc75f5..046396b37c 100644 --- a/actionpack/test/controller/filters_test.rb +++ b/actionpack/test/controller/filters_test.rb @@ -165,8 +165,6 @@ class FilterTest < ActionController::TestCase @ran_filter ||= [] @ran_filter << "clean_up_tmp" end - - def rescue_action(e) raise(e) end end class ConditionalCollectionFilterController < ConditionalFilterController @@ -454,11 +452,6 @@ class FilterTest < ActionController::TestCase def show raise ErrorToRescue.new("Something made the bad noise.") end - - private - def rescue_action(exception) - raise exception - end end class NonYieldingAroundFilterController < ActionController::Base @@ -472,9 +465,6 @@ class FilterTest < ActionController::TestCase render :inline => "index" end - #make sure the controller complains - def rescue_action(e); raise e; end - private def filter_one @@ -825,11 +815,7 @@ class FilterTest < ActionController::TestCase end end - - class PostsController < ActionController::Base - def rescue_action(e); raise e; end - module AroundExceptions class Error < StandardError ; end class Before < Error ; end diff --git a/actionpack/test/controller/flash_test.rb b/actionpack/test/controller/flash_test.rb index d497913dc4..37ccc7a4a5 100644 --- a/actionpack/test/controller/flash_test.rb +++ b/actionpack/test/controller/flash_test.rb @@ -51,10 +51,6 @@ class FlashTest < ActionController::TestCase render :inline => "hello" end - def rescue_action(e) - raise unless ActionView::MissingTemplate === e - end - # methods for test_sweep_after_halted_filter_chain before_filter :halt_and_redir, :only => "filter_halting_action" diff --git a/actionpack/test/controller/helper_test.rb b/actionpack/test/controller/helper_test.rb index 35a87c1aae..757661d8d0 100644 --- a/actionpack/test/controller/helper_test.rb +++ b/actionpack/test/controller/helper_test.rb @@ -7,16 +7,12 @@ module Fun def render_hello_world render :inline => "hello: <%= stratego %>" end - - def rescue_action(e) raise end end class PdfController < ActionController::Base def test render :inline => "test: <%= foobar %>" end - - def rescue_action(e) raise end end end @@ -60,7 +56,6 @@ class HelperTest < ActiveSupport::TestCase class TestController < ActionController::Base attr_accessor :delegate_attr def delegate_method() end - def rescue_action(e) raise end end def setup @@ -201,8 +196,6 @@ class IsolatedHelpersTest < ActiveSupport::TestCase def index render :inline => '<%= shout %>' end - - def rescue_action(e) raise end end class B < A diff --git a/actionpack/test/controller/mime_responds_test.rb b/actionpack/test/controller/mime_responds_test.rb index 76a8c89e60..60498822ff 100644 --- a/actionpack/test/controller/mime_responds_test.rb +++ b/actionpack/test/controller/mime_responds_test.rb @@ -151,10 +151,6 @@ class RespondToController < ActionController::Base end end - def rescue_action(e) - raise - end - protected def set_layout if action_name.in?(["all_types_with_layout", "iphone_with_html_response_type"]) @@ -498,7 +494,7 @@ class RespondToControllerTest < 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_invalid_format get :using_defaults, :format => "invalidformat" assert_equal " ", @response.body diff --git a/actionpack/test/controller/redirect_test.rb b/actionpack/test/controller/redirect_test.rb index 5b739e49ac..b1d76150f8 100644 --- a/actionpack/test/controller/redirect_test.rb +++ b/actionpack/test/controller/redirect_test.rb @@ -105,8 +105,6 @@ class RedirectController < ActionController::Base def rescue_errors(e) raise e end - def rescue_action(e) raise end - protected def dashbord_url(id, message) url_for :action => "dashboard", :params => { "id" => id, "message" => message } diff --git a/actionpack/test/controller/render_test.rb b/actionpack/test/controller/render_test.rb index ec26315dc7..8c2d622304 100644 --- a/actionpack/test/controller/render_test.rb +++ b/actionpack/test/controller/render_test.rb @@ -54,7 +54,7 @@ class TestController < ActionController::Base def conditional_hello_with_record record = Struct.new(:updated_at, :cache_key).new(Time.now.utc.beginning_of_day, "foo/123") - + if stale?(record) render :action => 'hello_world' end @@ -649,10 +649,6 @@ class TestController < ActionController::Base render :action => "calling_partial_with_layout", :layout => "layouts/partial_with_layout" end - def rescue_action(e) - raise - end - before_filter :only => :render_with_filters do request.format = :xml end @@ -891,12 +887,12 @@ class RenderTest < ActionController::TestCase # :ported: def test_attempt_to_access_object_method - assert_raise(ActionController::UnknownAction, "No action responded to [clone]") { get :clone } + assert_raise(AbstractController::ActionNotFound, "No action responded to [clone]") { get :clone } end # :ported: def test_private_methods - assert_raise(ActionController::UnknownAction, "No action responded to [determine_layout]") { get :determine_layout } + assert_raise(AbstractController::ActionNotFound, "No action responded to [determine_layout]") { get :determine_layout } end # :ported: @@ -1096,15 +1092,15 @@ class RenderTest < ActionController::TestCase # :ported: def test_double_render - assert_raise(ActionController::DoubleRenderError) { get :double_render } + assert_raise(AbstractController::DoubleRenderError) { get :double_render } end def test_double_redirect - assert_raise(ActionController::DoubleRenderError) { get :double_redirect } + assert_raise(AbstractController::DoubleRenderError) { get :double_redirect } end def test_render_and_redirect - assert_raise(ActionController::DoubleRenderError) { get :render_and_redirect } + assert_raise(AbstractController::DoubleRenderError) { get :render_and_redirect } end # specify the one exception to double render rule - render_to_string followed by render diff --git a/actionpack/test/controller/request_forgery_protection_test.rb b/actionpack/test/controller/request_forgery_protection_test.rb index fd5a41a0bb..4a291582d8 100644 --- a/actionpack/test/controller/request_forgery_protection_test.rb +++ b/actionpack/test/controller/request_forgery_protection_test.rb @@ -36,8 +36,6 @@ module RequestForgeryProtectionActions def form_for_without_protection render :inline => "<%= form_for(:some_resource, :authenticity_token => false ) {} %>" end - - def rescue_action(e) raise e end end # sample controllers diff --git a/actionpack/test/controller/resources_test.rb b/actionpack/test/controller/resources_test.rb index 6b8a8f6161..73d72fe4d6 100644 --- a/actionpack/test/controller/resources_test.rb +++ b/actionpack/test/controller/resources_test.rb @@ -6,7 +6,6 @@ require 'active_support/core_ext/object/inclusion' class ResourcesController < ActionController::Base def index() render :nothing => true end alias_method :show, :index - def rescue_action(e) raise e end end class ThreadsController < ResourcesController; end diff --git a/actionpack/test/controller/routing_test.rb b/actionpack/test/controller/routing_test.rb index bf33b8cdd7..bec9eb16f3 100644 --- a/actionpack/test/controller/routing_test.rb +++ b/actionpack/test/controller/routing_test.rb @@ -6,7 +6,6 @@ require 'active_support/core_ext/object/with_options' class MilestonesController < ActionController::Base def index() head :ok end alias_method :show, :index - def rescue_action(e) raise e end end ROUTING = ActionDispatch::Routing diff --git a/actionpack/test/controller/test_case_test.rb b/actionpack/test/controller/test_case_test.rb index 34b06df8d8..caf76c7e61 100644 --- a/actionpack/test/controller/test_case_test.rb +++ b/actionpack/test/controller/test_case_test.rb @@ -2,7 +2,7 @@ require 'abstract_unit' require 'controller/fake_controllers' require 'active_support/ordered_hash' -class TestTest < ActionController::TestCase +class TestCaseTest < ActionController::TestCase class TestController < ActionController::Base def no_op render :text => 'dummy' @@ -124,9 +124,6 @@ XML end private - def rescue_action(e) - raise e - end def generate_url(opts) url_for(opts.merge(:action => "test_uri")) @@ -174,7 +171,7 @@ XML def test_document_body_and_params_with_post post :test_params, :id => 1 - assert_equal("{\"id\"=>\"1\", \"controller\"=>\"test_test/test\", \"action\"=>\"test_params\"}", @response.body) + assert_equal("{\"id\"=>\"1\", \"controller\"=>\"test_case_test/test\", \"action\"=>\"test_params\"}", @response.body) end def test_document_body_with_post @@ -247,18 +244,18 @@ XML def test_process_with_request_uri_with_no_params process :test_uri - assert_equal "/test_test/test/test_uri", @response.body + assert_equal "/test_case_test/test/test_uri", @response.body end def test_process_with_request_uri_with_params process :test_uri, "GET", :id => 7 - assert_equal "/test_test/test/test_uri/7", @response.body + assert_equal "/test_case_test/test/test_uri/7", @response.body end def test_process_with_old_api assert_deprecated do process :test_uri, :id => 7 - assert_equal "/test_test/test/test_uri/7", @response.body + assert_equal "/test_case_test/test/test_uri/7", @response.body end end @@ -542,7 +539,7 @@ XML get :test_params, :page => {:name => "Page name", :month => '4', :year => '2004', :day => '6'} parsed_params = eval(@response.body) assert_equal( - {'controller' => 'test_test/test', 'action' => 'test_params', + {'controller' => 'test_case_test/test', 'action' => 'test_params', 'page' => {'name' => "Page name", 'month' => '4', 'year' => '2004', 'day' => '6'}}, parsed_params ) @@ -552,7 +549,7 @@ XML get :test_params, :page => {:name => "Page name", :month => 4, :year => 2004, :day => 6} parsed_params = eval(@response.body) assert_equal( - {'controller' => 'test_test/test', 'action' => 'test_params', + {'controller' => 'test_case_test/test', 'action' => 'test_params', 'page' => {'name' => "Page name", 'month' => '4', 'year' => '2004', 'day' => '6'}}, parsed_params ) @@ -564,7 +561,7 @@ XML end parsed_params = eval(@response.body) assert_equal( - {'controller' => 'test_test/test', 'action' => 'test_params', + {'controller' => 'test_case_test/test', 'action' => 'test_params', 'frozen' => 'icy', 'frozens' => ['icy']}, parsed_params ) @@ -584,7 +581,7 @@ XML def test_array_path_parameter_handled_properly with_routing do |set| set.draw do - match 'file/*path', :to => 'test_test/test#test_params' + match 'file/*path', :to => 'test_case_test/test#test_params' match ':controller/:action' end @@ -719,7 +716,7 @@ XML end def test_fixture_path_is_accessed_from_self_instead_of_active_support_test_case - TestTest.stubs(:fixture_path).returns(FILES_DIR) + TestCaseTest.stubs(:fixture_path).returns(FILES_DIR) uploaded_file = fixture_file_upload('/mona_lisa.jpg', 'image/png') assert_equal File.open("#{FILES_DIR}/mona_lisa.jpg", READ_PLAIN).read, uploaded_file.read diff --git a/actionpack/test/controller/view_paths_test.rb b/actionpack/test/controller/view_paths_test.rb index 872f171c42..40f6dc6f0f 100644 --- a/actionpack/test/controller/view_paths_test.rb +++ b/actionpack/test/controller/view_paths_test.rb @@ -3,7 +3,6 @@ require 'abstract_unit' class ViewLoadPathsTest < ActionController::TestCase class TestController < ActionController::Base def self.controller_path() "test" end - def rescue_action(e) raise end before_filter :add_view_path, :only => :hello_world_at_request_time @@ -24,16 +23,9 @@ class ViewLoadPathsTest < ActionController::TestCase end def setup - # TestController.view_paths = nil - @request = ActionController::TestRequest.new @response = ActionController::TestResponse.new - @controller = TestController.new - # Following is needed in order to setup @controller.template object properly - @controller.send :assign_shortcuts, @request, @response - @controller.send :initialize_template_class, @response - @paths = TestController.view_paths end diff --git a/actionpack/test/controller/webservice_test.rb b/actionpack/test/controller/webservice_test.rb index ae8588cbb0..351e61eeae 100644 --- a/actionpack/test/controller/webservice_test.rb +++ b/actionpack/test/controller/webservice_test.rb @@ -18,8 +18,6 @@ class WebServiceTest < ActionDispatch::IntegrationTest s << "#{k}#{value}" end end - - def rescue_action(e) raise end end def setup diff --git a/actionpack/test/dispatch/debug_exceptions_test.rb b/actionpack/test/dispatch/debug_exceptions_test.rb index f3dc160d7d..c3a565990e 100644 --- a/actionpack/test/dispatch/debug_exceptions_test.rb +++ b/actionpack/test/dispatch/debug_exceptions_test.rb @@ -24,7 +24,7 @@ class DebugExceptionsTest < ActionDispatch::IntegrationTest when "/pass" [404, { "X-Cascade" => "pass" }, self] when "/not_found" - raise ActionController::UnknownAction + raise AbstractController::ActionNotFound when "/runtime_error" raise RuntimeError when "/method_not_allowed" @@ -83,7 +83,7 @@ class DebugExceptionsTest < ActionDispatch::IntegrationTest get "/not_found", {}, {'action_dispatch.show_exceptions' => true} assert_response 404 - assert_match(/#{ActionController::UnknownAction.name}/, body) + assert_match(/#{AbstractController::ActionNotFound.name}/, body) get "/method_not_allowed", {}, {'action_dispatch.show_exceptions' => true} assert_response 405 diff --git a/actionpack/test/dispatch/session/cache_store_test.rb b/actionpack/test/dispatch/session/cache_store_test.rb index 73e056de23..12405bf45d 100644 --- a/actionpack/test/dispatch/session/cache_store_test.rb +++ b/actionpack/test/dispatch/session/cache_store_test.rb @@ -30,8 +30,6 @@ class CacheStoreTest < ActionDispatch::IntegrationTest session[:bar] = "baz" head :ok end - - def rescue_action(e) raise end end def test_setting_and_getting_session_value diff --git a/actionpack/test/dispatch/session/cookie_store_test.rb b/actionpack/test/dispatch/session/cookie_store_test.rb index 92df6967d6..19969394cd 100644 --- a/actionpack/test/dispatch/session/cookie_store_test.rb +++ b/actionpack/test/dispatch/session/cookie_store_test.rb @@ -54,8 +54,6 @@ class CookieStoreTest < ActionDispatch::IntegrationTest request.session_options[:renew] = true head :ok end - - def rescue_action(e) raise end end def test_setting_session_value diff --git a/actionpack/test/dispatch/session/mem_cache_store_test.rb b/actionpack/test/dispatch/session/mem_cache_store_test.rb index 8502bc547b..5277c92b55 100644 --- a/actionpack/test/dispatch/session/mem_cache_store_test.rb +++ b/actionpack/test/dispatch/session/mem_cache_store_test.rb @@ -31,8 +31,6 @@ class MemCacheStoreTest < ActionDispatch::IntegrationTest session[:bar] = "baz" head :ok end - - def rescue_action(e) raise end end begin diff --git a/actionpack/test/dispatch/show_exceptions_test.rb b/actionpack/test/dispatch/show_exceptions_test.rb index e9504f3524..4a6d5ddbf7 100644 --- a/actionpack/test/dispatch/show_exceptions_test.rb +++ b/actionpack/test/dispatch/show_exceptions_test.rb @@ -7,7 +7,7 @@ class ShowExceptionsTest < ActionDispatch::IntegrationTest req = ActionDispatch::Request.new(env) case req.path when "/not_found" - raise ActionController::UnknownAction + raise AbstractController::ActionNotFound when "/method_not_allowed" raise ActionController::MethodNotAllowed when "/not_found_original_exception" diff --git a/actionpack/test/template/atom_feed_helper_test.rb b/actionpack/test/template/atom_feed_helper_test.rb index 81d7444cf8..d26aa9aa85 100644 --- a/actionpack/test/template/atom_feed_helper_test.rb +++ b/actionpack/test/template/atom_feed_helper_test.rb @@ -16,7 +16,7 @@ class ScrollsController < ActionController::Base feed.title("My great blog!") feed.updated((@scrolls.first.created_at)) - @scrolls.each do |scroll| + @scrolls.each do |scroll| feed.entry(scroll) do |entry| entry.title(scroll.title) entry.content(scroll.body, :type => 'html') @@ -185,11 +185,6 @@ class ScrollsController < ActionController::Base render :inline => FEEDS[params[:id]], :type => :builder end - - protected - def rescue_action(e) - raise(e) - end end class AtomFeedTest < ActionController::TestCase diff --git a/actionpack/test/template/url_helper_test.rb b/actionpack/test/template/url_helper_test.rb index bc45fabf34..d013a44e6c 100644 --- a/actionpack/test/template/url_helper_test.rb +++ b/actionpack/test/template/url_helper_test.rb @@ -91,7 +91,7 @@ class UrlHelperTest < ActiveSupport::TestCase def test_button_to_with_remote_and_form_options assert_dom_equal "<form method=\"post\" action=\"http://www.example.com\" class=\"custom-class\" data-remote=\"true\" data-type=\"json\"><div><input type=\"submit\" value=\"Hello\" /></div></form>", button_to("Hello", "http://www.example.com", :remote => true, :form => { :class => "custom-class", "data-type" => "json" } ) end - + def test_button_to_with_remote_and_javascript_confirm assert_dom_equal( "<form method=\"post\" action=\"http://www.example.com\" class=\"button_to\" data-remote=\"true\"><div><input data-confirm=\"Are you sure?\" type=\"submit\" value=\"Hello\" /></div></form>", @@ -506,8 +506,6 @@ class UrlHelperControllerTest < ActionController::TestCase render :inline => '<%= url_for(:action => :show_url_for) %>' end - def rescue_action(e) raise e end - def override_url_helper render :inline => '<%= override_url_helper_path %>' end @@ -595,8 +593,6 @@ class TasksController < ActionController::Base render_default end - def rescue_action(e) raise e end - protected def render_default render :inline => @@ -655,8 +651,6 @@ class WorkshopsController < ActionController::Base @workshop = Workshop.new(params[:id]) render :inline => "<%= url_for(@workshop) %>\n<%= link_to('Workshop', @workshop) %>" end - - def rescue_action(e) raise e end end class SessionsController < ActionController::Base @@ -677,8 +671,6 @@ class SessionsController < ActionController::Base @session = Session.new(params[:id]) render :inline => "<%= url_for([@workshop, @session]) %>\n<%= link_to('Session', [@workshop, @session]) %>" end - - def rescue_action(e) raise e end end class PolymorphicControllerTest < ActionController::TestCase diff --git a/railties/test/application/configuration_test.rb b/railties/test/application/configuration_test.rb index 397f4da8fc..cadf60d46f 100644 --- a/railties/test/application/configuration_test.rb +++ b/railties/test/application/configuration_test.rb @@ -287,6 +287,14 @@ module ApplicationTests assert_equal Rails.application, ActionDispatch.test_app end + test "sets ActionDispatch::Response.default_charset" do + make_basic_app do |app| + app.config.action_dispatch.default_charset = "utf-16" + end + + assert_equal "utf-16", ActionDispatch::Response.default_charset + end + test "sets all Active Record models to whitelist all attributes by default" do add_to_config <<-RUBY config.active_record.whitelist_attributes = true |