提交 dadba9ae 编写于 作者: A Andrew White

Remove deprecated :prefix option

上级 2ff2b980
......@@ -7,10 +7,6 @@ class NumberToHumanSizeConverter < NumberConverter #:nodoc:
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 @@ def smaller_than_base?
end
def base
opts[:prefix] == :si ? 1000 : 1024
1024
end
end
end
......
......@@ -287,21 +287,6 @@ def test_to_s__human_size
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)
......
......@@ -244,23 +244,6 @@ def test_number_number_to_human_size
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)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册