aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--activesupport/CHANGELOG2
-rw-r--r--activesupport/lib/inflector.rb3
-rw-r--r--activesupport/test/inflector_test.rb10
3 files changed, 13 insertions, 2 deletions
diff --git a/activesupport/CHANGELOG b/activesupport/CHANGELOG
index cf9fc0a728..f0324acd0e 100644
--- a/activesupport/CHANGELOG
+++ b/activesupport/CHANGELOG
@@ -1,3 +1,5 @@
+* Fixed Inflector for words like "news" and "series" that are the same in plural and singular #603 [echion], #615 [marcenuc]
+
* Added Hash#stringify_keys and Hash#stringify_keys!
* Added IndifferentAccess as a way to wrap a hash by a symbol-based store that also can be accessed by string keys
diff --git a/activesupport/lib/inflector.rb b/activesupport/lib/inflector.rb
index a9b2f87be4..e09208dd4f 100644
--- a/activesupport/lib/inflector.rb
+++ b/activesupport/lib/inflector.rb
@@ -58,6 +58,7 @@ module Inflector
def plural_rules #:doc:
[
[/(x|ch|ss|sh)$/, '\1es'], # search, switch, fix, box, process, address
+ [/series$/, '\1series'],
[/([^aeiouy]|qu)ies$/, '\1y'],
[/([^aeiouy]|qu)y$/, '\1ies'], # query, ability, agency
[/(?:([^f])fe|([lr])f)$/, '\1\2ves'], # half, safe, wife
@@ -75,6 +76,7 @@ module Inflector
[
[/(x|ch|ss)es$/, '\1'],
[/movies$/, 'movie'],
+ [/series$/, 'series'],
[/([^aeiouy]|qu)ies$/, '\1y'],
[/([lr])ves$/, '\1f'],
[/([^f])ves$/, '\1fe'],
@@ -84,6 +86,7 @@ module Inflector
[/men$/, 'man'],
[/status$/, 'status'],
[/children$/, 'child'],
+ [/news$/, 'news'],
[/s$/, '']
]
end
diff --git a/activesupport/test/inflector_test.rb b/activesupport/test/inflector_test.rb
index cdab0f9ed0..083e7993dc 100644
--- a/activesupport/test/inflector_test.rb
+++ b/activesupport/test/inflector_test.rb
@@ -49,7 +49,13 @@ class InflectorTest < Test::Unit::TestCase
"day" => "days",
"comment" => "comments",
- "foobar" => "foobars"
+ "foobar" => "foobars",
+ "newsletter" => "newsletters",
+
+ "old_news" => "old_news",
+ "news" => "news",
+
+ "series" => "series"
}
CamelToUnderscore = {
@@ -162,4 +168,4 @@ class InflectorTest < Test::Unit::TestCase
assert_equal InflectorTest, Inflector.constantize("InflectorTest")
assert_raises(NameError) { Inflector.constantize("UnknownClass") }
end
-end \ No newline at end of file
+end