Created
May 14, 2011 02:36
-
-
Save AquaGeek/971851 to your computer and use it in GitHub Desktop.
Rails Lighthouse ticket #6744
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From 04fb78f610d17726857b39157a2f0dc56b39e800 Mon Sep 17 00:00:00 2001 | |
From: Jim Herzberg <jimmiesh@gmail.com> | |
Date: Mon, 25 Apr 2011 17:55:56 -0700 | |
Subject: [PATCH] Attributes with :string type should not be given the type passed in model serialization options. | |
--- | |
activemodel/lib/active_model/serializers/xml.rb | 2 +- | |
.../cases/serializers/xml_serialization_test.rb | 5 +++++ | |
2 files changed, 6 insertions(+), 1 deletions(-) | |
diff --git a/activemodel/lib/active_model/serializers/xml.rb b/activemodel/lib/active_model/serializers/xml.rb | |
index d4295e6..c2ade99 100644 | |
--- a/activemodel/lib/active_model/serializers/xml.rb | |
+++ b/activemodel/lib/active_model/serializers/xml.rb | |
@@ -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 | |
diff --git a/activemodel/test/cases/serializers/xml_serialization_test.rb b/activemodel/test/cases/serializers/xml_serialization_test.rb | |
index b6a2f88..b2c4a8b 100644 | |
--- a/activemodel/test/cases/serializers/xml_serialization_test.rb | |
+++ b/activemodel/test/cases/serializers/xml_serialization_test.rb | |
@@ -93,6 +93,11 @@ class XmlSerializationTest < ActiveModel::TestCase | |
assert_match %r{<name>aaron stack</name>}, @contact.to_xml | |
end | |
+ test "should serialize string correctly when type passed" do | |
+ xml = @contact.to_xml :type => 'Contact' | |
+ assert_match %r{<name>aaron stack</name>}, xml | |
+ end | |
+ | |
test "should serialize integer" do | |
assert_match %r{<age type="integer">25</age>}, @contact.to_xml | |
end | |
-- | |
1.7.3.5 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment