diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2006-08-03 17:19:45 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2006-08-03 17:19:45 +0000 |
commit | b5c2366569573c76ab9dcbf871a4a00b91d7f141 (patch) | |
tree | 9f1bda237673f1240a37396b1b607c7286e3de8d /activerecord | |
parent | 8085cbfd0898676ffaea2f2d1c2616e47a37e5e1 (diff) | |
download | rails-b5c2366569573c76ab9dcbf871a4a00b91d7f141.tar.gz rails-b5c2366569573c76ab9dcbf871a4a00b91d7f141.tar.bz2 rails-b5c2366569573c76ab9dcbf871a4a00b91d7f141.zip |
Fixed to_xml with :include misbehaviors when invoked on array of model instances (closes #5690) [alexkwolfe@gmail.com]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4652 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/CHANGELOG | 2 | ||||
-rw-r--r-- | activerecord/lib/active_record/xml_serialization.rb | 2 | ||||
-rwxr-xr-x | activerecord/test/base_test.rb | 13 |
3 files changed, 17 insertions, 0 deletions
diff --git a/activerecord/CHANGELOG b/activerecord/CHANGELOG index 70cf37a7ac..fddd3e2e4a 100644 --- a/activerecord/CHANGELOG +++ b/activerecord/CHANGELOG @@ -1,5 +1,7 @@ *SVN* +* Fixed to_xml with :include misbehaviors when invoked on array of model instances #5690 [alexkwolfe@gmail.com] + * Added support for conditions on Base.exists? #5689 [josh@joshpeek.com]. Examples: assert (Topic.exists?(:author_name => "David")) diff --git a/activerecord/lib/active_record/xml_serialization.rb b/activerecord/lib/active_record/xml_serialization.rb index c8a4e2526c..5324ae5a0a 100644 --- a/activerecord/lib/active_record/xml_serialization.rb +++ b/activerecord/lib/active_record/xml_serialization.rb @@ -199,6 +199,8 @@ module ActiveRecord #:nodoc: end end end + + options[:include] = include_associations end end diff --git a/activerecord/test/base_test.rb b/activerecord/test/base_test.rb index 93415911f9..d3f2840291 100755 --- a/activerecord/test/base_test.rb +++ b/activerecord/test/base_test.rb @@ -1299,6 +1299,19 @@ class BasicsTest < Test::Unit::TestCase assert xml.include?(%(<replies><reply>)) assert xml.include?(%(<title>The Second Topic's of the day</title>)) end + + def test_array_to_xml_including_has_one_association + xml = [ companies(:first_firm), companies(:rails_core) ].to_xml(:indent => 0, :skip_instruct => true, :include => :account) + assert xml.include?(companies(:first_firm).account.to_xml(:indent => 0, :skip_instruct => true)) + assert xml.include?(companies(:rails_core).account.to_xml(:indent => 0, :skip_instruct => true)) + end + + def test_array_to_xml_including_belongs_to_association + xml = [ companies(:first_client), companies(:second_client), companies(:another_client) ].to_xml(:indent => 0, :skip_instruct => true, :include => :firm) + assert xml.include?(companies(:first_client).to_xml(:indent => 0, :skip_instruct => true)) + assert xml.include?(companies(:second_client).firm.to_xml(:indent => 0, :skip_instruct => true)) + assert xml.include?(companies(:another_client).firm.to_xml(:indent => 0, :skip_instruct => true)) + end def test_to_xml_including_belongs_to_association xml = companies(:first_client).to_xml(:indent => 0, :skip_instruct => true, :include => :firm) |