diff options
author | rick <technoweenie@gmail.com> | 2008-06-19 09:59:36 -0700 |
---|---|---|
committer | rick <technoweenie@gmail.com> | 2008-06-19 09:59:36 -0700 |
commit | 10c581a6deed66e8b62de6e7a3621a63de90baad (patch) | |
tree | 588ceb1118761602caa8ccf248dd08d59f33896c /actionpack/lib/action_controller | |
parent | 64637da284ed4685591c178202ee103e6bee71cf (diff) | |
parent | 81025b5808886289f54d698f73f4199c99223e7e (diff) | |
download | rails-10c581a6deed66e8b62de6e7a3621a63de90baad.tar.gz rails-10c581a6deed66e8b62de6e7a3621a63de90baad.tar.bz2 rails-10c581a6deed66e8b62de6e7a3621a63de90baad.zip |
fix merge
Diffstat (limited to 'actionpack/lib/action_controller')
-rwxr-xr-x | actionpack/lib/action_controller/base.rb | 35 | ||||
-rw-r--r-- | actionpack/lib/action_controller/caching/actions.rb | 41 | ||||
-rw-r--r-- | actionpack/lib/action_controller/dispatcher.rb | 2 | ||||
-rw-r--r-- | actionpack/lib/action_controller/integration.rb | 9 | ||||
-rw-r--r-- | actionpack/lib/action_controller/layout.rb | 2 | ||||
-rw-r--r-- | actionpack/lib/action_controller/performance_test.rb | 16 | ||||
-rw-r--r-- | actionpack/lib/action_controller/record_identifier.rb | 4 | ||||
-rw-r--r-- | actionpack/lib/action_controller/resources.rb | 6 | ||||
-rw-r--r-- | actionpack/lib/action_controller/templates/rescues/layout.erb | 2 | ||||
-rw-r--r-- | actionpack/lib/action_controller/verification.rb | 2 |
10 files changed, 71 insertions, 48 deletions
diff --git a/actionpack/lib/action_controller/base.rb b/actionpack/lib/action_controller/base.rb index a036600c2b..bf34edcd85 100755 --- a/actionpack/lib/action_controller/base.rb +++ b/actionpack/lib/action_controller/base.rb @@ -283,13 +283,6 @@ module ActionController #:nodoc: @@debug_routes = true cattr_accessor :debug_routes - # Indicates to Mongrel or Webrick whether to allow concurrent action - # processing. Your controller actions and any other code they call must - # also behave well when called from concurrent threads. Turned off by - # default. - @@allow_concurrency = false - cattr_accessor :allow_concurrency - # Modern REST web services often need to submit complex data to the web application. # The <tt>@@param_parsers</tt> hash lets you register handlers which will process the HTTP body and add parameters to the # <tt>params</tt> hash. These handlers are invoked for POST and PUT requests. @@ -428,8 +421,7 @@ module ActionController #:nodoc: end def view_paths=(value) - @view_paths = value - ActionView::TemplateFinder.process_view_paths(value) + @view_paths = ActionView::ViewLoadPaths.new(Array(value)) if value end # Adds a view_path to the front of the view_paths array. @@ -441,8 +433,7 @@ module ActionController #:nodoc: # def prepend_view_path(path) @view_paths = superclass.view_paths.dup if @view_paths.nil? - view_paths.unshift(*path) - ActionView::TemplateFinder.process_view_paths(path) + @view_paths.unshift(*path) end # Adds a view_path to the end of the view_paths array. @@ -454,8 +445,7 @@ module ActionController #:nodoc: # def append_view_path(path) @view_paths = superclass.view_paths.dup if @view_paths.nil? - view_paths.push(*path) - ActionView::TemplateFinder.process_view_paths(path) + @view_paths.push(*path) end # Replace sensitive parameter data from the request log. @@ -613,8 +603,8 @@ module ActionController #:nodoc: # # This takes the current URL as is and only exchanges the action. In contrast, <tt>url_for :action => 'print'</tt> # would have slashed-off the path components after the changed action. - def url_for(options = nil) #:doc: - case options || {} + def url_for(options = {}) #:doc: + case options when String options when Hash @@ -647,11 +637,11 @@ module ActionController #:nodoc: # View load paths for controller. def view_paths - @template.finder.view_paths + @template.view_paths end def view_paths=(value) - @template.finder.view_paths = value # Mutex needed + @template.view_paths = ViewLoadPaths.new(value) end # Adds a view_path to the front of the view_paths array. @@ -661,7 +651,7 @@ module ActionController #:nodoc: # self.prepend_view_path(["views/default", "views/custom"]) # def prepend_view_path(path) - @template.finder.prepend_view_path(path) # Mutex needed + @template.view_paths.unshift(*path) end # Adds a view_path to the end of the view_paths array. @@ -671,7 +661,7 @@ module ActionController #:nodoc: # self.append_view_path(["views/default", "views/custom"]) # def append_view_path(path) - @template.finder.append_view_path(path) # Mutex needed + @template.view_paths.push(*path) end protected @@ -1232,7 +1222,7 @@ module ActionController #:nodoc: end def template_exists?(template_name = default_template_name) - @template.finder.file_exists?(template_name) + @template.file_exists?(template_name) end def template_public?(template_name = default_template_name) @@ -1240,9 +1230,8 @@ module ActionController #:nodoc: end def template_exempt_from_layout?(template_name = default_template_name) - extension = @template && @template.finder.pick_template_extension(template_name) - name_with_extension = !template_name.include?('.') && extension ? "#{template_name}.#{extension}" : template_name - @@exempt_from_layout.any? { |ext| name_with_extension =~ ext } + template_name = @template.send(:template_file_from_name, template_name) if @template + @@exempt_from_layout.any? { |ext| template_name.to_s =~ ext } end def default_template_name(action_name = self.action_name) diff --git a/actionpack/lib/action_controller/caching/actions.rb b/actionpack/lib/action_controller/caching/actions.rb index c4b0a97a33..65a36f7f98 100644 --- a/actionpack/lib/action_controller/caching/actions.rb +++ b/actionpack/lib/action_controller/caching/actions.rb @@ -67,10 +67,10 @@ module ActionController #:nodoc: if options[:action].is_a?(Array) options[:action].dup.each do |action| - expire_fragment(ActionCachePath.path_for(self, options.merge({ :action => action }))) + expire_fragment(ActionCachePath.path_for(self, options.merge({ :action => action }), false)) end else - expire_fragment(ActionCachePath.path_for(self, options)) + expire_fragment(ActionCachePath.path_for(self, options, false)) end end @@ -125,16 +125,24 @@ module ActionController #:nodoc: attr_reader :path, :extension class << self - def path_for(controller, options) - new(controller, options).path + def path_for(controller, options, infer_extension=true) + new(controller, options, infer_extension).path end end - - def initialize(controller, options = {}) - @extension = extract_extension(controller.request.path) + + # When true, infer_extension will look up the cache path extension from the request's path & format. + # This is desirable when reading and writing the cache, but not when expiring the cache - expire_action should expire the same files regardless of the request format. + def initialize(controller, options = {}, infer_extension=true) + if infer_extension and options.is_a? Hash + request_extension = extract_extension(controller.request) + options = options.reverse_merge(:format => request_extension) + end path = controller.url_for(options).split('://').last normalize!(path) - add_extension!(path, @extension) + if infer_extension + @extension = request_extension + add_extension!(path, @extension) + end @path = URI.unescape(path) end @@ -144,13 +152,22 @@ module ActionController #:nodoc: end def add_extension!(path, extension) - path << ".#{extension}" if extension + path << ".#{extension}" if extension and !path.ends_with?(extension) end - - def extract_extension(file_path) + + def extract_extension(request) # Don't want just what comes after the last '.' to accommodate multi part extensions # such as tar.gz. - file_path[/^[^.]+\.(.+)$/, 1] + extension = request.path[/^[^.]+\.(.+)$/, 1] + + # If there's no extension in the path, check request.format + if extension.nil? + extension = request.format.to_sym.to_s + if extension=='all' + extension = nil + end + end + extension end end end diff --git a/actionpack/lib/action_controller/dispatcher.rb b/actionpack/lib/action_controller/dispatcher.rb index fe4f6b4a7e..7df987d525 100644 --- a/actionpack/lib/action_controller/dispatcher.rb +++ b/actionpack/lib/action_controller/dispatcher.rb @@ -134,7 +134,7 @@ module ActionController run_callbacks :prepare_dispatch Routing::Routes.reload - ActionView::TemplateFinder.reload! unless ActionView::Base.cache_template_loading + ActionController::Base.view_paths.reload! end # Cleanup the application by clearing out loaded classes so they can diff --git a/actionpack/lib/action_controller/integration.rb b/actionpack/lib/action_controller/integration.rb index bd69d02ed7..18c2df8b37 100644 --- a/actionpack/lib/action_controller/integration.rb +++ b/actionpack/lib/action_controller/integration.rb @@ -1,9 +1,10 @@ -require 'stringio' -require 'uri' - +require 'active_support/test_case' require 'action_controller/dispatcher' require 'action_controller/test_process' +require 'stringio' +require 'uri' + module ActionController module Integration #:nodoc: # An integration Session instance represents a set of requests and responses @@ -580,7 +581,7 @@ EOF # end # end # end - class IntegrationTest < Test::Unit::TestCase + class IntegrationTest < ActiveSupport::TestCase include Integration::Runner # Work around a bug in test/unit caused by the default test being named diff --git a/actionpack/lib/action_controller/layout.rb b/actionpack/lib/action_controller/layout.rb index b5b59f2d7c..0721f71498 100644 --- a/actionpack/lib/action_controller/layout.rb +++ b/actionpack/lib/action_controller/layout.rb @@ -304,7 +304,7 @@ module ActionController #:nodoc: end def layout_directory?(layout_name) - @template.finder.find_template_extension_from_handler(File.join('layouts', layout_name)) + @template.view_paths.find_template_file_for_path("#{File.join('layouts', layout_name)}.#{@template.template_format}.erb") ? true : false end end end diff --git a/actionpack/lib/action_controller/performance_test.rb b/actionpack/lib/action_controller/performance_test.rb new file mode 100644 index 0000000000..85543fffae --- /dev/null +++ b/actionpack/lib/action_controller/performance_test.rb @@ -0,0 +1,16 @@ +require 'action_controller/integration' +require 'active_support/testing/performance' +require 'active_support/testing/default' + +module ActionController + # An integration test that runs a code profiler on your test methods. + # Profiling output for combinations of each test method, measurement, and + # output format are written to your tmp/performance directory. + # + # By default, process_time is measured and both flat and graph_html output + # formats are written, so you'll have two output files per test method. + class PerformanceTest < ActionController::IntegrationTest + include ActiveSupport::Testing::Performance + include ActiveSupport::Testing::Default + end +end diff --git a/actionpack/lib/action_controller/record_identifier.rb b/actionpack/lib/action_controller/record_identifier.rb index f69c3d6163..742d290ad6 100644 --- a/actionpack/lib/action_controller/record_identifier.rb +++ b/actionpack/lib/action_controller/record_identifier.rb @@ -66,12 +66,12 @@ module ActionController # The DOM id convention is to use the singular form of an object or class with the id following an underscore. # If no id is found, prefix with "new_" instead. Examples: # - # dom_id(Post.new(:id => 45)) # => "post_45" + # dom_id(Post.find(45)) # => "post_45" # dom_id(Post.new) # => "new_post" # # If you need to address multiple instances of the same class in the same view, you can prefix the dom_id: # - # dom_id(Post.new(:id => 45), :edit) # => "edit_post_45" + # dom_id(Post.find(45), :edit) # => "edit_post_45" def dom_id(record, prefix = nil) if record_id = record.id "#{dom_class(record, prefix)}#{JOIN}#{record_id}" diff --git a/actionpack/lib/action_controller/resources.rb b/actionpack/lib/action_controller/resources.rb index 9fb1f9fa39..af2fcaf3ad 100644 --- a/actionpack/lib/action_controller/resources.rb +++ b/actionpack/lib/action_controller/resources.rb @@ -72,7 +72,7 @@ module ActionController end def conditions - @conditions = @options[:conditions] || {} + @conditions ||= @options[:conditions] || {} end def path @@ -80,9 +80,9 @@ module ActionController end def new_path - new_action = self.options[:path_names][:new] if self.options[:path_names] + new_action = self.options[:path_names][:new] if self.options[:path_names] new_action ||= Base.resources_path_names[:new] - @new_path ||= "#{path}/#{new_action}" + @new_path ||= "#{path}/#{new_action}" end def member_path diff --git a/actionpack/lib/action_controller/templates/rescues/layout.erb b/actionpack/lib/action_controller/templates/rescues/layout.erb index d38f3e67f9..4a04742e40 100644 --- a/actionpack/lib/action_controller/templates/rescues/layout.erb +++ b/actionpack/lib/action_controller/templates/rescues/layout.erb @@ -1,4 +1,4 @@ -<html> +<html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Action Controller: Exception caught</title> <style> diff --git a/actionpack/lib/action_controller/verification.rb b/actionpack/lib/action_controller/verification.rb index 9f606e7b7c..35b12a7f13 100644 --- a/actionpack/lib/action_controller/verification.rb +++ b/actionpack/lib/action_controller/verification.rb @@ -116,7 +116,7 @@ module ActionController #:nodoc: end def apply_redirect_to(redirect_to_option) # :nodoc: - redirect_to_option.is_a?(Symbol) ? self.send!(redirect_to_option) : redirect_to_option + (redirect_to_option.is_a?(Symbol) && redirect_to_option != :back) ? self.send!(redirect_to_option) : redirect_to_option end def apply_remaining_actions(options) # :nodoc: |