Remove deprecated :prefix option

This commit is contained in:
Andrew White 2016-11-13 23:08:13 +00:00
parent 2ff2b98032
commit dadba9ae57
3 changed files with 1 additions and 37 deletions

View File

@ -7,10 +7,6 @@ module ActiveSupport
self.validate_float = true
def convert
if opts.key?(:prefix)
ActiveSupport::Deprecation.warn("The :prefix option of `number_to_human_size` is deprecated and will be removed in Rails 5.1 with no replacement.")
end
@number = Float(number)
# for backwards compatibility with those that didn't add strip_insignificant_zeros to their locale files
@ -54,7 +50,7 @@ module ActiveSupport
end
def base
opts[:prefix] == :si ? 1000 : 1024
1024
end
end
end

View File

@ -287,21 +287,6 @@ class NumericExtFormattingTest < ActiveSupport::TestCase
assert_equal "10 Bytes", 10.to_s(:human_size)
end
def test_to_s__human_size_with_si_prefix
assert_deprecated do
assert_equal "3 Bytes", 3.14159265.to_s(:human_size, prefix: :si)
assert_equal "123 Bytes", 123.0.to_s(:human_size, prefix: :si)
assert_equal "123 Bytes", 123.to_s(:human_size, prefix: :si)
assert_equal "1.23 KB", 1234.to_s(:human_size, prefix: :si)
assert_equal "12.3 KB", 12345.to_s(:human_size, prefix: :si)
assert_equal "1.23 MB", 1234567.to_s(:human_size, prefix: :si)
assert_equal "1.23 GB", 1234567890.to_s(:human_size, prefix: :si)
assert_equal "1.23 TB", 1234567890123.to_s(:human_size, prefix: :si)
assert_equal "1.23 PB", 1234567890123456.to_s(:human_size, prefix: :si)
assert_equal "1.23 EB", 1234567890123456789.to_s(:human_size, prefix: :si)
end
end
def test_to_s__human_size_with_options_hash
assert_equal "1.2 MB", 1234567.to_s(:human_size, precision: 2)
assert_equal "3 Bytes", 3.14159265.to_s(:human_size, precision: 4)

View File

@ -244,23 +244,6 @@ module ActiveSupport
end
end
def test_number_to_human_size_with_si_prefix
assert_deprecated do
[@instance_with_helpers, TestClassWithClassNumberHelpers, ActiveSupport::NumberHelper].each do |number_helper|
assert_equal "3 Bytes", number_helper.number_to_human_size(3.14159265, prefix: :si)
assert_equal "123 Bytes", number_helper.number_to_human_size(123.0, prefix: :si)
assert_equal "123 Bytes", number_helper.number_to_human_size(123, prefix: :si)
assert_equal "1.23 KB", number_helper.number_to_human_size(1234, prefix: :si)
assert_equal "12.3 KB", number_helper.number_to_human_size(12345, prefix: :si)
assert_equal "1.23 MB", number_helper.number_to_human_size(1234567, prefix: :si)
assert_equal "1.23 GB", number_helper.number_to_human_size(1234567890, prefix: :si)
assert_equal "1.23 TB", number_helper.number_to_human_size(1234567890123, prefix: :si)
assert_equal "1.23 PB", number_helper.number_to_human_size(1234567890123456, prefix: :si)
assert_equal "1.23 EB", number_helper.number_to_human_size(1234567890123456789, prefix: :si)
end
end
end
def test_number_to_human_size_with_options_hash
[@instance_with_helpers, TestClassWithClassNumberHelpers, ActiveSupport::NumberHelper].each do |number_helper|
assert_equal "1.2 MB", number_helper.number_to_human_size(1234567, precision: 2)