Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Changeset 6022

Show
Ignore:
Timestamp:
01/23/07 05:32:08 (2 years ago)
Author:
rick
Message:

Added test coverage for Inflector.inflections.clear. Closes #7179. [Rich Collins]. Remove unused code from Duration#inspect. Closes #7180. [Rich Collins]

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/activesupport/CHANGELOG

    r6019 r6022  
    11*SVN* 
     2 
     3* Remove unused code from Duration#inspect.  Closes #7180.  [Rich Collins] 
     4 
     5* Added test coverage for Inflector.inflections.clear.  Closes #7179. [Rich Collins] 
     6 
     7* ActiveSupport::Multibyte::Handlers::UTF8Handler should raise when a range and an integer are passed in (just like the native implementation).  Closes #7176 [Rich Collins] 
    28 
    39* A couple extra tests for #classify.  Closes #7273. [Josh Susser] 
  • trunk/activesupport/lib/active_support/duration.rb

    r5952 r6022  
    5656    def inspect #:nodoc: 
    5757      consolidated = parts.inject(Hash.new(0)) { |h,part| h[part.first] += part.last; h } 
    58       [:years, :months, :days, :hours, :minutes, :seconds].map do |length| 
     58      [:years, :months, :days, :minutes, :seconds].map do |length| 
    5959        n = consolidated[length] 
    6060        "#{n} #{n == 1 ? length.to_s.singularize : length.to_s}" if n.nonzero? 
  • trunk/activesupport/test/inflector_test.rb

    r6019 r6022  
    328328    end 
    329329  end 
     330   
     331  %w{plurals singulars uncountables}.each do |inflection_type| 
     332    class_eval " 
     333      def test_clear_#{inflection_type} 
     334        cached_values = Inflector.inflections.#{inflection_type} 
     335        Inflector.inflections.clear :#{inflection_type} 
     336        assert Inflector.inflections.#{inflection_type}.empty?, \"#{inflection_type} inflections should be empty after clear :#{inflection_type}\" 
     337        Inflector.inflections.instance_variable_set :@#{inflection_type}, cached_values 
     338      end 
     339    " 
     340  end 
     341   
     342  def test_clear_all 
     343    cached_values = Inflector.inflections.plurals, Inflector.inflections.singulars, Inflector.inflections.uncountables 
     344    Inflector.inflections.clear :all 
     345    assert Inflector.inflections.plurals.empty? 
     346    assert Inflector.inflections.singulars.empty? 
     347    assert Inflector.inflections.uncountables.empty? 
     348    Inflector.inflections.instance_variable_set :@plurals, cached_values[0] 
     349    Inflector.inflections.instance_variable_set :@singulars, cached_values[1] 
     350    Inflector.inflections.instance_variable_set :@uncountables, cached_values[2] 
     351  end 
     352   
     353  def test_clear_with_default 
     354    cached_values = Inflector.inflections.plurals, Inflector.inflections.singulars, Inflector.inflections.uncountables 
     355    Inflector.inflections.clear 
     356    assert Inflector.inflections.plurals.empty? 
     357    assert Inflector.inflections.singulars.empty? 
     358    assert Inflector.inflections.uncountables.empty? 
     359    Inflector.inflections.instance_variable_set :@plurals, cached_values[0] 
     360    Inflector.inflections.instance_variable_set :@singulars, cached_values[1] 
     361    Inflector.inflections.instance_variable_set :@uncountables, cached_values[2] 
     362  end 
    330363end