Normalize classify's argument to a String so that it plays nice with Symbols. [Marcel Molina Jr.]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4359 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
parent
213992195d
commit
f91096a543
|
@ -1,5 +1,7 @@
|
||||||
*SVN*
|
*SVN*
|
||||||
|
|
||||||
|
* Normalize classify's argument to a String so that it plays nice with Symbols. [Marcel Molina Jr.]
|
||||||
|
|
||||||
* Strip out leading schema name in classify. References #5139. [schoenm@earthlink.net]
|
* Strip out leading schema name in classify. References #5139. [schoenm@earthlink.net]
|
||||||
|
|
||||||
* Remove Enumerable#first_match since break(value) handles the use case well enough. [Nicholas Seckar]
|
* Remove Enumerable#first_match since break(value) handles the use case well enough. [Nicholas Seckar]
|
||||||
|
|
|
@ -147,7 +147,7 @@ module Inflector
|
||||||
|
|
||||||
def classify(table_name)
|
def classify(table_name)
|
||||||
# strip out any leading schema name
|
# strip out any leading schema name
|
||||||
camelize(singularize(table_name.sub(/.*\./, '')))
|
camelize(singularize(table_name.to_s.sub(/.*\./, '')))
|
||||||
end
|
end
|
||||||
|
|
||||||
def foreign_key(class_name, separate_class_name_and_id_with_underscore = true)
|
def foreign_key(class_name, separate_class_name_and_id_with_underscore = true)
|
||||||
|
|
|
@ -279,6 +279,12 @@ class InflectorTest < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_classify_with_symbol
|
||||||
|
assert_nothing_raised do
|
||||||
|
assert_equal 'FooBar', Inflector.classify(:foo_bar)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def test_humanize
|
def test_humanize
|
||||||
UnderscoreToHuman.each do |underscore, human|
|
UnderscoreToHuman.each do |underscore, human|
|
||||||
assert_equal(human, Inflector.humanize(underscore))
|
assert_equal(human, Inflector.humanize(underscore))
|
||||||
|
|
Loading…
Reference in New Issue