Permalink
Browse files

Added test coverage for Inflector.inflections.clear. Closes #7179. [R…

…ich Collins]. Remove unused code from Duration#inspect. Closes #7180.  [Rich Collins]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6022 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
1 parent a44cee2 commit be7f86e37ac21585ad2621e2e0938c68a7a71360 @technoweenie technoweenie committed Jan 23, 2007
Showing with 40 additions and 1 deletion.
  1. +6 −0 activesupport/CHANGELOG
  2. +1 −1 activesupport/lib/active_support/duration.rb
  3. +33 −0 activesupport/test/inflector_test.rb
View
@@ -1,5 +1,11 @@
*SVN*
+* Remove unused code from Duration#inspect. Closes #7180. [Rich Collins]
+
+* Added test coverage for Inflector.inflections.clear. Closes #7179. [Rich Collins]
+
+* ActiveSupport::Multibyte::Handlers::UTF8Handler should raise when a range and an integer are passed in (just like the native implementation). Closes #7176 [Rich Collins]
+
* A couple extra tests for #classify. Closes #7273. [Josh Susser]
* Better docs for Object extensions [zackchandler, Jamis Buck]
@@ -55,7 +55,7 @@ def ago(time = ::Time.now)
def inspect #:nodoc:
consolidated = parts.inject(Hash.new(0)) { |h,part| h[part.first] += part.last; h }
- [:years, :months, :days, :hours, :minutes, :seconds].map do |length|
+ [:years, :months, :days, :minutes, :seconds].map do |length|
n = consolidated[length]
"#{n} #{n == 1 ? length.to_s.singularize : length.to_s}" if n.nonzero?
end.compact.to_sentence
@@ -327,4 +327,37 @@ def test_underscore_to_lower_camel
assert_equal(lower_camel, Inflector.camelize(underscored, false))
end
end
+
+ %w{plurals singulars uncountables}.each do |inflection_type|
+ class_eval "
+ def test_clear_#{inflection_type}
+ cached_values = Inflector.inflections.#{inflection_type}
+ Inflector.inflections.clear :#{inflection_type}
+ assert Inflector.inflections.#{inflection_type}.empty?, \"#{inflection_type} inflections should be empty after clear :#{inflection_type}\"
+ Inflector.inflections.instance_variable_set :@#{inflection_type}, cached_values
+ end
+ "
+ end
+
+ def test_clear_all
+ cached_values = Inflector.inflections.plurals, Inflector.inflections.singulars, Inflector.inflections.uncountables
+ Inflector.inflections.clear :all
+ assert Inflector.inflections.plurals.empty?
+ assert Inflector.inflections.singulars.empty?
+ assert Inflector.inflections.uncountables.empty?
+ Inflector.inflections.instance_variable_set :@plurals, cached_values[0]
+ Inflector.inflections.instance_variable_set :@singulars, cached_values[1]
+ Inflector.inflections.instance_variable_set :@uncountables, cached_values[2]
+ end
+
+ def test_clear_with_default
+ cached_values = Inflector.inflections.plurals, Inflector.inflections.singulars, Inflector.inflections.uncountables
+ Inflector.inflections.clear
+ assert Inflector.inflections.plurals.empty?
+ assert Inflector.inflections.singulars.empty?
+ assert Inflector.inflections.uncountables.empty?
+ Inflector.inflections.instance_variable_set :@plurals, cached_values[0]
+ Inflector.inflections.instance_variable_set :@singulars, cached_values[1]
+ Inflector.inflections.instance_variable_set :@uncountables, cached_values[2]
+ end
end

1 comment on commit be7f86e

the change to activesupport/lib/active_support/duration.rb is not discussed in either of the referenced issues, and all it does is remove support for :hours. Why is that good? I understand it doesn't get a lot of use, but neither does the letter Q.

Please sign in to comment.