aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_controller
diff options
context:
space:
mode:
authorJosé Valim <jose.valim@gmail.com>2009-08-07 16:10:17 +0200
committerJosé Valim <jose.valim@gmail.com>2009-08-07 16:10:17 +0200
commitdac8927b0576bff89ba3a4fcbf502dffc9b39e89 (patch)
tree58c25132a52ef5cc56f406f8e2df416c5f2776a6 /actionpack/lib/action_controller
parent072c87b532a0bfb334787928248863a2561dc849 (diff)
parent606e950ccbd02a10f724c73543575a2a4e1ed8cb (diff)
downloadrails-dac8927b0576bff89ba3a4fcbf502dffc9b39e89.tar.gz
rails-dac8927b0576bff89ba3a4fcbf502dffc9b39e89.tar.bz2
rails-dac8927b0576bff89ba3a4fcbf502dffc9b39e89.zip
Merge branch 'master' of git://github.com/rails/rails into old
Diffstat (limited to 'actionpack/lib/action_controller')
-rw-r--r--actionpack/lib/action_controller/abstract.rb16
-rw-r--r--actionpack/lib/action_controller/abstract/base.rb159
-rw-r--r--actionpack/lib/action_controller/abstract/benchmarker.rb38
-rw-r--r--actionpack/lib/action_controller/abstract/callbacks.rb115
-rw-r--r--actionpack/lib/action_controller/abstract/exceptions.rb12
-rw-r--r--actionpack/lib/action_controller/abstract/helpers.rb82
-rw-r--r--actionpack/lib/action_controller/abstract/layouts.rb164
-rw-r--r--actionpack/lib/action_controller/abstract/logger.rb52
-rw-r--r--actionpack/lib/action_controller/abstract/renderer.rb156
-rw-r--r--actionpack/lib/action_controller/base.rb (renamed from actionpack/lib/action_controller/base/base.rb)2
-rw-r--r--actionpack/lib/action_controller/caching/actions.rb3
-rw-r--r--actionpack/lib/action_controller/metal.rb (renamed from actionpack/lib/action_controller/base/http.rb)12
-rw-r--r--actionpack/lib/action_controller/metal/compatibility.rb (renamed from actionpack/lib/action_controller/base/compatibility.rb)4
-rw-r--r--actionpack/lib/action_controller/metal/conditional_get.rb (renamed from actionpack/lib/action_controller/base/conditional_get.rb)23
-rw-r--r--actionpack/lib/action_controller/metal/cookies.rb (renamed from actionpack/lib/action_controller/base/cookies.rb)0
-rw-r--r--actionpack/lib/action_controller/metal/exceptions.rb (renamed from actionpack/lib/action_controller/base/exceptions.rb)0
-rw-r--r--actionpack/lib/action_controller/metal/filter_parameter_logging.rb (renamed from actionpack/lib/action_controller/base/filter_parameter_logging.rb)0
-rw-r--r--actionpack/lib/action_controller/metal/flash.rb (renamed from actionpack/lib/action_controller/base/flash.rb)0
-rw-r--r--actionpack/lib/action_controller/metal/helpers.rb (renamed from actionpack/lib/action_controller/base/helpers.rb)0
-rw-r--r--actionpack/lib/action_controller/metal/hide_actions.rb (renamed from actionpack/lib/action_controller/base/hide_actions.rb)0
-rw-r--r--actionpack/lib/action_controller/metal/http_authentication.rb (renamed from actionpack/lib/action_controller/base/http_authentication.rb)0
-rw-r--r--actionpack/lib/action_controller/metal/layouts.rb (renamed from actionpack/lib/action_controller/base/layouts.rb)0
-rw-r--r--actionpack/lib/action_controller/metal/mime_responds.rb (renamed from actionpack/lib/action_controller/base/mime_responds.rb)0
-rw-r--r--actionpack/lib/action_controller/metal/rack_convenience.rb (renamed from actionpack/lib/action_controller/base/rack_convenience.rb)2
-rw-r--r--actionpack/lib/action_controller/metal/redirector.rb (renamed from actionpack/lib/action_controller/base/redirector.rb)0
-rw-r--r--actionpack/lib/action_controller/metal/render_options.rb (renamed from actionpack/lib/action_controller/base/render_options.rb)14
-rw-r--r--actionpack/lib/action_controller/metal/renderer.rb (renamed from actionpack/lib/action_controller/base/renderer.rb)2
-rw-r--r--actionpack/lib/action_controller/metal/request_forgery_protection.rb (renamed from actionpack/lib/action_controller/base/request_forgery_protection.rb)0
-rw-r--r--actionpack/lib/action_controller/metal/rescuable.rb (renamed from actionpack/lib/action_controller/base/rescuable.rb)0
-rw-r--r--actionpack/lib/action_controller/metal/session.rb (renamed from actionpack/lib/action_controller/base/session.rb)0
-rw-r--r--actionpack/lib/action_controller/metal/session_management.rb (renamed from actionpack/lib/action_controller/base/session_management.rb)0
-rw-r--r--actionpack/lib/action_controller/metal/streaming.rb (renamed from actionpack/lib/action_controller/base/streaming.rb)6
-rw-r--r--actionpack/lib/action_controller/metal/testing.rb (renamed from actionpack/lib/action_controller/base/testing.rb)0
-rw-r--r--actionpack/lib/action_controller/metal/url_for.rb (renamed from actionpack/lib/action_controller/base/url_for.rb)0
-rw-r--r--actionpack/lib/action_controller/metal/verification.rb (renamed from actionpack/lib/action_controller/base/verification.rb)0
-rw-r--r--actionpack/lib/action_controller/old_base.rb84
-rw-r--r--actionpack/lib/action_controller/record_identifier.rb15
-rw-r--r--actionpack/lib/action_controller/testing/process.rb2
38 files changed, 27 insertions, 936 deletions
diff --git a/actionpack/lib/action_controller/abstract.rb b/actionpack/lib/action_controller/abstract.rb
deleted file mode 100644
index d0eba253b8..0000000000
--- a/actionpack/lib/action_controller/abstract.rb
+++ /dev/null
@@ -1,16 +0,0 @@
-require "active_support/core_ext/module/attr_internal"
-require "active_support/core_ext/module/delegation"
-
-module AbstractController
- autoload :Base, "action_controller/abstract/base"
- autoload :Benchmarker, "action_controller/abstract/benchmarker"
- autoload :Callbacks, "action_controller/abstract/callbacks"
- autoload :Helpers, "action_controller/abstract/helpers"
- autoload :Layouts, "action_controller/abstract/layouts"
- autoload :Logger, "action_controller/abstract/logger"
- autoload :Renderer, "action_controller/abstract/renderer"
- # === Exceptions
- autoload :ActionNotFound, "action_controller/abstract/exceptions"
- autoload :DoubleRenderError, "action_controller/abstract/exceptions"
- autoload :Error, "action_controller/abstract/exceptions"
-end
diff --git a/actionpack/lib/action_controller/abstract/base.rb b/actionpack/lib/action_controller/abstract/base.rb
deleted file mode 100644
index ca00e66349..0000000000
--- a/actionpack/lib/action_controller/abstract/base.rb
+++ /dev/null
@@ -1,159 +0,0 @@
-module AbstractController
-
- class Base
- attr_internal :response_body
- attr_internal :action_name
-
- class << self
- attr_reader :abstract
- alias_method :abstract?, :abstract
-
- # Define a controller as abstract. See internal_methods for more
- # details.
- def abstract!
- @abstract = true
- end
-
- def inherited(klass)
- ::AbstractController::Base.descendants << klass.to_s
- super
- end
-
- # A list of all descendents of AbstractController::Base. This is
- # useful for initializers which need to add behavior to all controllers.
- def descendants
- @descendants ||= []
- end
-
- # A list of all internal methods for a controller. This finds the first
- # abstract superclass of a controller, and gets a list of all public
- # instance methods on that abstract class. Public instance methods of
- # a controller would normally be considered action methods, so we
- # are removing those methods on classes declared as abstract
- # (ActionController::Http and ActionController::Base are defined
- # as abstract)
- def internal_methods
- controller = self
- controller = controller.superclass until controller.abstract?
- controller.public_instance_methods(true)
- end
-
- # The list of hidden actions to an empty Array. Defaults to an
- # empty Array. This can be modified by other modules or subclasses
- # to specify particular actions as hidden.
- #
- # ==== Returns
- # Array[String]:: An array of method names that should not be
- # considered actions.
- def hidden_actions
- []
- end
-
- # A list of method names that should be considered actions. This
- # includes all public instance methods on a controller, less
- # any internal methods (see #internal_methods), adding back in
- # any methods that are internal, but still exist on the class
- # itself. Finally, #hidden_actions are removed.
- #
- # ==== Returns
- # Array[String]:: A list of all methods that should be considered
- # actions.
- def action_methods
- @action_methods ||=
- # All public instance methods of this class, including ancestors
- public_instance_methods(true).map { |m| m.to_s }.to_set -
- # Except for public instance methods of Base and its ancestors
- internal_methods.map { |m| m.to_s } +
- # Be sure to include shadowed public instance methods of this class
- public_instance_methods(false).map { |m| m.to_s } -
- # And always exclude explicitly hidden actions
- hidden_actions
- end
- end
-
- abstract!
-
- # Calls the action going through the entire action dispatch stack.
- #
- # The actual method that is called is determined by calling
- # #method_for_action. If no method can handle the action, then an
- # ActionNotFound error is raised.
- #
- # ==== Returns
- # self
- def process(action)
- @_action_name = action_name = action.to_s
-
- unless action_name = method_for_action(action_name)
- raise ActionNotFound, "The action '#{action}' could not be found"
- end
-
- process_action(action_name)
- self
- end
-
- private
- # Returns true if the name can be considered an action. This can
- # be overridden in subclasses to modify the semantics of what
- # can be considered an action.
- #
- # ==== Parameters
- # name<String>:: The name of an action to be tested
- #
- # ==== Returns
- # TrueClass, FalseClass
- def action_method?(name)
- self.class.action_methods.include?(name)
- end
-
- # Call the action. Override this in a subclass to modify the
- # behavior around processing an action. This, and not #process,
- # is the intended way to override action dispatching.
- def process_action(method_name)
- send_action(method_name)
- end
-
- # Actually call the method associated with the action. Override
- # this method if you wish to change how action methods are called,
- # not to add additional behavior around it. For example, you would
- # override #send_action if you want to inject arguments into the
- # method.
- alias send_action send
-
- # If the action name was not found, but a method called "action_missing"
- # was found, #method_for_action will return "_handle_action_missing".
- # This method calls #action_missing with the current action name.
- def _handle_action_missing
- action_missing(@_action_name)
- end
-
- # Takes an action name and returns the name of the method that will
- # handle the action. In normal cases, this method returns the same
- # name as it receives. By default, if #method_for_action receives
- # a name that is not an action, it will look for an #action_missing
- # method and return "_handle_action_missing" if one is found.
- #
- # Subclasses may override this method to add additional conditions
- # that should be considered an action. For instance, an HTTP controller
- # with a template matching the action name is considered to exist.
- #
- # If you override this method to handle additional cases, you may
- # also provide a method (like _handle_method_missing) to handle
- # the case.
- #
- # If none of these conditions are true, and method_for_action
- # returns nil, an ActionNotFound exception will be raised.
- #
- # ==== Parameters
- # action_name<String>:: An action name to find a method name for
- #
- # ==== Returns
- # String:: The name of the method that handles the action
- # nil:: No method name could be found. Raise ActionNotFound.
- def method_for_action(action_name)
- if action_method?(action_name) then action_name
- elsif respond_to?(:action_missing, true) then "_handle_action_missing"
- end
- end
- end
-end
diff --git a/actionpack/lib/action_controller/abstract/benchmarker.rb b/actionpack/lib/action_controller/abstract/benchmarker.rb
deleted file mode 100644
index 58e9564c2f..0000000000
--- a/actionpack/lib/action_controller/abstract/benchmarker.rb
+++ /dev/null
@@ -1,38 +0,0 @@
-module AbstractController
- module Benchmarker
- extend ActiveSupport::Concern
-
- include Logger
-
- module ClassMethods
- # Execute the passed in block, timing the duration of the block in ms.
- #
- # ==== Parameters
- # title<#to_s>:: The title of block to benchmark
- # log_level<Integer>:: A valid log level. Defaults to Logger::DEBUG
- # use_silence<TrueClass, FalseClass>:: Whether or not to silence the
- # logger for the duration of the block.
- #
- # ==== Returns
- # Object:: The result of the block
- def benchmark(title, log_level = ::Logger::DEBUG, use_silence = true)
- if logger && logger.level >= log_level
- result = nil
- ms = Benchmark.ms { result = use_silence ? silence { yield } : yield }
- logger.add(log_level, "#{title} (#{('%.1f' % ms)}ms)")
- result
- else
- yield
- end
- end
-
- # Silences the logger for the duration of the block.
- def silence
- old_logger_level, logger.level = logger.level, ::Logger::ERROR if logger
- yield
- ensure
- logger.level = old_logger_level if logger
- end
- end
- end
-end
diff --git a/actionpack/lib/action_controller/abstract/callbacks.rb b/actionpack/lib/action_controller/abstract/callbacks.rb
deleted file mode 100644
index ea4b59466e..0000000000
--- a/actionpack/lib/action_controller/abstract/callbacks.rb
+++ /dev/null
@@ -1,115 +0,0 @@
-require "active_support/new_callbacks"
-
-module AbstractController
- module Callbacks
- extend ActiveSupport::Concern
-
- # Uses ActiveSupport::NewCallbacks as the base functionality. For
- # more details on the whole callback system, read the documentation
- # for ActiveSupport::NewCallbacks.
- include ActiveSupport::NewCallbacks
-
- included do
- define_callbacks :process_action, "response_body"
- end
-
- # Override AbstractController::Base's process_action to run the
- # process_action callbacks around the normal behavior.
- def process_action(method_name)
- _run_process_action_callbacks(method_name) do
- super
- end
- end
-
- module ClassMethods
- # If :only or :accept are used, convert the options into the
- # primitive form (:per_key) used by ActiveSupport::Callbacks.
- # The basic idea is that :only => :index gets converted to
- # :if => proc {|c| c.action_name == "index" }, but that the
- # proc is only evaluated once per action for the lifetime of
- # a Rails process.
- #
- # ==== Options
- # :only<#to_s>:: The callback should be run only for this action
- # :except<#to_s>:: The callback should be run for all actions
- # except this action
- def _normalize_callback_options(options)
- if only = options[:only]
- only = Array(only).map {|o| "action_name == '#{o}'"}.join(" || ")
- options[:per_key] = {:if => only}
- end
- if except = options[:except]
- except = Array(except).map {|e| "action_name == '#{e}'"}.join(" || ")
- options[:per_key] = {:unless => except}
- end
- end
-
- # Skip before, after, and around filters matching any of the names
- #
- # ==== Parameters
- # *names<Object>:: A list of valid names that could be used for
- # callbacks. Note that skipping uses Ruby equality, so it's
- # impossible to skip a callback defined using an anonymous proc
- # using #skip_filter
- def skip_filter(*names, &blk)
- skip_before_filter(*names)
- skip_after_filter(*names)
- skip_around_filter(*names)
- end
-
- # Take callback names and an optional callback proc, normalize them,
- # then call the block with each callback. This allows us to abstract
- # the normalization across several methods that use it.
- #
- # ==== Parameters
- # callbacks<Array[*Object, Hash]>:: A list of callbacks, with an optional
- # options hash as the last parameter.
- # block<Proc>:: A proc that should be added to the callbacks.
- #
- # ==== Block Parameters
- # name<Symbol>:: The callback to be added
- # options<Hash>:: A list of options to be used when adding the callback
- def _insert_callbacks(callbacks, block)
- options = callbacks.last.is_a?(Hash) ? callbacks.pop : {}
- _normalize_callback_options(options)
- callbacks.push(block) if block
- callbacks.each do |callback|
- yield callback, options
- end
- end
-
- # set up before_filter, prepend_before_filter, skip_before_filter, etc.
- # for each of before, after, and around.
- [:before, :after, :around].each do |filter|
- class_eval <<-RUBY_EVAL, __FILE__, __LINE__ + 1
- # Append a before, after or around filter. See _insert_callbacks
- # for details on the allowed parameters.
- def #{filter}_filter(*names, &blk)
- _insert_callbacks(names, blk) do |name, options|
- set_callback(:process_action, :#{filter}, name, options)
- end
- end
-
- # Prepend a before, after or around filter. See _insert_callbacks
- # for details on the allowed parameters.
- def prepend_#{filter}_filter(*names, &blk)
- _insert_callbacks(names, blk) do |name, options|
- set_callback(:process_action, :#{filter}, name, options.merge(:prepend => true))
- end
- end
-
- # Skip a before, after or around filter. See _insert_callbacks
- # for details on the allowed parameters.
- def skip_#{filter}_filter(*names, &blk)
- _insert_callbacks(names, blk) do |name, options|
- skip_callback(:process_action, :#{filter}, name, options)
- end
- end
-
- # *_filter is the same as append_*_filter
- alias_method :append_#{filter}_filter, :#{filter}_filter
- RUBY_EVAL
- end
- end
- end
-end
diff --git a/actionpack/lib/action_controller/abstract/exceptions.rb b/actionpack/lib/action_controller/abstract/exceptions.rb
deleted file mode 100644
index b671516de1..0000000000
--- a/actionpack/lib/action_controller/abstract/exceptions.rb
+++ /dev/null
@@ -1,12 +0,0 @@
-module AbstractController
- class Error < StandardError; end
- class ActionNotFound < StandardError; end
-
- class DoubleRenderError < Error
- DEFAULT_MESSAGE = "Render and/or redirect were called multiple times in this action. Please note that you may only call render OR redirect, and at most once per action. Also note that neither redirect nor render terminate execution of the action, so if you want to exit an action after redirecting, you need to do something like \"redirect_to(...) and return\"."
-
- def initialize(message = nil)
- super(message || DEFAULT_MESSAGE)
- end
- end
-end
diff --git a/actionpack/lib/action_controller/abstract/helpers.rb b/actionpack/lib/action_controller/abstract/helpers.rb
deleted file mode 100644
index 5efa37fde3..0000000000
--- a/actionpack/lib/action_controller/abstract/helpers.rb
+++ /dev/null
@@ -1,82 +0,0 @@
-module AbstractController
- module Helpers
- extend ActiveSupport::Concern
-
- include Renderer
-
- included do
- extlib_inheritable_accessor(:_helpers) { Module.new }
- end
-
- module ClassMethods
- # When a class is inherited, wrap its helper module in a new module.
- # This ensures that the parent class's module can be changed
- # independently of the child class's.
- def inherited(klass)
- helpers = _helpers
- klass._helpers = Module.new { include helpers }
-
- super
- end
-
- # Declare a controller method as a helper. For example, the following
- # makes the +current_user+ controller method available to the view:
- # class ApplicationController < ActionController::Base
- # helper_method :current_user, :logged_in?
- #
- # def current_user
- # @current_user ||= User.find_by_id(session[:user])
- # end
- #
- # def logged_in?
- # current_user != nil
- # end
- # end
- #
- # In a view:
- # <% if logged_in? -%>Welcome, <%= current_user.name %><% end -%>
- #
- # ==== Parameters
- # meths<Array[#to_s]>:: The name of a method on the controller
- # to be made available on the view.
- def helper_method(*meths)
- meths.flatten.each do |meth|
- _helpers.class_eval <<-ruby_eval, __FILE__, __LINE__ + 1
- def #{meth}(*args, &blk)
- controller.send(%(#{meth}), *args, &blk)
- end
- ruby_eval
- end
- end
-
- # Make a number of helper modules part of this class' default
- # helpers.
- #
- # ==== Parameters
- # *args<Array[Module]>:: Modules to be included
- # block<Block>:: Evalulate the block in the context
- # of the helper module. Any methods defined in the block
- # will be helpers.
- def helper(*args, &block)
- args.flatten.each do |arg|
- case arg
- when Module
- add_template_helper(arg)
- end
- end
- _helpers.module_eval(&block) if block_given?
- end
-
- private
- # Makes all the (instance) methods in the helper module available to templates
- # rendered through this controller.
- #
- # ==== Parameters
- # mod<Module>:: The module to include into the current helper module
- # for the class
- def add_template_helper(mod)
- _helpers.module_eval { include mod }
- end
- end
- end
-end
diff --git a/actionpack/lib/action_controller/abstract/layouts.rb b/actionpack/lib/action_controller/abstract/layouts.rb
deleted file mode 100644
index f021dd8b62..0000000000
--- a/actionpack/lib/action_controller/abstract/layouts.rb
+++ /dev/null
@@ -1,164 +0,0 @@
-module AbstractController
- module Layouts
- extend ActiveSupport::Concern
-
- include Renderer
-
- included do
- extlib_inheritable_accessor(:_layout_conditions) { Hash.new }
- _write_layout_method
- end
-
- module ClassMethods
- def inherited(klass)
- super
- klass._write_layout_method
- end
-
- # Specify the layout to use for this class.
- #
- # If the specified layout is a:
- # String:: the String is the template name
- # Symbol:: call the method specified by the symbol, which will return
- # the template name
- # false:: There is no layout
- # true:: raise an ArgumentError
- #
- # ==== Parameters
- # layout<String, Symbol, false)>:: The layout to use.
- #
- # ==== Options (conditions)
- # :only<#to_s, Array[#to_s]>:: A list of actions to apply this layout to.
- # :except<#to_s, Array[#to_s]>:: Apply this layout to all actions but this one
- def layout(layout, conditions = {})
- conditions.each {|k, v| conditions[k] = Array(v).map {|a| a.to_s} }
- self._layout_conditions = conditions
-
- @_layout = layout || false # Converts nil to false
- _write_layout_method
- end
-
- # If no layout is supplied, look for a template named the return
- # value of this method.
- #
- # ==== Returns
- # String:: A template name
- def _implied_layout_name
- name.underscore
- end
-
- # Takes the specified layout and creates a _layout method to be called
- # by _default_layout
- #
- # If there is no explicit layout specified:
- # If a layout is found in the view paths with the controller's
- # name, return that string. Otherwise, use the superclass'
- # layout (which might also be implied)
- def _write_layout_method
- case @_layout
- when String
- self.class_eval %{def _layout(details) #{@_layout.inspect} end}
- when Symbol
- self.class_eval <<-ruby_eval, __FILE__, __LINE__ + 1
- def _layout(details)
- #{@_layout}.tap do |layout|
- unless layout.is_a?(String) || !layout
- raise ArgumentError, "Your layout method :#{@_layout} returned \#{layout}. It " \
- "should have returned a String, false, or nil"
- end
- end
- end
- ruby_eval
- when false
- self.class_eval %{def _layout(details) end}
- when true
- raise ArgumentError, "Layouts must be specified as a String, Symbol, false, or nil"
- when nil
- self.class_eval <<-ruby_eval, __FILE__, __LINE__ + 1
- def _layout(details)
- if view_paths.find_by_parts?("#{_implied_layout_name}", details, "layouts")
- "#{_implied_layout_name}"
- else
- super
- end
- end
- ruby_eval
- end
- self.class_eval { private :_layout }
- end
- end
-
- private
- # This will be overwritten by _write_layout_method
- def _layout(details) end
-
- # Determine the layout for a given name and details.
- #
- # ==== Parameters
- # name<String>:: The name of the template
- # details<Hash{Symbol => Object}>:: A list of details to restrict
- # the lookup to. By default, layout lookup is limited to the
- # formats specified for the current request.
- def _layout_for_name(name, details = {:formats => formats})
- name && _find_layout(name, details)
- end
-
- # Take in the name and details and find a Template.
- #
- # ==== Parameters
- # name<String>:: The name of the template to retrieve
- # details<Hash>:: A list of details to restrict the search by. This
- # might include details like the format or locale of the template.
- #
- # ==== Returns
- # Template:: A template object matching the name and details
- def _find_layout(name, details)
- # TODO: Make prefix actually part of details in ViewPath#find_by_parts
- prefix = details.key?(:prefix) ? details.delete(:prefix) : "layouts"
- view_paths.find_by_parts(name, details, prefix)
- end
-
- # Returns the default layout for this controller and a given set of details.
- # Optionally raises an exception if the layout could not be found.
- #
- # ==== Parameters
- # details<Hash>:: A list of details to restrict the search by. This
- # might include details like the format or locale of the template.
- # require_layout<Boolean>:: If this is true, raise an ArgumentError
- # with details about the fact that the exception could not be
- # found (defaults to false)
- #
- # ==== Returns
- # Template:: The template object for the default layout (or nil)
- def _default_layout(details, require_layout = false)
- if require_layout && _action_has_layout? && !_layout(details)
- raise ArgumentError,
- "There was no default layout for #{self.class} in #{view_paths.inspect}"
- end
-
- begin
- _layout_for_name(_layout(details), details) if _action_has_layout?
- rescue NameError => e
- raise NoMethodError,
- "You specified #{@_layout.inspect} as the layout, but no such method was found"
- end
- end
-
- # Determines whether the current action has a layout by checking the
- # action name against the :only and :except conditions set on the
- # layout.
- #
- # ==== Returns
- # Boolean:: True if the action has a layout, false otherwise.
- def _action_has_layout?
- conditions = _layout_conditions
- if only = conditions[:only]
- only.include?(action_name)
- elsif except = conditions[:except]
- !except.include?(action_name)
- else
- true
- end
- end
- end
-end
diff --git a/actionpack/lib/action_controller/abstract/logger.rb b/actionpack/lib/action_controller/abstract/logger.rb
deleted file mode 100644
index fd33bd2ddd..0000000000
--- a/actionpack/lib/action_controller/abstract/logger.rb
+++ /dev/null
@@ -1,52 +0,0 @@
-require 'active_support/core_ext/logger'
-
-module AbstractController
- module Logger
- extend ActiveSupport::Concern
-
- # A class that allows you to defer expensive processing
- # until the logger actually tries to log. Otherwise, you are
- # forced to do the processing in advance, and send the
- # entire processed String to the logger, which might
- # just discard the String if the log level is too low.
- #
- # TODO: Require that Rails loggers accept a block.
- class DelayedLog
- def initialize(&blk)
- @blk = blk
- end
-
- def to_s
- @blk.call
- end
- alias to_str to_s
- end
-
- included do
- cattr_accessor :logger
- end
-
- # Override process_action in the AbstractController::Base
- # to log details about the method.
- def process_action(action)
- super
-
- if logger
- log = DelayedLog.new do
- "\n\nProcessing #{self.class.name}\##{action_name} " \
- "to #{request.formats} " \
- "(for #{request_origin}) [#{request.method.to_s.upcase}]"
- end
-
- logger.info(log)
- end
- end
-
- private
- def request_origin
- # this *needs* to be cached!
- # otherwise you'd get different results if calling it more than once
- @request_origin ||= "#{request.remote_ip} at #{Time.now.to_s(:db)}"
- end
- end
-end
diff --git a/actionpack/lib/action_controller/abstract/renderer.rb b/actionpack/lib/action_controller/abstract/renderer.rb
deleted file mode 100644
index 41b7d47458..0000000000
--- a/actionpack/lib/action_controller/abstract/renderer.rb
+++ /dev/null
@@ -1,156 +0,0 @@
-require "action_controller/abstract/logger"
-
-module AbstractController
- module Renderer
- extend ActiveSupport::Concern
-
- include AbstractController::Logger
-
- included do
- attr_internal :formats
-
- extlib_inheritable_accessor :_view_paths
-
- self._view_paths ||= ActionView::PathSet.new
- end
-
- # An instance of a view class. The default view class is ActionView::Base
- #
- # The view class must have the following methods:
- # View.for_controller[controller] Create a new ActionView instance for a
- # controller
- # View#_render_partial_from_controller[options]
- # - responsible for setting options[:_template]
- # - Returns String with the rendered partial
- # options<Hash>:: see _render_partial in ActionView::Base
- # View#_render_template_from_controller[template, layout, options, partial]
- # - Returns String with the rendered template
- # template<ActionView::Template>:: The template to render
- # layout<ActionView::Template>:: The layout to render around the template
- # options<Hash>:: See _render_template_with_layout in ActionView::Base
- # partial<Boolean>:: Whether or not the template to render is a partial
- #
- # Override this method in a to change the default behavior.
- def _action_view
- @_action_view ||= ActionView::Base.for_controller(self)
- end
-
- # Mostly abstracts the fact that calling render twice is a DoubleRenderError.
- # Delegates render_to_body and sticks the result in self.response_body.
- def render(*args)
- if response_body
- raise AbstractController::DoubleRenderError, "OMG"
- end
-
- self.response_body = render_to_body(*args)
- end
-
- # Raw rendering of a template to a Rack-compatible body.
- #
- # ==== Options
- # _partial_object<Object>:: The object that is being rendered. If this
- # exists, we are in the special case of rendering an object as a partial.
- #
- # :api: plugin
- def render_to_body(options = {})
- # TODO: Refactor so we can just use the normal template logic for this
- if options[:_partial_object]
- _action_view._render_partial_from_controller(options)
- else
- _determine_template(options)
- _render_template(options)
- end
- end
-
- # Raw rendering of a template to a string. Just convert the results of
- # render_to_body into a String.
- #
- # :api: plugin
- def render_to_string(options = {})
- AbstractController::Renderer.body_to_s(render_to_body(options))
- end
-
- # Renders the template from an object.
- #
- # ==== Options
- # _template<ActionView::Template>:: The template to render
- # _layout<ActionView::Template>:: The layout to wrap the template in (optional)
- # _partial<TrueClass, FalseClass>:: Whether or not the template to be rendered is a partial
- def _render_template(options)
- _action_view._render_template_from_controller(options[:_template], options[:_layout], options, options[:_partial])
- end
-
- # The list of view paths for this controller. See ActionView::ViewPathSet for
- # more details about writing custom view paths.
- def view_paths
- _view_paths
- end
-
- # Return a string representation of a Rack-compatible response body.
- def self.body_to_s(body)
- if body.respond_to?(:to_str)
- body
- else
- strings = []
- body.each { |part| strings << part.to_s }
- body.close if body.respond_to?(:close)
- strings.join
- end
- end
-
- private
- # Take in a set of options and determine the template to render
- #
- # ==== Options
- # _template<ActionView::Template>:: If this is provided, the search is over
- # _template_name<#to_s>:: The name of the template to look up. Otherwise,
- # use the current action name.
- # _prefix<String>:: The prefix to look inside of. In a file system, this corresponds
- # to a directory.
- # _partial<TrueClass, FalseClass>:: Whether or not the file to look up is a partial
- def _determine_template(options)
- name = (options[:_template_name] || action_name).to_s
-
- options[:_template] ||= view_paths.find_by_parts(
- name, { :formats => formats }, options[:_prefix], options[:_partial]
- )
- end
-
- module ClassMethods
- # Append a path to the list of view paths for this controller.
- #
- # ==== Parameters
- # path<String, ViewPath>:: If a String is provided, it gets converted into
- # the default view path. You may also provide a custom view path
- # (see ActionView::ViewPathSet for more information)
- def append_view_path(path)
- self.view_paths << path
- end
-
- # Prepend a path to the list of view paths for this controller.
- #
- # ==== Parameters
- # path<String, ViewPath>:: If a String is provided, it gets converted into
- # the default view path. You may also provide a custom view path
- # (see ActionView::ViewPathSet for more information)
- def prepend_view_path(path)
- self.view_paths.unshift(path)
- end
-
- # A list of all of the default view paths for this controller.
- def view_paths
- self._view_paths
- end
-
- # Set the view paths.
- #
- # ==== Parameters
- # paths<ViewPathSet, Object>:: If a ViewPathSet is provided, use that;
- # otherwise, process the parameter into a ViewPathSet.
- def view_paths=(paths)
- self._view_paths = paths.is_a?(ActionView::PathSet) ?
- paths : ActionView::Base.process_view_paths(paths)
- end
- end
- end
-end
diff --git a/actionpack/lib/action_controller/base/base.rb b/actionpack/lib/action_controller/base.rb
index e541d24e31..9d9f735e27 100644
--- a/actionpack/lib/action_controller/base/base.rb
+++ b/actionpack/lib/action_controller/base.rb
@@ -1,5 +1,5 @@
module ActionController
- class Base < Http
+ class Base < Metal
abstract!
include AbstractController::Benchmarker
diff --git a/actionpack/lib/action_controller/caching/actions.rb b/actionpack/lib/action_controller/caching/actions.rb
index d8a1662acc..cb0c3a1384 100644
--- a/actionpack/lib/action_controller/caching/actions.rb
+++ b/actionpack/lib/action_controller/caching/actions.rb
@@ -129,8 +129,7 @@ module ActionController #:nodoc:
end
def content_for_layout(controller)
- # TODO: Remove this when new base is merged in
- template = controller.respond_to?(:template) ? controller.template : controller._action_view
+ template = controller.view_context
template.layout && template.instance_variable_get('@cached_content_for_layout')
end
end
diff --git a/actionpack/lib/action_controller/base/http.rb b/actionpack/lib/action_controller/metal.rb
index 3efd1b656f..5333ca497c 100644
--- a/actionpack/lib/action_controller/base/http.rb
+++ b/actionpack/lib/action_controller/metal.rb
@@ -1,13 +1,11 @@
-require 'action_controller/abstract'
-
module ActionController
- # ActionController::Http provides a way to get a valid Rack application from a controller.
+ # ActionController::Metal provides a way to get a valid Rack application from a controller.
#
# In AbstractController, dispatching is triggered directly by calling #process on a new controller.
- # ActionController::Http provides an #action method that returns a valid Rack application for a
+ # ActionController::Metal provides an #action method that returns a valid Rack application for a
# given action. Other rack builders, such as Rack::Builder, Rack::URLMap, and the Rails router,
# can dispatch directly to the action returned by FooController.action(:index).
- class Http < AbstractController::Base
+ class Metal < AbstractController::Base
abstract!
# :api: public
@@ -72,11 +70,11 @@ module ActionController
def call(name, env)
@_env = env
process(name)
- to_rack
+ to_a
end
# :api: private
- def to_rack
+ def to_a
[status, headers, response_body]
end
diff --git a/actionpack/lib/action_controller/base/compatibility.rb b/actionpack/lib/action_controller/metal/compatibility.rb
index 13813ffd17..23e7b1b3af 100644
--- a/actionpack/lib/action_controller/base/compatibility.rb
+++ b/actionpack/lib/action_controller/metal/compatibility.rb
@@ -72,7 +72,7 @@ module ActionController
# TODO: Remove this after we flip
def template
- @template ||= _action_view
+ @template ||= view_context
end
def process_action(*)
@@ -141,7 +141,7 @@ module ActionController
end
def view_paths
- _action_view.view_paths
+ view_context.view_paths
end
end
end
diff --git a/actionpack/lib/action_controller/base/conditional_get.rb b/actionpack/lib/action_controller/metal/conditional_get.rb
index d287ec4994..6d35137428 100644
--- a/actionpack/lib/action_controller/base/conditional_get.rb
+++ b/actionpack/lib/action_controller/metal/conditional_get.rb
@@ -29,11 +29,7 @@ module ActionController
response.last_modified = options[:last_modified] if options[:last_modified]
if options[:public]
- cache_control = response.headers["Cache-Control"].split(",").map {|k| k.strip }
- cache_control.delete("private")
- cache_control.delete("no-cache")
- cache_control << "public"
- response.headers["Cache-Control"] = cache_control.join(', ')
+ response.cache_control[:public] = true
end
if request.fresh?(response)
@@ -107,21 +103,10 @@ module ActionController
# This method will overwrite an existing Cache-Control header.
# See http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html for more possibilities.
def expires_in(seconds, options = {}) #:doc:
- cache_control = response.headers["Cache-Control"].split(",").map {|k| k.strip }
+ response.cache_control.merge!(:max_age => seconds, :public => options.delete(:public))
+ options.delete(:private)
- cache_control << "max-age=#{seconds}"
- cache_control.delete("no-cache")
- if options[:public]
- cache_control.delete("private")
- cache_control << "public"
- else
- cache_control << "private"
- end
-
- # This allows for additional headers to be passed through like 'max-stale' => 5.hours
- cache_control += options.symbolize_keys.reject{|k,v| k == :public || k == :private }.map{ |k,v| v == true ? k.to_s : "#{k.to_s}=#{v.to_s}"}
-
- response.headers["Cache-Control"] = cache_control.join(', ')
+ response.cache_control[:extras] = options.map {|k,v| "#{k}=#{v}"}
end
# Sets a HTTP 1.1 Cache-Control header of "no-cache" so no caching should occur by the browser or
diff --git a/actionpack/lib/action_controller/base/cookies.rb b/actionpack/lib/action_controller/metal/cookies.rb
index d4806623c3..d4806623c3 100644
--- a/actionpack/lib/action_controller/base/cookies.rb
+++ b/actionpack/lib/action_controller/metal/cookies.rb
diff --git a/actionpack/lib/action_controller/base/exceptions.rb b/actionpack/lib/action_controller/metal/exceptions.rb
index d0811254cb..d0811254cb 100644
--- a/actionpack/lib/action_controller/base/exceptions.rb
+++ b/actionpack/lib/action_controller/metal/exceptions.rb
diff --git a/actionpack/lib/action_controller/base/filter_parameter_logging.rb b/actionpack/lib/action_controller/metal/filter_parameter_logging.rb
index 065e62a37f..065e62a37f 100644
--- a/actionpack/lib/action_controller/base/filter_parameter_logging.rb
+++ b/actionpack/lib/action_controller/metal/filter_parameter_logging.rb
diff --git a/actionpack/lib/action_controller/base/flash.rb b/actionpack/lib/action_controller/metal/flash.rb
index 590f9be3ac..590f9be3ac 100644
--- a/actionpack/lib/action_controller/base/flash.rb
+++ b/actionpack/lib/action_controller/metal/flash.rb
diff --git a/actionpack/lib/action_controller/base/helpers.rb b/actionpack/lib/action_controller/metal/helpers.rb
index 7c52779064..7c52779064 100644
--- a/actionpack/lib/action_controller/base/helpers.rb
+++ b/actionpack/lib/action_controller/metal/helpers.rb
diff --git a/actionpack/lib/action_controller/base/hide_actions.rb b/actionpack/lib/action_controller/metal/hide_actions.rb
index af68c772b1..af68c772b1 100644
--- a/actionpack/lib/action_controller/base/hide_actions.rb
+++ b/actionpack/lib/action_controller/metal/hide_actions.rb
diff --git a/actionpack/lib/action_controller/base/http_authentication.rb b/actionpack/lib/action_controller/metal/http_authentication.rb
index 525787bf92..525787bf92 100644
--- a/actionpack/lib/action_controller/base/http_authentication.rb
+++ b/actionpack/lib/action_controller/metal/http_authentication.rb
diff --git a/actionpack/lib/action_controller/base/layouts.rb b/actionpack/lib/action_controller/metal/layouts.rb
index 365351b421..365351b421 100644
--- a/actionpack/lib/action_controller/base/layouts.rb
+++ b/actionpack/lib/action_controller/metal/layouts.rb
diff --git a/actionpack/lib/action_controller/base/mime_responds.rb b/actionpack/lib/action_controller/metal/mime_responds.rb
index 9a6c8aa58b..9a6c8aa58b 100644
--- a/actionpack/lib/action_controller/base/mime_responds.rb
+++ b/actionpack/lib/action_controller/metal/mime_responds.rb
diff --git a/actionpack/lib/action_controller/base/rack_convenience.rb b/actionpack/lib/action_controller/metal/rack_convenience.rb
index 805157b0e3..5fac445dab 100644
--- a/actionpack/lib/action_controller/base/rack_convenience.rb
+++ b/actionpack/lib/action_controller/metal/rack_convenience.rb
@@ -20,7 +20,7 @@ module ActionController
end
# :api: private
- def to_rack
+ def to_a
@_response.prepare!
@_response.to_a
end
diff --git a/actionpack/lib/action_controller/base/redirector.rb b/actionpack/lib/action_controller/metal/redirector.rb
index 20060b001f..20060b001f 100644
--- a/actionpack/lib/action_controller/base/redirector.rb
+++ b/actionpack/lib/action_controller/metal/redirector.rb
diff --git a/actionpack/lib/action_controller/base/render_options.rb b/actionpack/lib/action_controller/metal/render_options.rb
index fc9a02626f..c6a965472f 100644
--- a/actionpack/lib/action_controller/base/render_options.rb
+++ b/actionpack/lib/action_controller/metal/render_options.rb
@@ -13,7 +13,7 @@ module ActionController
<<-RUBY_EVAL
if options.key?(:#{r})
_process_options(options)
- return _render_#{r}(options[:#{r}], options)
+ return render_#{r}(options[:#{r}], options)
end
RUBY_EVAL
end
@@ -52,7 +52,7 @@ module ActionController
extend RenderOption
register_renderer :json
- def _render_json(json, options)
+ def render_json(json, options)
json = ActiveSupport::JSON.encode(json) unless json.respond_to?(:to_str)
json = "#{options[:callback]}(#{json})" unless options[:callback].blank?
self.content_type ||= Mime::JSON
@@ -64,9 +64,9 @@ module ActionController
extend RenderOption
register_renderer :js
- def _render_js(js, options)
+ def render_js(js, options)
self.content_type ||= Mime::JS
- self.response_body = js
+ self.response_body = js.respond_to?(:to_js) ? js.to_js : js
end
end
@@ -74,7 +74,7 @@ module ActionController
extend RenderOption
register_renderer :xml
- def _render_xml(xml, options)
+ def render_xml(xml, options)
self.content_type ||= Mime::XML
self.response_body = xml.respond_to?(:to_xml) ? xml.to_xml : xml
end
@@ -84,8 +84,8 @@ module ActionController
extend RenderOption
register_renderer :update
- def _render_update(proc, options)
- generator = ActionView::Helpers::PrototypeHelper::JavaScriptGenerator.new(_action_view, &proc)
+ def render_update(proc, options)
+ generator = ActionView::Helpers::PrototypeHelper::JavaScriptGenerator.new(view_context, &proc)
self.content_type = Mime::JS
self.response_body = generator.to_s
end
diff --git a/actionpack/lib/action_controller/base/renderer.rb b/actionpack/lib/action_controller/metal/renderer.rb
index 572da451ff..5a458764ad 100644
--- a/actionpack/lib/action_controller/base/renderer.rb
+++ b/actionpack/lib/action_controller/metal/renderer.rb
@@ -57,7 +57,7 @@ module ActionController
when true
options[:_prefix] = _prefix
when String
- options[:_prefix] = _prefix unless partial.index('/')
+ options[:_prefix] = _prefix unless partial.include?(?/)
options[:_template_name] = partial
else
options[:_partial_object] = true
diff --git a/actionpack/lib/action_controller/base/request_forgery_protection.rb b/actionpack/lib/action_controller/metal/request_forgery_protection.rb
index ad06657f86..ad06657f86 100644
--- a/actionpack/lib/action_controller/base/request_forgery_protection.rb
+++ b/actionpack/lib/action_controller/metal/request_forgery_protection.rb
diff --git a/actionpack/lib/action_controller/base/rescuable.rb b/actionpack/lib/action_controller/metal/rescuable.rb
index 029e643d93..029e643d93 100644
--- a/actionpack/lib/action_controller/base/rescuable.rb
+++ b/actionpack/lib/action_controller/metal/rescuable.rb
diff --git a/actionpack/lib/action_controller/base/session.rb b/actionpack/lib/action_controller/metal/session.rb
index bcedd6e1c7..bcedd6e1c7 100644
--- a/actionpack/lib/action_controller/base/session.rb
+++ b/actionpack/lib/action_controller/metal/session.rb
diff --git a/actionpack/lib/action_controller/base/session_management.rb b/actionpack/lib/action_controller/metal/session_management.rb
index ffce8e1bd1..ffce8e1bd1 100644
--- a/actionpack/lib/action_controller/base/session_management.rb
+++ b/actionpack/lib/action_controller/metal/session_management.rb
diff --git a/actionpack/lib/action_controller/base/streaming.rb b/actionpack/lib/action_controller/metal/streaming.rb
index 9ff4f25f43..f0317c6e99 100644
--- a/actionpack/lib/action_controller/base/streaming.rb
+++ b/actionpack/lib/action_controller/metal/streaming.rb
@@ -1,3 +1,5 @@
+require 'active_support/core_ext/string/bytesize'
+
module ActionController #:nodoc:
# Methods for sending arbitrary data and for streaming files to the browser,
# instead of rendering.
@@ -142,7 +144,7 @@ module ActionController #:nodoc:
# instead. See ActionController::Base#render for more information.
def send_data(data, options = {}) #:doc:
logger.info "Sending data #{options[:filename]}" if logger
- send_file_headers! options.merge(:length => data.size)
+ send_file_headers! options.merge(:length => data.bytesize)
@performed_render = false
render :status => options[:status], :text => data
end
@@ -179,7 +181,7 @@ module ActionController #:nodoc:
# after it displays the "open/save" dialog, which means that if you
# hit "open" the file isn't there anymore when the application that
# is called for handling the download is run, so let's workaround that
- headers['Cache-Control'] = 'private' if headers['Cache-Control'] == 'no-cache'
+ response.cache_control[:public] ||= false
end
end
end
diff --git a/actionpack/lib/action_controller/base/testing.rb b/actionpack/lib/action_controller/metal/testing.rb
index a4a1116d9e..a4a1116d9e 100644
--- a/actionpack/lib/action_controller/base/testing.rb
+++ b/actionpack/lib/action_controller/metal/testing.rb
diff --git a/actionpack/lib/action_controller/base/url_for.rb b/actionpack/lib/action_controller/metal/url_for.rb
index 7119c14cd3..7119c14cd3 100644
--- a/actionpack/lib/action_controller/base/url_for.rb
+++ b/actionpack/lib/action_controller/metal/url_for.rb
diff --git a/actionpack/lib/action_controller/base/verification.rb b/actionpack/lib/action_controller/metal/verification.rb
index 951ae1bee1..951ae1bee1 100644
--- a/actionpack/lib/action_controller/base/verification.rb
+++ b/actionpack/lib/action_controller/metal/verification.rb
diff --git a/actionpack/lib/action_controller/old_base.rb b/actionpack/lib/action_controller/old_base.rb
deleted file mode 100644
index dd22bfd617..0000000000
--- a/actionpack/lib/action_controller/old_base.rb
+++ /dev/null
@@ -1,84 +0,0 @@
-#--
-# Copyright (c) 2004-2009 David Heinemeier Hansson
-#
-# Permission is hereby granted, free of charge, to any person obtaining
-# a copy of this software and associated documentation files (the
-# "Software"), to deal in the Software without restriction, including
-# without limitation the rights to use, copy, modify, merge, publish,
-# distribute, sublicense, and/or sell copies of the Software, and to
-# permit persons to whom the Software is furnished to do so, subject to
-# the following conditions:
-#
-# The above copyright notice and this permission notice shall be
-# included in all copies or substantial portions of the Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-#++
-
-activesupport_path = "#{File.dirname(__FILE__)}/../../activesupport/lib"
-$:.unshift activesupport_path if File.directory?(activesupport_path)
-require 'active_support'
-
-require File.join(File.dirname(__FILE__), "action_pack")
-
-module ActionController
- # TODO: Review explicit to see if they will automatically be handled by
- # the initilizer if they are really needed.
- def self.load_all!
- [Base, Request, Response, UrlRewriter, UrlWriter]
- [ActionDispatch::Http::Headers]
- end
-
- autoload :Base, 'action_controller/base/base'
- autoload :Benchmarking, 'action_controller/base/chained/benchmarking'
- autoload :Caching, 'action_controller/caching'
- autoload :Cookies, 'action_controller/base/cookies'
- autoload :Dispatcher, 'action_controller/dispatch/dispatcher'
- autoload :Filters, 'action_controller/base/chained/filters'
- autoload :Flash, 'action_controller/base/chained/flash'
- autoload :Helpers, 'action_controller/base/helpers'
- autoload :HttpAuthentication, 'action_controller/base/http_authentication'
- autoload :Integration, 'action_controller/testing/integration'
- autoload :IntegrationTest, 'action_controller/testing/integration'
- autoload :Layout, 'action_controller/base/layout'
- autoload :MimeResponds, 'action_controller/base/mime_responds'
- autoload :PolymorphicRoutes, 'action_controller/routing/generation/polymorphic_routes'
- autoload :RecordIdentifier, 'action_controller/record_identifier'
- autoload :Redirector, 'action_controller/base/redirect'
- autoload :Renderer, 'action_controller/base/render'
- autoload :RequestForgeryProtection, 'action_controller/base/request_forgery_protection'
- autoload :Rescue, 'action_controller/base/rescue'
- autoload :Resources, 'action_controller/routing/resources'
- autoload :Responder, 'action_controller/base/responder'
- autoload :Routing, 'action_controller/routing'
- autoload :SessionManagement, 'action_controller/base/session_management'
- autoload :Streaming, 'action_controller/base/streaming'
- autoload :TestCase, 'action_controller/testing/test_case'
- autoload :TestProcess, 'action_controller/testing/process'
- autoload :Translation, 'action_controller/translation'
- autoload :UrlEncodedPairParser, 'action_controller/dispatch/url_encoded_pair_parser'
- autoload :UrlRewriter, 'action_controller/routing/generation/url_rewriter'
- autoload :UrlWriter, 'action_controller/routing/generation/url_rewriter'
- autoload :Verification, 'action_controller/base/verification'
- autoload :FilterParameterLogging, 'action_controller/base/filter_parameter_logging'
-
- module Assertions
- autoload :DomAssertions, 'action_controller/testing/assertions/dom'
- autoload :ModelAssertions, 'action_controller/testing/assertions/model'
- autoload :ResponseAssertions, 'action_controller/testing/assertions/response'
- autoload :RoutingAssertions, 'action_controller/testing/assertions/routing'
- autoload :SelectorAssertions, 'action_controller/testing/assertions/selector'
- autoload :TagAssertions, 'action_controller/testing/assertions/tag'
- end
-end
-
-autoload :HTML, 'action_controller/vendor/html-scanner'
-
-require 'action_dispatch'
-require 'action_view'
diff --git a/actionpack/lib/action_controller/record_identifier.rb b/actionpack/lib/action_controller/record_identifier.rb
index b4408e4e1d..1165c3b7c5 100644
--- a/actionpack/lib/action_controller/record_identifier.rb
+++ b/actionpack/lib/action_controller/record_identifier.rb
@@ -36,21 +36,6 @@ module ActionController
JOIN = '_'.freeze
NEW = 'new'.freeze
- # Returns plural/singular for a record or class. Example:
- #
- # partial_path(post) # => "posts/post"
- # partial_path(Person) # => "people/person"
- # partial_path(Person, "admin/games") # => "admin/people/person"
- def partial_path(record_or_class, controller_path = nil)
- name = model_name_from_record_or_class(record_or_class)
-
- if controller_path && controller_path.include?("/")
- "#{File.dirname(controller_path)}/#{name.partial_path}"
- else
- name.partial_path
- end
- end
-
# The DOM class convention is to use the singular form of an object or class. Examples:
#
# dom_class(post) # => "post"
diff --git a/actionpack/lib/action_controller/testing/process.rb b/actionpack/lib/action_controller/testing/process.rb
index e7c64d0942..d32d5562e8 100644
--- a/actionpack/lib/action_controller/testing/process.rb
+++ b/actionpack/lib/action_controller/testing/process.rb
@@ -52,7 +52,7 @@ module ActionController #:nodoc:
class TestResponse < ActionDispatch::TestResponse
def recycle!
@status = 200
- @header = Rack::Utils::HeaderHash.new(DEFAULT_HEADERS)
+ @header = Rack::Utils::HeaderHash.new
@writer = lambda { |x| @body << x }
@block = nil
@length = 0