Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
dadba9ae
R
rails
项目概览
张重言
/
rails
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
rails
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
dadba9ae
编写于
11月 13, 2016
作者:
A
Andrew White
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Remove deprecated :prefix option
上级
2ff2b980
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
1 addition
and
37 deletion
+1
-37
activesupport/lib/active_support/number_helper/number_to_human_size_converter.rb
...e_support/number_helper/number_to_human_size_converter.rb
+1
-5
activesupport/test/core_ext/numeric_ext_test.rb
activesupport/test/core_ext/numeric_ext_test.rb
+0
-15
activesupport/test/number_helper_test.rb
activesupport/test/number_helper_test.rb
+0
-17
未找到文件。
activesupport/lib/active_support/number_helper/number_to_human_size_converter.rb
浏览文件 @
dadba9ae
...
...
@@ -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
...
...
activesupport/test/core_ext/numeric_ext_test.rb
浏览文件 @
dadba9ae
...
...
@@ -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
)
...
...
activesupport/test/number_helper_test.rb
浏览文件 @
dadba9ae
...
...
@@ -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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录