Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
213e73dd
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,发现更多精彩内容 >>
提交
213e73dd
编写于
6月 22, 2014
作者:
Y
Yves Senn
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #15857 from zuhao/refactor_activesupport_encoding_test
Avoid hardcoded magic number in test teardown.
上级
0e9a7059
42b33590
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
19 addition
and
14 deletion
+19
-14
activesupport/test/json/encoding_test.rb
activesupport/test/json/encoding_test.rb
+19
-14
未找到文件。
activesupport/test/json/encoding_test.rb
浏览文件 @
213e73dd
...
...
@@ -494,31 +494,28 @@ def test_twz_to_json_with_use_standard_json_time_format_config_set_to_true
def
test_twz_to_json_with_custom_time_precision
with_standard_json_time_format
(
true
)
do
ActiveSupport
::
JSON
::
Encoding
.
time_precision
=
0
zone
=
ActiveSupport
::
TimeZone
[
'Eastern Time (US & Canada)'
]
time
=
ActiveSupport
::
TimeWithZone
.
new
(
Time
.
utc
(
2000
),
zone
)
assert_equal
"
\"
1999-12-31T19:00:00-05:00
\"
"
,
ActiveSupport
::
JSON
.
encode
(
time
)
with_time_precision
(
0
)
do
zone
=
ActiveSupport
::
TimeZone
[
'Eastern Time (US & Canada)'
]
time
=
ActiveSupport
::
TimeWithZone
.
new
(
Time
.
utc
(
2000
),
zone
)
assert_equal
"
\"
1999-12-31T19:00:00-05:00
\"
"
,
ActiveSupport
::
JSON
.
encode
(
time
)
end
end
ensure
ActiveSupport
::
JSON
::
Encoding
.
time_precision
=
3
end
def
test_time_to_json_with_custom_time_precision
with_standard_json_time_format
(
true
)
do
ActiveSupport
::
JSON
::
Encoding
.
time_precision
=
0
assert_equal
"
\"
2000-01-01T00:00:00Z
\"
"
,
ActiveSupport
::
JSON
.
encode
(
Time
.
utc
(
2000
))
with_time_precision
(
0
)
do
assert_equal
"
\"
2000-01-01T00:00:00Z
\"
"
,
ActiveSupport
::
JSON
.
encode
(
Time
.
utc
(
2000
))
end
end
ensure
ActiveSupport
::
JSON
::
Encoding
.
time_precision
=
3
end
def
test_datetime_to_json_with_custom_time_precision
with_standard_json_time_format
(
true
)
do
ActiveSupport
::
JSON
::
Encoding
.
time_precision
=
0
assert_equal
"
\"
2000-01-01T00:00:00+00:00
\"
"
,
ActiveSupport
::
JSON
.
encode
(
DateTime
.
new
(
2000
))
with_time_precision
(
0
)
do
assert_equal
"
\"
2000-01-01T00:00:00+00:00
\"
"
,
ActiveSupport
::
JSON
.
encode
(
DateTime
.
new
(
2000
))
end
end
ensure
ActiveSupport
::
JSON
::
Encoding
.
time_precision
=
3
end
def
test_twz_to_json_when_wrapping_a_date_time
...
...
@@ -539,4 +536,12 @@ def with_standard_json_time_format(boolean = true)
ensure
ActiveSupport
.
use_standard_json_time_format
=
old
end
def
with_time_precision
(
value
)
old_value
=
ActiveSupport
::
JSON
::
Encoding
.
time_precision
ActiveSupport
::
JSON
::
Encoding
.
time_precision
=
value
yield
ensure
ActiveSupport
::
JSON
::
Encoding
.
time_precision
=
old_value
end
end
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录