Skip to content

Commit

Permalink
Test the serialized types of virtual columns in XML
Browse files Browse the repository at this point in the history
The previous tests were passing, because nothing ever looked at the
generated XML. What was previously being generated was
`<firstname type="NilClass">...`, which is not consistent with all other
cases where there is not a known type.
  • Loading branch information
Geoff Petrie & Sean Griffin authored and geopet committed Jun 1, 2014
1 parent 260c384 commit 29cbfa2
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
2 changes: 0 additions & 2 deletions activerecord/lib/active_record/serializers/xml_serializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,6 @@ def compute_type
super
elsif klass.columns_hash.key?(name)
klass.columns_hash[name].type
else
NilClass
end

{ :text => :string,
Expand Down
5 changes: 3 additions & 2 deletions activerecord/test/cases/xml_serialization_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -416,8 +416,9 @@ def test_should_produce_xml_for_methods_returning_array

def test_should_support_aliased_attributes
xml = Author.select("name as firstname").to_xml
array = Hash.from_xml(xml)['authors']
assert_equal array.size, array.select { |author| author.has_key? 'firstname' }.size
Author.all.each do |author|
assert xml.include?(%(<firstname>#{author.name}</firstname>)), xml
end
end

def test_array_to_xml_including_has_many_association
Expand Down

0 comments on commit 29cbfa2

Please sign in to comment.