Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
a6d0e379
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,发现更多精彩内容 >>
提交
a6d0e379
编写于
5月 23, 2012
作者:
C
Carlos Antonio da Silva
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #6446 from acapilleri/mini_xml_4
Change xml type datetime to dateTime
上级
90d8c8a2
5646d65d
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
22 addition
and
19 deletion
+22
-19
activemodel/lib/active_model/serializers/xml.rb
activemodel/lib/active_model/serializers/xml.rb
+1
-1
activemodel/test/cases/serializers/xml_serialization_test.rb
activemodel/test/cases/serializers/xml_serialization_test.rb
+1
-1
activerecord/lib/active_record/serializers/xml_serializer.rb
activerecord/lib/active_record/serializers/xml_serializer.rb
+2
-2
activerecord/test/cases/xml_serialization_test.rb
activerecord/test/cases/xml_serialization_test.rb
+7
-7
activesupport/CHANGELOG.md
activesupport/CHANGELOG.md
+2
-0
activesupport/lib/active_support/core_ext/hash/conversions.rb
...vesupport/lib/active_support/core_ext/hash/conversions.rb
+2
-2
activesupport/lib/active_support/xml_mini.rb
activesupport/lib/active_support/xml_mini.rb
+5
-4
activesupport/test/core_ext/hash_ext_test.rb
activesupport/test/core_ext/hash_ext_test.rb
+2
-2
未找到文件。
activemodel/lib/active_model/serializers/xml.rb
浏览文件 @
a6d0e379
...
...
@@ -172,7 +172,7 @@ def add_procs
# <id type="integer">1</id>
# <name>David</name>
# <age type="integer">16</age>
# <created-at type="date
t
ime">2011-01-30T22:29:23Z</created-at>
# <created-at type="date
T
ime">2011-01-30T22:29:23Z</created-at>
# </user>
#
# The <tt>:only</tt> and <tt>:except</tt> options can be used to limit the attributes
...
...
activemodel/test/cases/serializers/xml_serialization_test.rb
浏览文件 @
a6d0e379
...
...
@@ -140,7 +140,7 @@ def setup
end
test
"should serialize datetime"
do
assert_match
%r{<created-at type=
\"
date
t
ime
\"
>2006-08-01T00:00:00Z</created-at>}
,
@contact
.
to_xml
assert_match
%r{<created-at type=
\"
date
T
ime
\"
>2006-08-01T00:00:00Z</created-at>}
,
@contact
.
to_xml
end
test
"should serialize boolean"
do
...
...
activerecord/lib/active_record/serializers/xml_serializer.rb
浏览文件 @
a6d0e379
...
...
@@ -18,8 +18,8 @@ module Serialization
# <id type="integer">1</id>
# <approved type="boolean">false</approved>
# <replies-count type="integer">0</replies-count>
# <bonus-time type="date
t
ime">2000-01-01T08:28:00+12:00</bonus-time>
# <written-on type="date
t
ime">2003-07-16T09:28:00+1200</written-on>
# <bonus-time type="date
T
ime">2000-01-01T08:28:00+12:00</bonus-time>
# <written-on type="date
T
ime">2003-07-16T09:28:00+1200</written-on>
# <content>Have a nice day</content>
# <author-email-address>david@loudthinking.com</author-email-address>
# <parent-id></parent-id>
...
...
activerecord/test/cases/xml_serialization_test.rb
浏览文件 @
a6d0e379
...
...
@@ -92,7 +92,7 @@ def test_should_serialize_binary
end
def
test_should_serialize_datetime
assert_match
%r{<created-at type=
\"
date
t
ime
\"
>2006-08-01T00:00:00Z</created-at>}
,
@xml
assert_match
%r{<created-at type=
\"
date
T
ime
\"
>2006-08-01T00:00:00Z</created-at>}
,
@xml
end
def
test_should_serialize_boolean
...
...
@@ -109,7 +109,7 @@ def test_should_serialize_datetime_with_timezone
timezone
,
Time
.
zone
=
Time
.
zone
,
"Pacific Time (US & Canada)"
toy
=
Toy
.
create
(
:name
=>
'Mickey'
,
:updated_at
=>
Time
.
utc
(
2006
,
8
,
1
))
assert_match
%r{<updated-at type=
\"
date
t
ime
\"
>2006-07-31T17:00:00-07:00</updated-at>}
,
toy
.
to_xml
assert_match
%r{<updated-at type=
\"
date
T
ime
\"
>2006-07-31T17:00:00-07:00</updated-at>}
,
toy
.
to_xml
ensure
Time
.
zone
=
timezone
end
...
...
@@ -118,7 +118,7 @@ def test_should_serialize_datetime_with_timezone_reloaded
timezone
,
Time
.
zone
=
Time
.
zone
,
"Pacific Time (US & Canada)"
toy
=
Toy
.
create
(
:name
=>
'Minnie'
,
:updated_at
=>
Time
.
utc
(
2006
,
8
,
1
)).
reload
assert_match
%r{<updated-at type=
\"
date
t
ime
\"
>2006-07-31T17:00:00-07:00</updated-at>}
,
toy
.
to_xml
assert_match
%r{<updated-at type=
\"
date
T
ime
\"
>2006-07-31T17:00:00-07:00</updated-at>}
,
toy
.
to_xml
ensure
Time
.
zone
=
timezone
end
...
...
@@ -152,7 +152,7 @@ def test_should_serialize_datetime
assert
%r{<created-at (.*)></created-at>}
.
match
(
@xml
)
attributes
=
$1
assert_match
%r{nil="true"}
,
attributes
assert_match
%r{type="date
t
ime"}
,
attributes
assert_match
%r{type="date
T
ime"}
,
attributes
end
def
test_should_serialize_boolean
...
...
@@ -188,7 +188,7 @@ def test_to_xml
assert_equal
"integer"
,
xml
.
elements
[
"//replies-count"
].
attributes
[
'type'
]
assert_equal
written_on_in_current_timezone
,
xml
.
elements
[
"//written-on"
].
text
assert_equal
"date
t
ime"
,
xml
.
elements
[
"//written-on"
].
attributes
[
'type'
]
assert_equal
"date
T
ime"
,
xml
.
elements
[
"//written-on"
].
attributes
[
'type'
]
assert_equal
"david@loudthinking.com"
,
xml
.
elements
[
"//author-email-address"
].
text
...
...
@@ -198,7 +198,7 @@ def test_to_xml
if
current_adapter?
(
:SybaseAdapter
)
assert_equal
last_read_in_current_timezone
,
xml
.
elements
[
"//last-read"
].
text
assert_equal
"date
t
ime"
,
xml
.
elements
[
"//last-read"
].
attributes
[
'type'
]
assert_equal
"date
T
ime"
,
xml
.
elements
[
"//last-read"
].
attributes
[
'type'
]
else
# Oracle enhanced adapter allows to define Date attributes in model class (see topic.rb)
assert_equal
"2004-04-15"
,
xml
.
elements
[
"//last-read"
].
text
...
...
@@ -211,7 +211,7 @@ def test_to_xml
assert_equal
"boolean"
,
xml
.
elements
[
"//approved"
].
attributes
[
'type'
]
assert_equal
bonus_time_in_current_timezone
,
xml
.
elements
[
"//bonus-time"
].
text
assert_equal
"date
t
ime"
,
xml
.
elements
[
"//bonus-time"
].
attributes
[
'type'
]
assert_equal
"date
T
ime"
,
xml
.
elements
[
"//bonus-time"
].
attributes
[
'type'
]
end
end
...
...
activesupport/CHANGELOG.md
浏览文件 @
a6d0e379
## Rails 4.0.0 (unreleased) ##
*
Changed xml type
`datetime`
to
`dateTime`
(with upper case letter
`T`
).
*Angelo Capilleri*
*
Add
`:instance_accessor`
option for
`class_attribute`
.
*Alexey Vakhov*
*
`constantize`
now looks in the ancestor chain.
*Marc-Andre Lafortune & Andrew White*
...
...
activesupport/lib/active_support/core_ext/hash/conversions.rb
浏览文件 @
a6d0e379
...
...
@@ -57,8 +57,8 @@ class Hash
# "TrueClass" => "boolean",
# "FalseClass" => "boolean",
# "Date" => "date",
# "DateTime" => "date
t
ime",
# "Time" => "date
t
ime"
# "DateTime" => "date
T
ime",
# "Time" => "date
T
ime"
# }
#
# By default the root node is "hash", but that's configurable via the <tt>:root</tt> option.
...
...
activesupport/lib/active_support/xml_mini.rb
浏览文件 @
a6d0e379
...
...
@@ -39,8 +39,8 @@ def content_type
"TrueClass"
=>
"boolean"
,
"FalseClass"
=>
"boolean"
,
"Date"
=>
"date"
,
"DateTime"
=>
"date
t
ime"
,
"Time"
=>
"date
t
ime"
,
"DateTime"
=>
"date
T
ime"
,
"Time"
=>
"date
T
ime"
,
"Array"
=>
"array"
,
"Hash"
=>
"hash"
}
unless
defined?
(
TYPE_NAMES
)
...
...
@@ -48,7 +48,7 @@ def content_type
FORMATTING
=
{
"symbol"
=>
Proc
.
new
{
|
symbol
|
symbol
.
to_s
},
"date"
=>
Proc
.
new
{
|
date
|
date
.
to_s
(
:db
)
},
"date
t
ime"
=>
Proc
.
new
{
|
time
|
time
.
xmlschema
},
"date
T
ime"
=>
Proc
.
new
{
|
time
|
time
.
xmlschema
},
"binary"
=>
Proc
.
new
{
|
binary
|
::
Base64
.
encode64
(
binary
)
},
"yaml"
=>
Proc
.
new
{
|
yaml
|
yaml
.
to_yaml
}
}
unless
defined?
(
FORMATTING
)
...
...
@@ -111,6 +111,7 @@ def to_tag(key, value, options)
type_name
||=
TYPE_NAMES
[
value
.
class
.
name
]
type_name
||=
value
.
class
.
name
if
value
&&
!
value
.
respond_to?
(
:to_str
)
type_name
=
type_name
.
to_s
if
type_name
type_name
=
"dateTime"
if
type_name
==
"datetime"
key
=
rename_key
(
key
.
to_s
,
options
)
...
...
@@ -145,7 +146,7 @@ def _dasherize(key)
"
#{
left
}#{
middle
.
tr
(
'_ '
,
'--'
)
}#{
right
}
"
end
# TODO: Add support for other encodings
# TODO: Add support for other encodings
def
_parse_binary
(
bin
,
entity
)
#:nodoc:
case
entity
[
'encoding'
]
when
'base64'
...
...
activesupport/test/core_ext/hash_ext_test.rb
浏览文件 @
a6d0e379
...
...
@@ -672,8 +672,8 @@ def test_timezoned_attributes
:created_at
=>
Time
.
utc
(
1999
,
2
,
2
),
:local_created_at
=>
Time
.
utc
(
1999
,
2
,
2
).
in_time_zone
(
'Eastern Time (US & Canada)'
)
}.
to_xml
(
@xml_options
)
assert_match
%r{<created-at type=
\"
date
t
ime
\"
>1999-02-02T00:00:00Z</created-at>}
,
xml
assert_match
%r{<local-created-at type=
\"
date
t
ime
\"
>1999-02-01T19:00:00-05:00</local-created-at>}
,
xml
assert_match
%r{<created-at type=
\"
date
T
ime
\"
>1999-02-02T00:00:00Z</created-at>}
,
xml
assert_match
%r{<local-created-at type=
\"
date
T
ime
\"
>1999-02-01T19:00:00-05:00</local-created-at>}
,
xml
end
def
test_multiple_records_from_xml_with_attributes_other_than_type_ignores_them_without_exploding
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录