diff --git a/client/ruby/solrb/lib/solr/xml.rb b/client/ruby/solrb/lib/solr/xml.rb index fff1da640ee..626ecd295f3 100644 --- a/client/ruby/solrb/lib/solr/xml.rb +++ b/client/ruby/solrb/lib/solr/xml.rb @@ -31,7 +31,7 @@ begin # element.text = "blah" should work def text=(x) - self.content = x.to_s + self << x.to_s end end diff --git a/client/ruby/solrb/test/unit/field_test.rb b/client/ruby/solrb/test/unit/field_test.rb index e74abd71ace..ca8d3630654 100644 --- a/client/ruby/solrb/test/unit/field_test.rb +++ b/client/ruby/solrb/test/unit/field_test.rb @@ -21,6 +21,12 @@ class FieldTest < Test::Unit::TestCase assert_match(/Erik Hatcher<\/field>/, field.to_xml.to_s) end + def test_escaped_xml + field = Solr::Field.new :creator => 'Erik Hatcher & His Amazing Leaping Ability' + assert_kind_of Solr::XML::Element, field.to_xml + assert_match(/Erik Hatcher & His Amazing Leaping Ability<\/field>/, field.to_xml.to_s) + end + def test_xml_date field = Solr::Field.new :time => Time.now assert_kind_of Solr::XML::Element, field.to_xml