Merge pull request #6446 from acapilleri/mini_xml_4
Change xml type datetime to dateTime
This commit is contained in:
commit
a6d0e37957
|
@ -172,7 +172,7 @@ module ActiveModel
|
|||
# <id type="integer">1</id>
|
||||
# <name>David</name>
|
||||
# <age type="integer">16</age>
|
||||
# <created-at type="datetime">2011-01-30T22:29:23Z</created-at>
|
||||
# <created-at type="dateTime">2011-01-30T22:29:23Z</created-at>
|
||||
# </user>
|
||||
#
|
||||
# The <tt>:only</tt> and <tt>:except</tt> options can be used to limit the attributes
|
||||
|
|
|
@ -140,7 +140,7 @@ class XmlSerializationTest < ActiveModel::TestCase
|
|||
end
|
||||
|
||||
test "should serialize datetime" do
|
||||
assert_match %r{<created-at type=\"datetime\">2006-08-01T00:00:00Z</created-at>}, @contact.to_xml
|
||||
assert_match %r{<created-at type=\"dateTime\">2006-08-01T00:00:00Z</created-at>}, @contact.to_xml
|
||||
end
|
||||
|
||||
test "should serialize boolean" do
|
||||
|
|
|
@ -18,8 +18,8 @@ module ActiveRecord #:nodoc:
|
|||
# <id type="integer">1</id>
|
||||
# <approved type="boolean">false</approved>
|
||||
# <replies-count type="integer">0</replies-count>
|
||||
# <bonus-time type="datetime">2000-01-01T08:28:00+12:00</bonus-time>
|
||||
# <written-on type="datetime">2003-07-16T09:28:00+1200</written-on>
|
||||
# <bonus-time type="dateTime">2000-01-01T08:28:00+12:00</bonus-time>
|
||||
# <written-on type="dateTime">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>
|
||||
|
|
|
@ -92,7 +92,7 @@ class DefaultXmlSerializationTest < ActiveRecord::TestCase
|
|||
end
|
||||
|
||||
def test_should_serialize_datetime
|
||||
assert_match %r{<created-at type=\"datetime\">2006-08-01T00:00:00Z</created-at>}, @xml
|
||||
assert_match %r{<created-at type=\"dateTime\">2006-08-01T00:00:00Z</created-at>}, @xml
|
||||
end
|
||||
|
||||
def test_should_serialize_boolean
|
||||
|
@ -109,7 +109,7 @@ class DefaultXmlSerializationTimezoneTest < ActiveRecord::TestCase
|
|||
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=\"datetime\">2006-07-31T17:00:00-07:00</updated-at>}, toy.to_xml
|
||||
assert_match %r{<updated-at type=\"dateTime\">2006-07-31T17:00:00-07:00</updated-at>}, toy.to_xml
|
||||
ensure
|
||||
Time.zone = timezone
|
||||
end
|
||||
|
@ -118,7 +118,7 @@ class DefaultXmlSerializationTimezoneTest < ActiveRecord::TestCase
|
|||
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=\"datetime\">2006-07-31T17:00:00-07:00</updated-at>}, toy.to_xml
|
||||
assert_match %r{<updated-at type=\"dateTime\">2006-07-31T17:00:00-07:00</updated-at>}, toy.to_xml
|
||||
ensure
|
||||
Time.zone = timezone
|
||||
end
|
||||
|
@ -152,7 +152,7 @@ class NilXmlSerializationTest < ActiveRecord::TestCase
|
|||
assert %r{<created-at (.*)></created-at>}.match(@xml)
|
||||
attributes = $1
|
||||
assert_match %r{nil="true"}, attributes
|
||||
assert_match %r{type="datetime"}, attributes
|
||||
assert_match %r{type="dateTime"}, attributes
|
||||
end
|
||||
|
||||
def test_should_serialize_boolean
|
||||
|
@ -188,7 +188,7 @@ class DatabaseConnectedXmlSerializationTest < ActiveRecord::TestCase
|
|||
assert_equal "integer" , xml.elements["//replies-count"].attributes['type']
|
||||
|
||||
assert_equal written_on_in_current_timezone, xml.elements["//written-on"].text
|
||||
assert_equal "datetime" , xml.elements["//written-on"].attributes['type']
|
||||
assert_equal "dateTime" , xml.elements["//written-on"].attributes['type']
|
||||
|
||||
assert_equal "david@loudthinking.com", xml.elements["//author-email-address"].text
|
||||
|
||||
|
@ -198,7 +198,7 @@ class DatabaseConnectedXmlSerializationTest < ActiveRecord::TestCase
|
|||
|
||||
if current_adapter?(:SybaseAdapter)
|
||||
assert_equal last_read_in_current_timezone, xml.elements["//last-read"].text
|
||||
assert_equal "datetime" , xml.elements["//last-read"].attributes['type']
|
||||
assert_equal "dateTime" , 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 @@ class DatabaseConnectedXmlSerializationTest < ActiveRecord::TestCase
|
|||
assert_equal "boolean" , xml.elements["//approved"].attributes['type']
|
||||
|
||||
assert_equal bonus_time_in_current_timezone, xml.elements["//bonus-time"].text
|
||||
assert_equal "datetime" , xml.elements["//bonus-time"].attributes['type']
|
||||
assert_equal "dateTime" , xml.elements["//bonus-time"].attributes['type']
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
## 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*
|
||||
|
|
|
@ -57,8 +57,8 @@ class Hash
|
|||
# "TrueClass" => "boolean",
|
||||
# "FalseClass" => "boolean",
|
||||
# "Date" => "date",
|
||||
# "DateTime" => "datetime",
|
||||
# "Time" => "datetime"
|
||||
# "DateTime" => "dateTime",
|
||||
# "Time" => "dateTime"
|
||||
# }
|
||||
#
|
||||
# By default the root node is "hash", but that's configurable via the <tt>:root</tt> option.
|
||||
|
|
|
@ -39,8 +39,8 @@ module ActiveSupport
|
|||
"TrueClass" => "boolean",
|
||||
"FalseClass" => "boolean",
|
||||
"Date" => "date",
|
||||
"DateTime" => "datetime",
|
||||
"Time" => "datetime",
|
||||
"DateTime" => "dateTime",
|
||||
"Time" => "dateTime",
|
||||
"Array" => "array",
|
||||
"Hash" => "hash"
|
||||
} unless defined?(TYPE_NAMES)
|
||||
|
@ -48,7 +48,7 @@ module ActiveSupport
|
|||
FORMATTING = {
|
||||
"symbol" => Proc.new { |symbol| symbol.to_s },
|
||||
"date" => Proc.new { |date| date.to_s(:db) },
|
||||
"datetime" => Proc.new { |time| time.xmlschema },
|
||||
"dateTime" => 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 @@ module ActiveSupport
|
|||
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 @@ module ActiveSupport
|
|||
"#{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'
|
||||
|
|
|
@ -672,8 +672,8 @@ class HashToXmlTest < ActiveSupport::TestCase
|
|||
: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=\"datetime\">1999-02-02T00:00:00Z</created-at>}, xml
|
||||
assert_match %r{<local-created-at type=\"datetime\">1999-02-01T19:00:00-05:00</local-created-at>}, xml
|
||||
assert_match %r{<created-at type=\"dateTime\">1999-02-02T00:00:00Z</created-at>}, xml
|
||||
assert_match %r{<local-created-at type=\"dateTime\">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
|
||||
|
|
Loading…
Reference in New Issue