mirror of
https://github.com/github/rails.git
synced 2026-01-10 07:07:54 -05:00
Attributes with :string type should not be given the type passed in model serialization options. Closes #1058
This commit is contained in:
committed by
Josh Kalderimis
parent
3a5a378056
commit
fbf99653f1
@@ -25,7 +25,7 @@ module ActiveModel
|
||||
def decorations
|
||||
decorations = {}
|
||||
decorations[:encoding] = 'base64' if type == :binary
|
||||
decorations[:type] = type unless type == :string
|
||||
decorations[:type] = (type == :string) ? nil : type
|
||||
decorations[:nil] = true if value.nil?
|
||||
decorations
|
||||
end
|
||||
|
||||
@@ -92,7 +92,7 @@ class XmlSerializationTest < ActiveModel::TestCase
|
||||
test "should serialize string" do
|
||||
assert_match %r{<name>aaron stack</name>}, @contact.to_xml
|
||||
end
|
||||
|
||||
|
||||
test "should serialize nil" do
|
||||
assert_match %r{<pseudonyms nil=\"true\"></pseudonyms>}, @contact.to_xml(:methods => :pseudonyms)
|
||||
end
|
||||
@@ -132,4 +132,10 @@ class XmlSerializationTest < ActiveModel::TestCase
|
||||
xml = @contact.to_xml(:procs => [ proc ])
|
||||
assert_match %r{<name-reverse>kcats noraa</name-reverse>}, xml
|
||||
end
|
||||
|
||||
test "should serialize string correctly when type passed" do
|
||||
xml = @contact.to_xml :type => 'Contact'
|
||||
assert_match %r{<contact type="Contact">}, xml
|
||||
assert_match %r{<name>aaron stack</name>}, xml
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user