diff options
Diffstat (limited to 'actionpack')
-rw-r--r-- | actionpack/lib/abstract_controller/asset_paths.rb | 2 | ||||
-rw-r--r-- | actionpack/lib/abstract_controller/base.rb | 7 | ||||
-rw-r--r-- | actionpack/lib/abstract_controller/logger.rb | 2 | ||||
-rw-r--r-- | actionpack/lib/action_controller/caching/sweeping.rb | 2 | ||||
-rw-r--r-- | actionpack/lib/action_controller/record_identifier.rb | 1 | ||||
-rw-r--r-- | actionpack/lib/action_dispatch/http/mime_type.rb | 2 | ||||
-rw-r--r-- | actionpack/lib/action_dispatch/routing/route_set.rb | 3 | ||||
-rw-r--r-- | actionpack/lib/action_dispatch/routing/url_for.rb | 15 | ||||
-rw-r--r-- | actionpack/lib/action_view/helpers/atom_feed_helper.rb | 2 | ||||
-rw-r--r-- | actionpack/lib/action_view/helpers/form_tag_helper.rb | 4 | ||||
-rw-r--r-- | actionpack/lib/action_view/helpers/tags/base.rb | 2 | ||||
-rw-r--r-- | actionpack/lib/action_view/helpers/text_helper.rb | 10 | ||||
-rw-r--r-- | actionpack/test/controller/filters_test.rb | 7 | ||||
-rw-r--r-- | actionpack/test/controller/url_for_test.rb | 18 |
14 files changed, 58 insertions, 19 deletions
diff --git a/actionpack/lib/abstract_controller/asset_paths.rb b/actionpack/lib/abstract_controller/asset_paths.rb index dd5f9a1942..822254b1a4 100644 --- a/actionpack/lib/abstract_controller/asset_paths.rb +++ b/actionpack/lib/abstract_controller/asset_paths.rb @@ -1,5 +1,5 @@ module AbstractController - module AssetPaths + module AssetPaths #:nodoc: extend ActiveSupport::Concern included do diff --git a/actionpack/lib/abstract_controller/base.rb b/actionpack/lib/abstract_controller/base.rb index b068846a13..97a9eec144 100644 --- a/actionpack/lib/abstract_controller/base.rb +++ b/actionpack/lib/abstract_controller/base.rb @@ -5,8 +5,11 @@ require 'active_support/descendants_tracker' require 'active_support/core_ext/module/anonymous' module AbstractController - class Error < StandardError; end - class ActionNotFound < StandardError; end + class Error < StandardError #:nodoc: + end + + class ActionNotFound < StandardError #:nodoc: + end # <tt>AbstractController::Base</tt> is a low-level API. Nobody should be # using it directly, and subclasses (like ActionController::Base) are diff --git a/actionpack/lib/abstract_controller/logger.rb b/actionpack/lib/abstract_controller/logger.rb index a4e31cd2e5..c31ea6c5b5 100644 --- a/actionpack/lib/abstract_controller/logger.rb +++ b/actionpack/lib/abstract_controller/logger.rb @@ -1,7 +1,7 @@ require "active_support/benchmarkable" module AbstractController - module Logger + module Logger #:nodoc: extend ActiveSupport::Concern included do diff --git a/actionpack/lib/action_controller/caching/sweeping.rb b/actionpack/lib/action_controller/caching/sweeping.rb index bb176ca3f9..cc1fa23935 100644 --- a/actionpack/lib/action_controller/caching/sweeping.rb +++ b/actionpack/lib/action_controller/caching/sweeping.rb @@ -93,7 +93,7 @@ module ActionController #:nodoc: end def method_missing(method, *arguments, &block) - super unless @controller + return super unless @controller @controller.__send__(method, *arguments, &block) end end diff --git a/actionpack/lib/action_controller/record_identifier.rb b/actionpack/lib/action_controller/record_identifier.rb index 18dda978b3..5c40889f6b 100644 --- a/actionpack/lib/action_controller/record_identifier.rb +++ b/actionpack/lib/action_controller/record_identifier.rb @@ -53,6 +53,7 @@ module ActionController # If you need to address multiple instances of the same class in the same view, you can prefix the dom_id: # # dom_id(Post.find(45), :edit) # => "edit_post_45" + # dom_id(Post.new, :custom) # => "custom_post" def dom_id(record, prefix = nil) if record_id = record_key_for_dom_id(record) "#{dom_class(record, prefix)}#{JOIN}#{record_id}" diff --git a/actionpack/lib/action_dispatch/http/mime_type.rb b/actionpack/lib/action_dispatch/http/mime_type.rb index e039eb1288..26f4c16218 100644 --- a/actionpack/lib/action_dispatch/http/mime_type.rb +++ b/actionpack/lib/action_dispatch/http/mime_type.rb @@ -38,7 +38,7 @@ module Mime # respond_to do |format| # format.html # format.ics { render :text => post.to_ics, :mime_type => Mime::Type["text/calendar"] } - # format.xml { render :xml => @people.to_xml } + # format.xml { render :xml => @people } # end # end # end diff --git a/actionpack/lib/action_dispatch/routing/route_set.rb b/actionpack/lib/action_dispatch/routing/route_set.rb index 30e9e5634b..45075050eb 100644 --- a/actionpack/lib/action_dispatch/routing/route_set.rb +++ b/actionpack/lib/action_dispatch/routing/route_set.rb @@ -605,8 +605,9 @@ module ActionDispatch nil end + # The +options+ argument must be +nil+ or a hash whose keys are *symbols*. def url_for(options) - options = (options || {}).reverse_merge!(default_url_options) + options = default_url_options.merge(options || {}) handle_positional_args(options) diff --git a/actionpack/lib/action_dispatch/routing/url_for.rb b/actionpack/lib/action_dispatch/routing/url_for.rb index 94db36ce1f..12ae2456d6 100644 --- a/actionpack/lib/action_dispatch/routing/url_for.rb +++ b/actionpack/lib/action_dispatch/routing/url_for.rb @@ -144,10 +144,21 @@ module ActionDispatch # # => 'http://somehost.org/tasks/testing?number=33' def url_for(options = nil) case options + when nil + _routes.url_for(url_options.symbolize_keys) + when Hash + symbolized = {} + options.keys.each do |k| + sym = k.to_sym + symbolized[sym] = options[k] unless symbolized.has_key?(sym) + end + url_options.keys.each do |k| + sym = k.to_sym + symbolized[sym] = url_options[k] unless symbolized.has_key?(sym) + end + _routes.url_for(symbolized) when String options - when nil, Hash - _routes.url_for((options || {}).symbolize_keys.reverse_merge!(url_options)) else polymorphic_url(options) end diff --git a/actionpack/lib/action_view/helpers/atom_feed_helper.rb b/actionpack/lib/action_view/helpers/atom_feed_helper.rb index 70164217de..f9aa8d7cee 100644 --- a/actionpack/lib/action_view/helpers/atom_feed_helper.rb +++ b/actionpack/lib/action_view/helpers/atom_feed_helper.rb @@ -189,7 +189,7 @@ module ActionView @xml.updated((options[:updated] || record.updated_at).xmlschema) end - type = options.fetch(:type) { 'text/html' } + type = options.fetch(:type, 'text/html') @xml.link(:rel => 'alternate', :type => type, :href => options[:url] || @view.polymorphic_url(record)) diff --git a/actionpack/lib/action_view/helpers/form_tag_helper.rb b/actionpack/lib/action_view/helpers/form_tag_helper.rb index e403d6cf5e..b5e0970612 100644 --- a/actionpack/lib/action_view/helpers/form_tag_helper.rb +++ b/actionpack/lib/action_view/helpers/form_tag_helper.rb @@ -122,11 +122,11 @@ module ActionView html_name = (options[:multiple] == true && !name.to_s.ends_with?("[]")) ? "#{name}[]" : name if options.delete(:include_blank) - option_tags = "<option value=\"\"></option>".html_safe + option_tags + option_tags = content_tag(:option, '', :value => '').safe_concat(option_tags) end if prompt = options.delete(:prompt) - option_tags = "<option value=\"\">#{prompt}</option>".html_safe + option_tags + option_tags = content_tag(:option, prompt, :value => '').safe_concat(option_tags) end content_tag :select, option_tags, { "name" => html_name, "id" => sanitize_to_id(name) }.update(options.stringify_keys) diff --git a/actionpack/lib/action_view/helpers/tags/base.rb b/actionpack/lib/action_view/helpers/tags/base.rb index 7c2f12d8e7..e4f431a6d7 100644 --- a/actionpack/lib/action_view/helpers/tags/base.rb +++ b/actionpack/lib/action_view/helpers/tags/base.rb @@ -123,7 +123,7 @@ module ActionView add_default_name_and_id(html_options) select = content_tag("select", add_options(option_tags, options, value(object)), html_options) - if html_options["multiple"] && options.fetch(:include_hidden) { true } + if html_options["multiple"] && options.fetch(:include_hidden, true) tag("input", :disabled => html_options["disabled"], :name => html_options["name"], :type => "hidden", :value => "") + select else select diff --git a/actionpack/lib/action_view/helpers/text_helper.rb b/actionpack/lib/action_view/helpers/text_helper.rb index 3dc651501e..eb806f44cf 100644 --- a/actionpack/lib/action_view/helpers/text_helper.rb +++ b/actionpack/lib/action_view/helpers/text_helper.rb @@ -1,5 +1,6 @@ require 'active_support/core_ext/object/blank' require 'active_support/core_ext/string/filters' +require 'active_support/core_ext/array/extract_options' module ActionView # = Action View Text Helpers @@ -306,12 +307,9 @@ module ActionView # </tr> # <% end %> def cycle(first_value, *values) - if (values.last.instance_of? Hash) - params = values.pop - name = params[:name] - else - name = "default" - end + options = values.extract_options! + name = options.fetch(:name, "default") + values.unshift(first_value) cycle = get_cycle(name) diff --git a/actionpack/test/controller/filters_test.rb b/actionpack/test/controller/filters_test.rb index 65c853f6eb..ef7fbca675 100644 --- a/actionpack/test/controller/filters_test.rb +++ b/actionpack/test/controller/filters_test.rb @@ -510,6 +510,13 @@ class FilterTest < ActionController::TestCase end end + def test_sweeper_should_not_ignore_no_method_error + sweeper = ActionController::Caching::Sweeper.send(:new) + assert_raise NoMethodError do + sweeper.send_not_defined + end + end + def test_sweeper_should_not_block_rendering response = test_process(SweeperTestController) assert_equal 'hello world', response.body diff --git a/actionpack/test/controller/url_for_test.rb b/actionpack/test/controller/url_for_test.rb index aa233d6135..04a431c5c9 100644 --- a/actionpack/test/controller/url_for_test.rb +++ b/actionpack/test/controller/url_for_test.rb @@ -356,6 +356,24 @@ module AbstractController assert_equal("/c/a", W.new.url_for(HashWithIndifferentAccess.new('controller' => 'c', 'action' => 'a', 'only_path' => true))) end + def test_with_stringified_default_url_options + W.default_url_options['controller'] = 'd' + W.default_url_options['only_path'] = false + assert_equal("/c", W.new.url_for(:controller => 'c', :only_path => true)) + + W.default_url_options['action'] = 'b' + assert_equal("/c/a", W.new.url_for(:controller => 'c', :action => 'a', :only_path => true)) + end + + def test_with_stringified_default_url_options_and_without_options + W.default_url_options['controller'] = 'c' + W.default_url_options['only_path'] = true + assert_equal("/c", W.new.url_for) + + W.default_url_options['action'] = 'a' + assert_equal("/c/a", W.new.url_for) + end + def test_url_params_with_nil_to_param_are_not_in_url assert_equal("/c/a", W.new.url_for(:only_path => true, :controller => 'c', :action => 'a', :id => Struct.new(:to_param).new(nil))) end |