diff options
Diffstat (limited to 'actionpack')
52 files changed, 101 insertions, 108 deletions
diff --git a/actionpack/CHANGELOG.md b/actionpack/CHANGELOG.md index f408c50390..583d984989 100644 --- a/actionpack/CHANGELOG.md +++ b/actionpack/CHANGELOG.md @@ -1,3 +1,7 @@ +* check_box helper with :disabled => true will generate a disabled hidden field to conform with the HTML convention where disabled fields are not submitted with the form. + This is a behavior change, previously the hidden tag had a value of the disabled checkbox. + *Tadas Tamosauskas* + ## Rails 3.2.0 (unreleased) ## * Add font_path helper method *Santiago Pastorino* diff --git a/actionpack/README.rdoc b/actionpack/README.rdoc index fc36423f83..076a93bbcd 100644 --- a/actionpack/README.rdoc +++ b/actionpack/README.rdoc @@ -206,7 +206,7 @@ A short rundown of some of the major features: You specify a logger through a class method, such as: - ActionController::Base.logger = Logger.new("Application Log") + ActionController::Base.logger = ActiveSupport::Logger.new("Application Log") ActionController::Base.logger = Log4r::Logger.new("Application Log") diff --git a/actionpack/lib/abstract_controller/callbacks.rb b/actionpack/lib/abstract_controller/callbacks.rb index 7004e607a1..fffe3edac2 100644 --- a/actionpack/lib/abstract_controller/callbacks.rb +++ b/actionpack/lib/abstract_controller/callbacks.rb @@ -167,7 +167,7 @@ module AbstractController # for details on the allowed parameters. def #{filter}_filter(*names, &blk) # def before_filter(*names, &blk) _insert_callbacks(names, blk) do |name, options| # _insert_callbacks(names, blk) do |name, options| - options[:if] = (Array.wrap(options[:if]) << "!halted") if #{filter == :after} # options[:if] = (Array.wrap(options[:if]) << "!halted") if false + options[:if] = (Array(options[:if]) << "!halted") if #{filter == :after} # options[:if] = (Array(options[:if]) << "!halted") if false set_callback(:process_action, :#{filter}, name, options) # set_callback(:process_action, :before, name, options) end # end end # end @@ -176,7 +176,7 @@ module AbstractController # for details on the allowed parameters. def prepend_#{filter}_filter(*names, &blk) # def prepend_before_filter(*names, &blk) _insert_callbacks(names, blk) do |name, options| # _insert_callbacks(names, blk) do |name, options| - options[:if] = (Array.wrap(options[:if]) << "!halted") if #{filter == :after} # options[:if] = (Array.wrap(options[:if]) << "!halted") if false + options[:if] = (Array(options[:if]) << "!halted") if #{filter == :after} # options[:if] = (Array(options[:if]) << "!halted") if false set_callback(:process_action, :#{filter}, name, options.merge(:prepend => true)) # set_callback(:process_action, :before, name, options.merge(:prepend => true)) end # end end # end diff --git a/actionpack/lib/abstract_controller/view_paths.rb b/actionpack/lib/abstract_controller/view_paths.rb index 96118b940f..c08b3a0e2a 100644 --- a/actionpack/lib/abstract_controller/view_paths.rb +++ b/actionpack/lib/abstract_controller/view_paths.rb @@ -89,7 +89,7 @@ module AbstractController # * <tt>paths</tt> - If a PathSet is provided, use that; # otherwise, process the parameter into a PathSet. def view_paths=(paths) - self._view_paths = ActionView::PathSet.new(Array.wrap(paths)) + self._view_paths = ActionView::PathSet.new(Array(paths)) end end end diff --git a/actionpack/lib/action_controller/metal/helpers.rb b/actionpack/lib/action_controller/metal/helpers.rb index 50d7aac300..d070eaae5d 100644 --- a/actionpack/lib/action_controller/metal/helpers.rb +++ b/actionpack/lib/action_controller/metal/helpers.rb @@ -1,4 +1,3 @@ -require 'active_support/core_ext/array/wrap' require 'active_support/core_ext/class/attribute' module ActionController @@ -94,7 +93,7 @@ module ActionController def all_helpers_from_path(path) helpers = [] - Array.wrap(path).each do |_path| + Array(path).each do |_path| extract = /^#{Regexp.quote(_path.to_s)}\/?(.*)_helper.rb$/ helpers += Dir["#{_path}/**/*_helper.rb"].map { |file| file.sub(extract, '\1') } end diff --git a/actionpack/lib/action_controller/metal/params_wrapper.rb b/actionpack/lib/action_controller/metal/params_wrapper.rb index 5c28a8074f..fa760f2658 100644 --- a/actionpack/lib/action_controller/metal/params_wrapper.rb +++ b/actionpack/lib/action_controller/metal/params_wrapper.rb @@ -1,7 +1,6 @@ require 'active_support/core_ext/class/attribute' require 'active_support/core_ext/hash/slice' require 'active_support/core_ext/hash/except' -require 'active_support/core_ext/array/wrap' require 'active_support/core_ext/module/anonymous' require 'action_dispatch/http/mime_types' @@ -43,9 +42,9 @@ module ActionController # wrap_parameters :person, :include => [:username, :password] # end # - # On ActiveRecord models with no +:include+ or +:exclude+ option set, + # On ActiveRecord models with no +:include+ or +:exclude+ option set, # if attr_accessible is set on that model, it will only wrap the accessible - # parameters, else it will only wrap the parameters returned by the class + # parameters, else it will only wrap the parameters returned by the class # method attribute_names. # # If you're going to pass the parameters to an +ActiveModel+ object (such as @@ -180,9 +179,9 @@ module ActionController controller_name.singularize end - options[:include] = Array.wrap(options[:include]).collect(&:to_s) if options[:include] - options[:exclude] = Array.wrap(options[:exclude]).collect(&:to_s) if options[:exclude] - options[:format] = Array.wrap(options[:format]) + options[:include] = Array(options[:include]).collect(&:to_s) if options[:include] + options[:exclude] = Array(options[:exclude]).collect(&:to_s) if options[:exclude] + options[:format] = Array(options[:format]) self._wrapper_options = options end diff --git a/actionpack/lib/action_controller/test_case.rb b/actionpack/lib/action_controller/test_case.rb index ac2e0fcb83..e96ff82a5a 100644 --- a/actionpack/lib/action_controller/test_case.rb +++ b/actionpack/lib/action_controller/test_case.rb @@ -432,13 +432,13 @@ module ActionController def process(action, http_method = 'GET', *args) check_required_ivars http_method, args = handle_old_process_api(http_method, args) - + if args.first.is_a?(String) @request.env['RAW_POST_DATA'] = args.shift end - + parameters, session, flash = args - + # Ensure that numbers and symbols passed as params are converted to # proper params, as is the case when engaging rack. parameters = paramify_values(parameters) @@ -512,7 +512,7 @@ module ActionController end end end - + def handle_old_process_api(http_method, args) # 4.0: Remove this method. if http_method.is_a?(Hash) @@ -520,7 +520,7 @@ module ActionController args.unshift(http_method) http_method = args.last.is_a?(String) ? args.last : "GET" end - + [http_method, args] end diff --git a/actionpack/lib/action_dispatch/http/filter_parameters.rb b/actionpack/lib/action_dispatch/http/filter_parameters.rb index 8dd1af7f3d..02a15ad599 100644 --- a/actionpack/lib/action_dispatch/http/filter_parameters.rb +++ b/actionpack/lib/action_dispatch/http/filter_parameters.rb @@ -50,7 +50,7 @@ module ActionDispatch end def env_filter - parameter_filter_for(Array.wrap(@env["action_dispatch.parameter_filter"]) << /RAW_POST_DATA/) + parameter_filter_for(Array(@env["action_dispatch.parameter_filter"]) << /RAW_POST_DATA/) end def parameter_filter_for(filters) diff --git a/actionpack/lib/action_dispatch/middleware/remote_ip.rb b/actionpack/lib/action_dispatch/middleware/remote_ip.rb index 66ece60860..030ccb2017 100644 --- a/actionpack/lib/action_dispatch/middleware/remote_ip.rb +++ b/actionpack/lib/action_dispatch/middleware/remote_ip.rb @@ -33,8 +33,8 @@ module ActionDispatch class GetIp def initialize(env, middleware) - @env = env - @middleware = middleware + @env = env + @middleware = middleware @calculated_ip = false end diff --git a/actionpack/lib/action_dispatch/middleware/show_exceptions.rb b/actionpack/lib/action_dispatch/middleware/show_exceptions.rb index 3d06214bf1..836136eb95 100644 --- a/actionpack/lib/action_dispatch/middleware/show_exceptions.rb +++ b/actionpack/lib/action_dispatch/middleware/show_exceptions.rb @@ -1,6 +1,5 @@ require 'action_dispatch/http/request' require 'action_dispatch/middleware/exception_wrapper' -require 'active_support/deprecation' module ActionDispatch # This middleware rescues any exception returned by the application @@ -39,11 +38,6 @@ module ActionDispatch private - # Define this method because some plugins were monkey patching it. - # Remove this after 3.2 is out with the other deprecations in this class. - def status_code(*) - end - def render_exception(env, exception) wrapper = ExceptionWrapper.new(env, exception) status = wrapper.status_code diff --git a/actionpack/lib/action_dispatch/routing/route_set.rb b/actionpack/lib/action_dispatch/routing/route_set.rb index 9d0a3e9993..2c21887220 100644 --- a/actionpack/lib/action_dispatch/routing/route_set.rb +++ b/actionpack/lib/action_dispatch/routing/route_set.rb @@ -533,7 +533,6 @@ module ActionDispatch end def url_for(options) - finalize! options = (options || {}).reverse_merge!(default_url_options) handle_positional_args(options) @@ -559,7 +558,6 @@ module ActionDispatch end def call(env) - finalize! @router.call(env) end diff --git a/actionpack/lib/action_view/base.rb b/actionpack/lib/action_view/base.rb index 66a5d59857..08149df423 100644 --- a/actionpack/lib/action_view/base.rb +++ b/actionpack/lib/action_view/base.rb @@ -1,10 +1,8 @@ require 'active_support/core_ext/module/attr_internal' require 'active_support/core_ext/module/delegation' require 'active_support/core_ext/class/attribute' -require 'active_support/core_ext/array/wrap' require 'active_support/ordered_options' require 'action_view/log_subscriber' -require 'active_support/core_ext/module/deprecation' module ActionView #:nodoc: # = Action View Base @@ -160,7 +158,7 @@ module ActionView #:nodoc: def process_view_paths(value) value.is_a?(PathSet) ? - value.dup : ActionView::PathSet.new(Array.wrap(value)) + value.dup : ActionView::PathSet.new(Array(value)) end deprecate :process_view_paths diff --git a/actionpack/lib/action_view/helpers/form_helper.rb b/actionpack/lib/action_view/helpers/form_helper.rb index 1e4bebeee7..fdddb33c31 100644 --- a/actionpack/lib/action_view/helpers/form_helper.rb +++ b/actionpack/lib/action_view/helpers/form_helper.rb @@ -1091,7 +1091,7 @@ module ActionView else add_default_name_and_id(options) end - hidden = tag("input", "name" => options["name"], "type" => "hidden", "value" => options['disabled'] && checked ? checked_value : unchecked_value) + hidden = unchecked_value ? tag("input", "name" => options["name"], "type" => "hidden", "value" => unchecked_value, "disabled" => options["disabled"]) : "" checkbox = tag("input", options) hidden + checkbox end diff --git a/actionpack/lib/action_view/helpers/form_options_helper.rb b/actionpack/lib/action_view/helpers/form_options_helper.rb index 3ee0d8ebc5..ba9ff1d5aa 100644 --- a/actionpack/lib/action_view/helpers/form_options_helper.rb +++ b/actionpack/lib/action_view/helpers/form_options_helper.rb @@ -134,7 +134,7 @@ module ActionView # # ==== Gotcha # - # The HTML specification says when +multiple+ parameter passed to select and all options got deselected + # The HTML specification says when +multiple+ parameter passed to select and all options got deselected # web browsers do not send any value to server. Unfortunately this introduces a gotcha: # if an +User+ model has many +roles+ and have +role_ids+ accessor, and in the form that edits roles of the user # the user deselects all roles from +role_ids+ multiple select box, no +role_ids+ parameter is sent. So, @@ -322,8 +322,8 @@ module ActionView def options_for_select(container, selected = nil) return container if String === container - selected, disabled = extract_selected_and_disabled(selected).map do | r | - Array.wrap(r).map { |item| item.to_s } + selected, disabled = extract_selected_and_disabled(selected).map do |r| + Array(r).map { |item| item.to_s } end container.map do |element| @@ -333,7 +333,6 @@ module ActionView disabled_attribute = ' disabled="disabled"' if disabled && option_value_selected?(value, disabled) %(<option value="#{ERB::Util.html_escape(value)}"#{selected_attribute}#{disabled_attribute}#{html_attributes}>#{ERB::Util.html_escape(text)}</option>) end.join("\n").html_safe - end # Returns a string of option tags that have been compiled by iterating over the +collection+ and assigning the @@ -508,9 +507,9 @@ module ActionView convert_zones = lambda { |list| list.map { |z| [ z.to_s, z.name ] } } if priority_zones - if priority_zones.is_a?(Regexp) + if priority_zones.is_a?(Regexp) priority_zones = model.all.find_all {|z| z =~ priority_zones} - end + end zone_options += options_for_select(convert_zones[priority_zones], selected) zone_options += "<option value=\"\" disabled=\"disabled\">-------------</option>\n" @@ -558,7 +557,8 @@ module ActionView else selected = Array.wrap(selected) options = selected.extract_options!.symbolize_keys - [ options.include?(:selected) ? options[:selected] : selected, options[:disabled] ] + selected_items = options.include?(:selected) ? options[:selected] : selected + [ selected_items, options[:disabled] ] end end @@ -629,7 +629,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"] - tag("input", :disabled => html_options["disabled"], :name => html_options["name"], :type => "hidden", :value => "") + select + tag("input", :disabled => html_options["disabled"], :name => html_options["name"], :type => "hidden", :value => "") + select else select end diff --git a/actionpack/lib/action_view/helpers/tag_helper.rb b/actionpack/lib/action_view/helpers/tag_helper.rb index 8c33ef09fa..93a3c40683 100644 --- a/actionpack/lib/action_view/helpers/tag_helper.rb +++ b/actionpack/lib/action_view/helpers/tag_helper.rb @@ -118,7 +118,7 @@ module ActionView # escape_once("<< Accept & Checkout") # # => "<< Accept & Checkout" def escape_once(html) - ActiveSupport::Multibyte.clean(html.to_s).gsub(/[\"><]|&(?!([a-zA-Z]+|(#\d+));)/) { |special| ERB::Util::HTML_ESCAPE[special] } + html.to_s.gsub(/[\"><]|&(?!([a-zA-Z]+|(#\d+));)/) { |special| ERB::Util::HTML_ESCAPE[special] } end private diff --git a/actionpack/lib/action_view/helpers/text_helper.rb b/actionpack/lib/action_view/helpers/text_helper.rb index 209360ee82..ce79a3da48 100644 --- a/actionpack/lib/action_view/helpers/text_helper.rb +++ b/actionpack/lib/action_view/helpers/text_helper.rb @@ -162,15 +162,15 @@ module ActionView options.reverse_merge!(:radius => 100, :omission => "...") phrase = Regexp.escape(phrase) - return unless found_pos = text.mb_chars =~ /(#{phrase})/i + return unless found_pos = text =~ /(#{phrase})/i start_pos = [ found_pos - options[:radius], 0 ].max - end_pos = [ [ found_pos + phrase.mb_chars.length + options[:radius] - 1, 0].max, text.mb_chars.length ].min + end_pos = [ [ found_pos + phrase.length + options[:radius] - 1, 0].max, text.length ].min prefix = start_pos > 0 ? options[:omission] : "" - postfix = end_pos < text.mb_chars.length - 1 ? options[:omission] : "" + postfix = end_pos < text.length - 1 ? options[:omission] : "" - prefix + text.mb_chars[start_pos..end_pos].strip + postfix + prefix + text[start_pos..end_pos].strip + postfix end # Attempts to pluralize the +singular+ word unless +count+ is 1. If diff --git a/actionpack/lib/action_view/lookup_context.rb b/actionpack/lib/action_view/lookup_context.rb index 3f07314dda..90d88ca967 100644 --- a/actionpack/lib/action_view/lookup_context.rb +++ b/actionpack/lib/action_view/lookup_context.rb @@ -1,4 +1,3 @@ -require 'active_support/core_ext/array/wrap' require 'active_support/core_ext/object/blank' require 'active_support/core_ext/module/remove_method' @@ -29,7 +28,7 @@ module ActionView end def #{name}=(value) - value = value.present? ? Array.wrap(value) : default_#{name} + value = value.present? ? Array(value) : default_#{name} _set_detail(:#{name}, value) if value != @details[:#{name}] end @@ -102,7 +101,7 @@ module ActionView # Whenever setting view paths, makes a copy so we can manipulate then in # instance objects as we wish. def view_paths=(paths) - @view_paths = ActionView::PathSet.new(Array.wrap(paths)) + @view_paths = ActionView::PathSet.new(Array(paths)) end def find(name, prefixes = [], partial = false, keys = [], options = {}) diff --git a/actionpack/lib/action_view/renderer/abstract_renderer.rb b/actionpack/lib/action_view/renderer/abstract_renderer.rb index 5a611e9f63..a588abcee3 100644 --- a/actionpack/lib/action_view/renderer/abstract_renderer.rb +++ b/actionpack/lib/action_view/renderer/abstract_renderer.rb @@ -12,16 +12,16 @@ module ActionView end protected - + def extract_details(options) details = {} @lookup_context.registered_details.each do |key| next unless value = options[key] - details[key] = Array.wrap(value) + details[key] = Array(value) end details end - + def instrument(name, options={}) ActiveSupport::Notifications.instrument("render_#{name}.action_view", options){ yield } end diff --git a/actionpack/lib/action_view/renderer/template_renderer.rb b/actionpack/lib/action_view/renderer/template_renderer.rb index 06148ccc98..f3abc6d533 100644 --- a/actionpack/lib/action_view/renderer/template_renderer.rb +++ b/actionpack/lib/action_view/renderer/template_renderer.rb @@ -1,5 +1,4 @@ require 'active_support/core_ext/object/try' -require 'active_support/core_ext/array/wrap' module ActionView class TemplateRenderer < AbstractRenderer #:nodoc: diff --git a/actionpack/lib/action_view/template.rb b/actionpack/lib/action_view/template.rb index 2d9fc3df7a..593eaa2abf 100644 --- a/actionpack/lib/action_view/template.rb +++ b/actionpack/lib/action_view/template.rb @@ -1,4 +1,3 @@ -require 'active_support/core_ext/array/wrap' require 'active_support/core_ext/object/blank' require 'active_support/core_ext/object/try' require 'active_support/core_ext/kernel/singleton_class' @@ -122,7 +121,7 @@ module ActionView @locals = details[:locals] || [] @virtual_path = details[:virtual_path] @updated_at = details[:updated_at] || Time.now - @formats = Array.wrap(format).map { |f| f.is_a?(Mime::Type) ? f.ref : f } + @formats = Array(format).map { |f| f.is_a?(Mime::Type) ? f.ref : f } end # Returns if the underlying handler supports streaming. If so, diff --git a/actionpack/lib/action_view/template/error.rb b/actionpack/lib/action_view/template/error.rb index 587e37a84f..83df2604bb 100644 --- a/actionpack/lib/action_view/template/error.rb +++ b/actionpack/lib/action_view/template/error.rb @@ -1,4 +1,3 @@ -require "active_support/core_ext/array/wrap" require "active_support/core_ext/enumerable" module ActionView @@ -30,7 +29,7 @@ module ActionView def initialize(paths, path, prefixes, partial, details, *) @path = path - prefixes = Array.wrap(prefixes) + prefixes = Array(prefixes) template_type = if partial "partial" elsif path =~ /layouts/i diff --git a/actionpack/lib/sprockets/assets.rake b/actionpack/lib/sprockets/assets.rake index a61a121d55..43405f3db9 100644 --- a/actionpack/lib/sprockets/assets.rake +++ b/actionpack/lib/sprockets/assets.rake @@ -1,12 +1,12 @@ require "fileutils" namespace :assets do - def ruby_rake_task(task) + def ruby_rake_task(task, fork = true) env = ENV['RAILS_ENV'] || 'production' groups = ENV['RAILS_GROUPS'] || 'assets' args = [$0, task,"RAILS_ENV=#{env}","RAILS_GROUPS=#{groups}"] args << "--trace" if Rake.application.options.trace - ruby(*args) + fork ? ruby(*args) : Kernel.exec(FileUtils::RUBY, *args) end # We are currently running with no explicit bundler group @@ -59,7 +59,7 @@ namespace :assets do # required in order to compile digestless assets as the # environment has already cached the assets on the primary # run. - ruby_rake_task "assets:precompile:nondigest" if Rails.application.config.assets.digest + ruby_rake_task("assets:precompile:nondigest", false) if Rails.application.config.assets.digest end task :primary => ["assets:environment", "tmp:cache:clear"] do diff --git a/actionpack/test/abstract/translation_test.rb b/actionpack/test/abstract/translation_test.rb index 8ec50fd57a..0194ee943f 100644 --- a/actionpack/test/abstract/translation_test.rb +++ b/actionpack/test/abstract/translation_test.rb @@ -3,7 +3,7 @@ require 'abstract_unit' # class TranslatingController < ActionController::Base # end -class TranslationControllerTest < Test::Unit::TestCase +class TranslationControllerTest < ActiveSupport::TestCase def setup @controller = ActionController::Base.new end @@ -23,4 +23,4 @@ class TranslationControllerTest < Test::Unit::TestCase def test_action_controller_base_responds_to_l assert_respond_to @controller, :l end -end
\ No newline at end of file +end diff --git a/actionpack/test/abstract_unit.rb b/actionpack/test/abstract_unit.rb index 63109d592a..a875a9f8b0 100644 --- a/actionpack/test/abstract_unit.rb +++ b/actionpack/test/abstract_unit.rb @@ -254,7 +254,7 @@ class Rack::TestCase < ActionDispatch::IntegrationTest end def assert_body(body) - assert_equal body, Array.wrap(response.body).join + assert_equal body, Array(response.body).join end def assert_status(code) @@ -262,7 +262,7 @@ class Rack::TestCase < ActionDispatch::IntegrationTest end def assert_response(body, status = 200, headers = {}) - assert_body body + assert_body body assert_status status headers.each do |header, value| assert_header header, value diff --git a/actionpack/test/controller/action_pack_assertions_test.rb b/actionpack/test/controller/action_pack_assertions_test.rb index bdbf158b36..01cafe1aca 100644 --- a/actionpack/test/controller/action_pack_assertions_test.rb +++ b/actionpack/test/controller/action_pack_assertions_test.rb @@ -338,7 +338,7 @@ class ActionPackAssertionsControllerTest < ActionController::TestCase end def test_render_based_on_parameters - process :render_based_on_parameters, "name" => "David" + process :render_based_on_parameters, "GET", "name" => "David" assert_equal "Mr. David", @response.body end diff --git a/actionpack/test/controller/base_test.rb b/actionpack/test/controller/base_test.rb index a4f858d06d..c5c48bc559 100644 --- a/actionpack/test/controller/base_test.rb +++ b/actionpack/test/controller/base_test.rb @@ -106,7 +106,7 @@ class ControllerClassTests < ActiveSupport::TestCase end end -class ControllerInstanceTests < Test::Unit::TestCase +class ControllerInstanceTests < ActiveSupport::TestCase def setup @empty = EmptyController.new @contained = Submodule::ContainedEmptyController.new diff --git a/actionpack/test/controller/content_type_test.rb b/actionpack/test/controller/content_type_test.rb index d51882066d..a312b7c32a 100644 --- a/actionpack/test/controller/content_type_test.rb +++ b/actionpack/test/controller/content_type_test.rb @@ -59,7 +59,7 @@ class ContentTypeTest < ActionController::TestCase super # enable a logger so that (e.g.) the benchmarking stuff runs, so we can get # a more accurate simulation of what happens in "real life". - @controller.logger = Logger.new(nil) + @controller.logger = ActiveSupport::Logger.new(nil) end # :ported: diff --git a/actionpack/test/controller/integration_test.rb b/actionpack/test/controller/integration_test.rb index 2ad95f5c29..a328372cff 100644 --- a/actionpack/test/controller/integration_test.rb +++ b/actionpack/test/controller/integration_test.rb @@ -2,7 +2,7 @@ require 'abstract_unit' require 'controller/fake_controllers' require 'action_controller/vendor/html-scanner' -class SessionTest < Test::Unit::TestCase +class SessionTest < ActiveSupport::TestCase StubApp = lambda { |env| [200, {"Content-Type" => "text/html", "Content-Length" => "13"}, ["Hello, World!"]] } @@ -165,7 +165,7 @@ class SessionTest < Test::Unit::TestCase end end -class IntegrationTestTest < Test::Unit::TestCase +class IntegrationTestTest < ActiveSupport::TestCase def setup @test = ::ActionDispatch::IntegrationTest.new(:app) @test.class.stubs(:fixture_table_names).returns([]) diff --git a/actionpack/test/controller/new_base/render_streaming_test.rb b/actionpack/test/controller/new_base/render_streaming_test.rb index 1532bd5c98..61ea68e3f7 100644 --- a/actionpack/test/controller/new_base/render_streaming_test.rb +++ b/actionpack/test/controller/new_base/render_streaming_test.rb @@ -85,7 +85,7 @@ module RenderStreaming test "rendering with template exception logs the exception" do io = StringIO.new - _old, ActionController::Base.logger = ActionController::Base.logger, Logger.new(io) + _old, ActionController::Base.logger = ActionController::Base.logger, ActiveSupport::Logger.new(io) begin get "/render_streaming/basic/template_exception" diff --git a/actionpack/test/controller/record_identifier_test.rb b/actionpack/test/controller/record_identifier_test.rb index f3e5ff8a47..eb38b81e85 100644 --- a/actionpack/test/controller/record_identifier_test.rb +++ b/actionpack/test/controller/record_identifier_test.rb @@ -1,7 +1,7 @@ require 'abstract_unit' require 'controller/fake_models' -class RecordIdentifierTest < Test::Unit::TestCase +class RecordIdentifierTest < ActiveSupport::TestCase include ActionController::RecordIdentifier def setup diff --git a/actionpack/test/controller/render_test.rb b/actionpack/test/controller/render_test.rb index 768cfb34ac..ec26315dc7 100644 --- a/actionpack/test/controller/render_test.rb +++ b/actionpack/test/controller/render_test.rb @@ -696,7 +696,7 @@ class RenderTest < ActionController::TestCase # enable a logger so that (e.g.) the benchmarking stuff runs, so we can get # a more accurate simulation of what happens in "real life". super - @controller.logger = Logger.new(nil) + @controller.logger = ActiveSupport::Logger.new(nil) @request.host = "www.nextangle.com" end @@ -907,7 +907,7 @@ class RenderTest < ActionController::TestCase def test_access_to_logger_in_view get :accessing_logger_in_template - assert_equal "Logger", @response.body + assert_equal "ActiveSupport::Logger", @response.body end # :ported: diff --git a/actionpack/test/controller/render_xml_test.rb b/actionpack/test/controller/render_xml_test.rb index ec4dc848ff..8b4f2f5349 100644 --- a/actionpack/test/controller/render_xml_test.rb +++ b/actionpack/test/controller/render_xml_test.rb @@ -48,7 +48,7 @@ class RenderXmlTest < ActionController::TestCase # enable a logger so that (e.g.) the benchmarking stuff runs, so we can get # a more accurate simulation of what happens in "real life". super - @controller.logger = Logger.new(nil) + @controller.logger = ActiveSupport::Logger.new(nil) @request.host = "www.nextangle.com" end diff --git a/actionpack/test/controller/routing_test.rb b/actionpack/test/controller/routing_test.rb index c9785d9b8a..bf33b8cdd7 100644 --- a/actionpack/test/controller/routing_test.rb +++ b/actionpack/test/controller/routing_test.rb @@ -12,7 +12,7 @@ end ROUTING = ActionDispatch::Routing # See RFC 3986, section 3.3 for allowed path characters. -class UriReservedCharactersRoutingTest < Test::Unit::TestCase +class UriReservedCharactersRoutingTest < ActiveSupport::TestCase include RoutingTestHelpers def setup @@ -72,7 +72,7 @@ class MockController end end -class LegacyRouteSetTests < Test::Unit::TestCase +class LegacyRouteSetTests < ActiveSupport::TestCase include RoutingTestHelpers attr_reader :rs diff --git a/actionpack/test/controller/runner_test.rb b/actionpack/test/controller/runner_test.rb index 24c220dcd5..3e9383abb2 100644 --- a/actionpack/test/controller/runner_test.rb +++ b/actionpack/test/controller/runner_test.rb @@ -2,7 +2,7 @@ require 'abstract_unit' require 'action_dispatch/testing/integration' module ActionDispatch - class RunnerTest < Test::Unit::TestCase + class RunnerTest < ActiveSupport::TestCase class MyRunner include Integration::Runner diff --git a/actionpack/test/controller/selector_test.rb b/actionpack/test/controller/selector_test.rb index 8ce9e43402..5e302da212 100644 --- a/actionpack/test/controller/selector_test.rb +++ b/actionpack/test/controller/selector_test.rb @@ -7,7 +7,7 @@ require 'abstract_unit' require 'controller/fake_controllers' require 'action_controller/vendor/html-scanner' -class SelectorTest < Test::Unit::TestCase +class SelectorTest < ActiveSupport::TestCase # # Basic selector: element, id, class, attributes. # diff --git a/actionpack/test/dispatch/reloader_test.rb b/actionpack/test/dispatch/reloader_test.rb index 3411bd14ea..e371c3b0c1 100644 --- a/actionpack/test/dispatch/reloader_test.rb +++ b/actionpack/test/dispatch/reloader_test.rb @@ -1,6 +1,6 @@ require 'abstract_unit' -class ReloaderTest < Test::Unit::TestCase +class ReloaderTest < ActiveSupport::TestCase Reloader = ActionDispatch::Reloader def test_prepare_callbacks diff --git a/actionpack/test/dispatch/request/json_params_parsing_test.rb b/actionpack/test/dispatch/request/json_params_parsing_test.rb index ad44b4b16a..ae425dd406 100644 --- a/actionpack/test/dispatch/request/json_params_parsing_test.rb +++ b/actionpack/test/dispatch/request/json_params_parsing_test.rb @@ -34,7 +34,7 @@ class JsonParamsParsingTest < ActionDispatch::IntegrationTest with_test_routing do output = StringIO.new json = "[\"person]\": {\"name\": \"David\"}}" - post "/parse", json, {'CONTENT_TYPE' => 'application/json', 'action_dispatch.show_exceptions' => true, 'action_dispatch.logger' => Logger.new(output)} + post "/parse", json, {'CONTENT_TYPE' => 'application/json', 'action_dispatch.show_exceptions' => true, 'action_dispatch.logger' => ActiveSupport::Logger.new(output)} assert_response :error output.rewind && err = output.read assert err =~ /Error occurred while parsing request parameters/ diff --git a/actionpack/test/dispatch/request/xml_params_parsing_test.rb b/actionpack/test/dispatch/request/xml_params_parsing_test.rb index 0984f00066..afd400c2a9 100644 --- a/actionpack/test/dispatch/request/xml_params_parsing_test.rb +++ b/actionpack/test/dispatch/request/xml_params_parsing_test.rb @@ -56,7 +56,7 @@ class XmlParamsParsingTest < ActionDispatch::IntegrationTest with_test_routing do output = StringIO.new xml = "<person><name>David</name><avatar type='file' name='me.jpg' content_type='image/jpg'>#{::Base64.encode64('ABC')}</avatar></pineapple>" - post "/parse", xml, default_headers.merge('action_dispatch.show_exceptions' => true, 'action_dispatch.logger' => Logger.new(output)) + post "/parse", xml, default_headers.merge('action_dispatch.show_exceptions' => true, 'action_dispatch.logger' => ActiveSupport::Logger.new(output)) assert_response :error output.rewind && err = output.read assert err =~ /Error occurred while parsing request parameters/ diff --git a/actionpack/test/dispatch/routing_test.rb b/actionpack/test/dispatch/routing_test.rb index d5c1586600..e5ed11d1ea 100644 --- a/actionpack/test/dispatch/routing_test.rb +++ b/actionpack/test/dispatch/routing_test.rb @@ -1443,10 +1443,10 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest def test_nested_optional_path_shorthand with_test_routes do get '/registrations/new' - assert @request.params[:locale].nil? + assert_nil @request.params[:locale] get '/en/registrations/new' - assert 'en', @request.params[:locale] + assert_equal 'en', @request.params[:locale] end end diff --git a/actionpack/test/template/compiled_templates_test.rb b/actionpack/test/template/compiled_templates_test.rb index 30d798d693..f5dc2fbb33 100644 --- a/actionpack/test/template/compiled_templates_test.rb +++ b/actionpack/test/template/compiled_templates_test.rb @@ -1,7 +1,7 @@ require 'abstract_unit' require 'controller/fake_models' -class CompiledTemplatesTest < Test::Unit::TestCase +class CompiledTemplatesTest < ActiveSupport::TestCase def setup # Clean up any details key cached to expose failures # that otherwise would appear just on isolated tests diff --git a/actionpack/test/template/date_helper_i18n_test.rb b/actionpack/test/template/date_helper_i18n_test.rb index d45215acfd..e3d3d5ff77 100644 --- a/actionpack/test/template/date_helper_i18n_test.rb +++ b/actionpack/test/template/date_helper_i18n_test.rb @@ -1,6 +1,6 @@ require 'abstract_unit' -class DateHelperDistanceOfTimeInWordsI18nTests < Test::Unit::TestCase +class DateHelperDistanceOfTimeInWordsI18nTests < ActiveSupport::TestCase include ActionView::Helpers::DateHelper attr_reader :request @@ -71,7 +71,7 @@ class DateHelperDistanceOfTimeInWordsI18nTests < Test::Unit::TestCase end end -class DateHelperSelectTagsI18nTests < Test::Unit::TestCase +class DateHelperSelectTagsI18nTests < ActiveSupport::TestCase include ActionView::Helpers::DateHelper attr_reader :request diff --git a/actionpack/test/template/erb_util_test.rb b/actionpack/test/template/erb_util_test.rb index 790ab1c74c..eba2ef64e0 100644 --- a/actionpack/test/template/erb_util_test.rb +++ b/actionpack/test/template/erb_util_test.rb @@ -1,7 +1,7 @@ require 'abstract_unit' require 'active_support/core_ext/object/inclusion' -class ErbUtilTest < Test::Unit::TestCase +class ErbUtilTest < ActiveSupport::TestCase include ERB::Util ERB::Util::HTML_ESCAPE.each do |given, expected| diff --git a/actionpack/test/template/form_helper_test.rb b/actionpack/test/template/form_helper_test.rb index 6fe4ce65cf..ad0cc41d69 100644 --- a/actionpack/test/template/form_helper_test.rb +++ b/actionpack/test/template/form_helper_test.rb @@ -65,7 +65,7 @@ class FormHelperTest < ActionView::TestCase def full_messages() [ "Author name can't be empty" ] end }.new end - def @post.id; 123; end + def @post.to_key; [123]; end def @post.id_before_type_cast; 123; end def @post.to_param; '123'; end @@ -374,6 +374,14 @@ class FormHelperTest < ActionView::TestCase ) end + def test_check_box_with_nil_unchecked_value + @post.secret = "on" + assert_dom_equal( + '<input checked="checked" id="post_secret" name="post[secret]" type="checkbox" value="on" />', + check_box("post", "secret", {}, "on", nil) + ) + end + def test_check_box_with_multiple_behavior @post.comment_ids = [2,3] assert_dom_equal( @@ -386,11 +394,10 @@ class FormHelperTest < ActionView::TestCase ) end - - def test_checkbox_disabled_still_submits_checked_value + def test_checkbox_disabled_disables_hidden_field assert_dom_equal( - '<input name="post[secret]" type="hidden" value="1" /><input checked="checked" disabled="disabled" id="post_secret" name="post[secret]" type="checkbox" value="1" />', - check_box("post", "secret", { :disabled => :true }) + '<input name="post[secret]" type="hidden" value="0" disabled="disabled"/><input checked="checked" disabled="disabled" id="post_secret" name="post[secret]" type="checkbox" value="1" />', + check_box("post", "secret", { :disabled => true }) ) end @@ -629,7 +636,7 @@ class FormHelperTest < ActionView::TestCase end def test_auto_index - pid = @post.id + pid = 123 assert_dom_equal( "<label for=\"post_#{pid}_title\">Title</label>", label("post[]", "title") @@ -655,7 +662,7 @@ class FormHelperTest < ActionView::TestCase end def test_auto_index_with_nil_id - pid = @post.id + pid = 123 assert_dom_equal( "<input name=\"post[#{pid}][title]\" size=\"30\" type=\"text\" value=\"Hello World\" />", text_field("post[]","title", :id => nil) @@ -868,6 +875,7 @@ class FormHelperTest < ActionView::TestCase def test_form_for_with_remote_without_html @post.persisted = false + def @post.to_key; nil; end form_for(@post, :remote => true) do |f| concat f.text_field(:title) concat f.text_area(:body) @@ -1017,6 +1025,7 @@ class FormHelperTest < ActionView::TestCase old_locale, I18n.locale = I18n.locale, :submit @post.persisted = false + def @post.to_key; nil; end form_for(@post) do |f| concat f.submit end @@ -2088,7 +2097,7 @@ class FormHelperTest < ActionView::TestCase def test_form_for_with_new_object post = Post.new post.persisted = false - def post.id() nil end + def post.to_key; nil; end form_for(post) do |f| end diff --git a/actionpack/test/template/html-scanner/cdata_node_test.rb b/actionpack/test/template/html-scanner/cdata_node_test.rb index 1822cc565a..9b58174641 100644 --- a/actionpack/test/template/html-scanner/cdata_node_test.rb +++ b/actionpack/test/template/html-scanner/cdata_node_test.rb @@ -1,6 +1,6 @@ require 'abstract_unit' -class CDATANodeTest < Test::Unit::TestCase +class CDATANodeTest < ActiveSupport::TestCase def setup @node = HTML::CDATA.new(nil, 0, 0, "<p>howdy</p>") end diff --git a/actionpack/test/template/html-scanner/document_test.rb b/actionpack/test/template/html-scanner/document_test.rb index 3db2fba783..17f045d549 100644 --- a/actionpack/test/template/html-scanner/document_test.rb +++ b/actionpack/test/template/html-scanner/document_test.rb @@ -1,6 +1,6 @@ require 'abstract_unit' -class DocumentTest < Test::Unit::TestCase +class DocumentTest < ActiveSupport::TestCase def test_handle_doctype doc = nil assert_nothing_raised do diff --git a/actionpack/test/template/html-scanner/node_test.rb b/actionpack/test/template/html-scanner/node_test.rb index f4b9b198e8..5b5d092036 100644 --- a/actionpack/test/template/html-scanner/node_test.rb +++ b/actionpack/test/template/html-scanner/node_test.rb @@ -1,6 +1,6 @@ require 'abstract_unit' -class NodeTest < Test::Unit::TestCase +class NodeTest < ActiveSupport::TestCase class MockNode def initialize(matched, value) diff --git a/actionpack/test/template/html-scanner/tag_node_test.rb b/actionpack/test/template/html-scanner/tag_node_test.rb index 3b72243e7d..a29d2d43d7 100644 --- a/actionpack/test/template/html-scanner/tag_node_test.rb +++ b/actionpack/test/template/html-scanner/tag_node_test.rb @@ -1,6 +1,6 @@ require 'abstract_unit' -class TagNodeTest < Test::Unit::TestCase +class TagNodeTest < ActiveSupport::TestCase def test_open_without_attributes node = tag("<tag>") assert_equal "tag", node.name diff --git a/actionpack/test/template/html-scanner/text_node_test.rb b/actionpack/test/template/html-scanner/text_node_test.rb index 6f61253ffa..cbcb9e78f0 100644 --- a/actionpack/test/template/html-scanner/text_node_test.rb +++ b/actionpack/test/template/html-scanner/text_node_test.rb @@ -1,6 +1,6 @@ require 'abstract_unit' -class TextNodeTest < Test::Unit::TestCase +class TextNodeTest < ActiveSupport::TestCase def setup @node = HTML::Text.new(nil, 0, 0, "hello, howdy, aloha, annyeong") end diff --git a/actionpack/test/template/html-scanner/tokenizer_test.rb b/actionpack/test/template/html-scanner/tokenizer_test.rb index bf45a7c2e3..1d59de23b6 100644 --- a/actionpack/test/template/html-scanner/tokenizer_test.rb +++ b/actionpack/test/template/html-scanner/tokenizer_test.rb @@ -1,6 +1,6 @@ require 'abstract_unit' -class TokenizerTest < Test::Unit::TestCase +class TokenizerTest < ActiveSupport::TestCase def test_blank tokenize "" diff --git a/actionpack/test/template/template_test.rb b/actionpack/test/template/template_test.rb index f9c228f0c3..3084527f70 100644 --- a/actionpack/test/template/template_test.rb +++ b/actionpack/test/template/template_test.rb @@ -37,7 +37,7 @@ class TestERBTemplate < ActiveSupport::TestCase end def logger - Logger.new(STDERR) + ActiveSupport::Logger.new(STDERR) end def my_buffer diff --git a/actionpack/test/template/text_helper_test.rb b/actionpack/test/template/text_helper_test.rb index 839bf900dc..aa185d9cb0 100644 --- a/actionpack/test/template/text_helper_test.rb +++ b/actionpack/test/template/text_helper_test.rb @@ -81,10 +81,6 @@ class TextHelperTest < ActionView::TestCase end def test_truncate_multibyte - # .mb_chars always returns a UTF-8 String. - # assert_equal "\354\225\210\353\205\225\355...", - # truncate("\354\225\210\353\205\225\355\225\230\354\204\270\354\232\224", :length => 10) - assert_equal "\354\225\204\353\246\254\353\236\221 \354\225\204\353\246\254 ...".force_encoding('UTF-8'), truncate("\354\225\204\353\246\254\353\236\221 \354\225\204\353\246\254 \354\225\204\353\235\274\353\246\254\354\230\244".force_encoding('UTF-8'), :length => 10) end @@ -231,8 +227,6 @@ class TextHelperTest < ActionView::TestCase def test_excerpt_with_utf8 assert_equal("...\357\254\203ciency could not be...".force_encoding('UTF-8'), excerpt("That's why e\357\254\203ciency could not be helped".force_encoding('UTF-8'), 'could', 8)) - # .mb_chars always returns UTF-8, even in 1.9. This is not great, but it's how it works. Let's work this out. - # assert_equal("...\203ciency could not be...", excerpt("That's why e\357\254\203ciency could not be helped".force_encoding("BINARY"), 'could', 8)) end def test_word_wrap diff --git a/actionpack/test/ts_isolated.rb b/actionpack/test/ts_isolated.rb index 5670d93613..cb775508ff 100644 --- a/actionpack/test/ts_isolated.rb +++ b/actionpack/test/ts_isolated.rb @@ -1,10 +1,12 @@ +$:.unshift(File.dirname(__FILE__)) $:.unshift(File.dirname(__FILE__) + '/../../activesupport/lib') require 'test/unit' require 'rbconfig' require 'active_support/core_ext/kernel/reporting' +require 'abstract_unit' -class TestIsolated < Test::Unit::TestCase +class TestIsolated < ActiveSupport::TestCase ruby = File.join(*RbConfig::CONFIG.values_at('bindir', 'RUBY_INSTALL_NAME')) Dir["#{File.dirname(__FILE__)}/{abstract,controller,dispatch,template}/**/*_test.rb"].each do |file| |