diff options
Diffstat (limited to 'actionpack/lib')
13 files changed, 28 insertions, 18 deletions
diff --git a/actionpack/lib/action_controller/caching.rb b/actionpack/lib/action_controller/caching.rb index b3fa129929..0da0ca1893 100644 --- a/actionpack/lib/action_controller/caching.rb +++ b/actionpack/lib/action_controller/caching.rb @@ -63,8 +63,9 @@ module ActionController #:nodoc: included do extend ConfigMethods - @@perform_caching = true - cattr_accessor :perform_caching + delegate :perform_caching, :perform_caching=, :to => :config + singleton_class.delegate :perform_caching, :perform_caching=, :to => :config + self.perform_caching = true end diff --git a/actionpack/lib/action_controller/caching/pages.rb b/actionpack/lib/action_controller/caching/pages.rb index 21a424e6f0..20df3a1a69 100644 --- a/actionpack/lib/action_controller/caching/pages.rb +++ b/actionpack/lib/action_controller/caching/pages.rb @@ -44,8 +44,8 @@ module ActionController #:nodoc: # For Rails, this directory has already been set to Rails.public_path (which is usually set to <tt>Rails.root + "/public"</tt>). Changing # this setting can be useful to avoid naming conflicts with files in <tt>public/</tt>, but doing so will likely require configuring your # web server to look in the new location for cached files. - @@page_cache_directory = '' - cattr_accessor :page_cache_directory + singleton_class.delegate :page_cache_directory, :page_cache_directory=, :to => :config + self.page_cache_directory = '' ## # :singleton-method: @@ -53,8 +53,8 @@ module ActionController #:nodoc: # order to make it easy for the cached files to be picked up properly by the web server. By default, this cache extension is <tt>.html</tt>. # If you want something else, like <tt>.php</tt> or <tt>.shtml</tt>, just set Base.page_cache_extension. In cases where a request already has an # extension, such as <tt>.xml</tt> or <tt>.rss</tt>, page caching will not add an extension. This allows it to work well with RESTful apps. - @@page_cache_extension = '.html' - cattr_accessor :page_cache_extension + singleton_class.delegate :page_cache_extension, :page_cache_extension=, :to => :config + self.page_cache_extension = '.html' end module ClassMethods @@ -116,7 +116,7 @@ module ActionController #:nodoc: # Expires the page that was cached with the +options+ as a key. Example: # expire_page :controller => "lists", :action => "show" def expire_page(options = {}) - return unless perform_caching + return unless self.class.perform_caching if options.is_a?(Hash) if options[:action].is_a?(Array) @@ -135,7 +135,7 @@ module ActionController #:nodoc: # If no options are provided, the requested url is used. Example: # cache_page "I'm the cached content", :controller => "lists", :action => "show" def cache_page(content = nil, options = nil) - return unless perform_caching && caching_allowed + return unless self.class.perform_caching && caching_allowed path = case options when Hash diff --git a/actionpack/lib/action_controller/deprecated/base.rb b/actionpack/lib/action_controller/deprecated/base.rb index b817bf42bc..57203ce95f 100644 --- a/actionpack/lib/action_controller/deprecated/base.rb +++ b/actionpack/lib/action_controller/deprecated/base.rb @@ -146,12 +146,15 @@ module ActionController extend DeprecatedBehavior - deprecated_config_writer :session_store deprecated_config_writer :session_options - deprecated_config_accessor :perform_caching - deprecated_config_accessor :relative_url_root, "relative_url_root is ineffective. Please stop using it" + deprecated_config_writer :session_store + deprecated_config_accessor :assets_dir + deprecated_config_accessor :asset_path + deprecated_config_accessor :helpers_path deprecated_config_accessor :javascripts_dir + deprecated_config_accessor :page_cache_directory + deprecated_config_accessor :relative_url_root, "relative_url_root is ineffective. Please stop using it" deprecated_config_accessor :stylesheets_dir delegate :consider_all_requests_local, :consider_all_requests_local=, diff --git a/actionpack/lib/action_controller/test_case.rb b/actionpack/lib/action_controller/test_case.rb index dfd8e75bcc..b3758218a2 100644 --- a/actionpack/lib/action_controller/test_case.rb +++ b/actionpack/lib/action_controller/test_case.rb @@ -1,5 +1,6 @@ require 'rack/session/abstract/id' require 'active_support/core_ext/object/blank' +require 'active_support/core_ext/object/to_query' module ActionController module TemplateAssertions diff --git a/actionpack/lib/action_dispatch/http/response.rb b/actionpack/lib/action_dispatch/http/response.rb index 362e5ec970..8b730a97ee 100644 --- a/actionpack/lib/action_dispatch/http/response.rb +++ b/actionpack/lib/action_dispatch/http/response.rb @@ -1,6 +1,7 @@ require 'digest/md5' require 'active_support/core_ext/module/delegation' require 'active_support/core_ext/object/blank' +require 'active_support/core_ext/class/attribute_accessors' module ActionDispatch # :nodoc: # Represents an HTTP response generated by a controller action. One can use diff --git a/actionpack/lib/action_dispatch/middleware/params_parser.rb b/actionpack/lib/action_dispatch/middleware/params_parser.rb index 1524b00d5b..09fb1f998a 100644 --- a/actionpack/lib/action_dispatch/middleware/params_parser.rb +++ b/actionpack/lib/action_dispatch/middleware/params_parser.rb @@ -1,3 +1,4 @@ +require 'active_support/core_ext/hash/conversions.rb' require 'action_dispatch/http/request' module ActionDispatch diff --git a/actionpack/lib/action_dispatch/routing/deprecated_mapper.rb b/actionpack/lib/action_dispatch/routing/deprecated_mapper.rb index e8c2e74314..1b676669e2 100644 --- a/actionpack/lib/action_dispatch/routing/deprecated_mapper.rb +++ b/actionpack/lib/action_dispatch/routing/deprecated_mapper.rb @@ -1,4 +1,5 @@ require 'active_support/core_ext/object/blank' +require 'active_support/core_ext/object/with_options' module ActionDispatch module Routing diff --git a/actionpack/lib/action_dispatch/routing/mapper.rb b/actionpack/lib/action_dispatch/routing/mapper.rb index 53585740ce..ef2826a4e8 100644 --- a/actionpack/lib/action_dispatch/routing/mapper.rb +++ b/actionpack/lib/action_dispatch/routing/mapper.rb @@ -66,8 +66,8 @@ module ActionDispatch path = normalize_path(path) if using_match_shorthand?(path, options) - options[:to] ||= path[1..-1].sub(%r{/([^/]*)$}, '#\1') - options[:as] ||= path[1..-1].gsub("/", "_") + options[:to] ||= path[1..-1].sub(%r{/([^/]*)$}, '#\1').sub(%r{\(.*\)}, '') + options[:as] ||= path[1..-1].gsub("/", "_").sub(%r{\(.*\)}, '') end [ path, options ] @@ -80,7 +80,7 @@ module ActionDispatch # match "account/overview" def using_match_shorthand?(path, options) - path && options.except(:via, :anchor, :to, :as).empty? && path =~ %r{^/[\w\/]+$} + path && options.except(:via, :anchor, :to, :as).empty? && path =~ %r{^/[\w+/?]+(\(.*\))*$} end def normalize_path(path) diff --git a/actionpack/lib/action_dispatch/routing/route_set.rb b/actionpack/lib/action_dispatch/routing/route_set.rb index f1965f38b9..fdbff74071 100644 --- a/actionpack/lib/action_dispatch/routing/route_set.rb +++ b/actionpack/lib/action_dispatch/routing/route_set.rb @@ -1,5 +1,6 @@ require 'rack/mount' require 'forwardable' +require 'active_support/core_ext/object/to_query' require 'action_dispatch/routing/deprecated_mapper' module ActionDispatch diff --git a/actionpack/lib/action_dispatch/testing/test_process.rb b/actionpack/lib/action_dispatch/testing/test_process.rb index d4eecac2de..79f309cae7 100644 --- a/actionpack/lib/action_dispatch/testing/test_process.rb +++ b/actionpack/lib/action_dispatch/testing/test_process.rb @@ -3,13 +3,13 @@ require 'action_dispatch/middleware/flash' module ActionDispatch module TestProcess def assigns(key = nil) - assigns = {} + assigns = {}.with_indifferent_access @controller.instance_variable_names.each do |ivar| next if ActionController::Base.protected_instance_variables.include?(ivar) assigns[ivar[1..-1]] = @controller.instance_variable_get(ivar) end - key.nil? ? assigns : assigns[key.to_s] + key.nil? ? assigns : assigns[key] end def session diff --git a/actionpack/lib/action_view/helpers/form_options_helper.rb b/actionpack/lib/action_view/helpers/form_options_helper.rb index 105f4565e6..8f8db548c3 100644 --- a/actionpack/lib/action_view/helpers/form_options_helper.rb +++ b/actionpack/lib/action_view/helpers/form_options_helper.rb @@ -444,7 +444,7 @@ module ActionView body << content_tag(:optgroup, options_for_select(group[1], selected_key), :label => group[0]) end - body + body.html_safe end # Returns a string of option tags for pretty much any time zone in the diff --git a/actionpack/lib/action_view/helpers/url_helper.rb b/actionpack/lib/action_view/helpers/url_helper.rb index 0b748d700b..4ffc5ea127 100644 --- a/actionpack/lib/action_view/helpers/url_helper.rb +++ b/actionpack/lib/action_view/helpers/url_helper.rb @@ -504,7 +504,7 @@ module ActionView "document.write('#{content_tag("a", name || email_address_obfuscated.html_safe, html_options.merge({ "href" => "mailto:"+email_address+extras }))}');".each_byte do |c| string << sprintf("%%%x", c) end - "<script type=\"#{Mime::JS}\">eval(decodeURIComponent('#{string}'))</script>" + "<script type=\"#{Mime::JS}\">eval(decodeURIComponent('#{string}'))</script>".html_safe elsif encode == "hex" email_address_encoded = '' email_address_obfuscated.each_byte do |c| diff --git a/actionpack/lib/action_view/test_case.rb b/actionpack/lib/action_view/test_case.rb index ddea9cfd92..beda7743bf 100644 --- a/actionpack/lib/action_view/test_case.rb +++ b/actionpack/lib/action_view/test_case.rb @@ -1,4 +1,5 @@ require 'active_support/core_ext/object/blank' +require 'action_controller' require 'action_controller/test_case' require 'action_view' |