1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Remove deprecated separator argument from parameterize

This commit is contained in:
Andrew White 2016-11-14 12:14:23 +00:00
parent 90520d2eee
commit 0189f4db6f
5 changed files with 6 additions and 44 deletions

View file

@ -1,3 +1,7 @@
* Remove deprecated separator argument from `parameterize`
*Andrew White*
* Remove deprecated method `Numeric#to_formatted_s`
*Andrew White*

View file

@ -178,11 +178,7 @@ class String
#
# <%= link_to(@person.name, person_path) %>
# # => <a href="/person/1-Donald-E-Knuth">Donald E. Knuth</a>
def parameterize(sep = :unused, separator: "-", preserve_case: false)
unless sep == :unused
ActiveSupport::Deprecation.warn("Passing the separator argument as a positional parameter is deprecated and will soon be removed. Use `separator: '#{sep}'` instead.")
separator = sep
end
def parameterize(separator: "-", preserve_case: false)
ActiveSupport::Inflector.parameterize(self, separator: separator, preserve_case: preserve_case)
end

View file

@ -78,11 +78,7 @@ module ActiveSupport
# parameterize("Donald E. Knuth", preserve_case: true) # => "Donald-E-Knuth"
# parameterize("^trés|Jolie-- ", preserve_case: true) # => "tres-Jolie"
#
def parameterize(string, sep = :unused, separator: "-", preserve_case: false)
unless sep == :unused
ActiveSupport::Deprecation.warn("Passing the separator argument as a positional parameter is deprecated and will soon be removed. Use `separator: '#{sep}'` instead.")
separator = sep
end
def parameterize(string, separator: "-", preserve_case: false)
# Replace accented chars with their ASCII equivalents.
parameterized_string = transliterate(string)

View file

@ -168,14 +168,6 @@ class StringInflectionsTest < ActiveSupport::TestCase
end
end
def test_string_parameterized_no_separator_deprecated
StringToParameterizeWithNoSeparator.each do |normal, slugged|
assert_deprecated(/Passing the separator argument as a positional parameter is deprecated and will soon be removed. Use `separator: ''` instead./i) do
assert_equal(normal.parameterize(""), slugged)
end
end
end
def test_string_parameterized_no_separator_preserve_case
StringToParameterizePreserveCaseWithNoSeparator.each do |normal, slugged|
assert_equal(normal.parameterize(separator: "", preserve_case: true), slugged)
@ -188,14 +180,6 @@ class StringInflectionsTest < ActiveSupport::TestCase
end
end
def test_string_parameterized_underscore_deprecated
StringToParameterizeWithUnderscore.each do |normal, slugged|
assert_deprecated(/Passing the separator argument as a positional parameter is deprecated and will soon be removed. Use `separator: '_'` instead./i) do
assert_equal(normal.parameterize("_"), slugged)
end
end
end
def test_string_parameterized_underscore_preserve_case
StringToParameterizePreserceCaseWithUnderscore.each do |normal, slugged|
assert_equal(normal.parameterize(separator: "_", preserve_case: true), slugged)

View file

@ -272,15 +272,6 @@ class InflectorTest < ActiveSupport::TestCase
end
end
def test_parameterize_with_custom_separator_deprecated
jruby_skip "UTF-8 to UTF8-MAC Converter is unavailable"
StringToParameterizeWithUnderscore.each do |some_string, parameterized_string|
assert_deprecated(/Passing the separator argument as a positional parameter is deprecated and will soon be removed. Use `separator: '_'` instead./i) do
assert_equal(parameterized_string, ActiveSupport::Inflector.parameterize(some_string, "_"))
end
end
end
def test_parameterize_with_multi_character_separator
jruby_skip "UTF-8 to UTF8-MAC Converter is unavailable"
StringToParameterized.each do |some_string, parameterized_string|
@ -288,15 +279,6 @@ class InflectorTest < ActiveSupport::TestCase
end
end
def test_parameterize_with_multi_character_separator_deprecated
jruby_skip "UTF-8 to UTF8-MAC Converter is unavailable"
StringToParameterized.each do |some_string, parameterized_string|
assert_deprecated(/Passing the separator argument as a positional parameter is deprecated and will soon be removed. Use `separator: '__sep__'` instead./i) do
assert_equal(parameterized_string.gsub("-", "__sep__"), ActiveSupport::Inflector.parameterize(some_string, "__sep__"))
end
end
end
def test_classify
ClassNameToTableName.each do |class_name, table_name|
assert_equal(class_name, ActiveSupport::Inflector.classify(table_name))