提交 98a412aa 编写于 作者: M Michael Koziarski

Add a :namespace option to AR::Base#to_xml [Koz]



git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@5130 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
上级 2caf4d5a
*SVN*
* Add a :namespace option to AR::Base#to_xml [Koz]
* Deprecation tests. Remove warnings for dynamic finders and for the foo_count method if it's also an attribute. [Jeremy Kemper]
* Mock Time.now for more accurate Touch mixin tests. #6213 [Dan Peterson]
......
......@@ -222,12 +222,17 @@ def add_tag(attribute)
end
def serialize
builder.tag!(root) do
args = [root]
if options[:namespace]
args << {:xmlns=>options[:namespace]}
end
builder.tag!(*args) do
add_attributes
add_includes
add_procs
end
end
end
alias_method :to_s, :serialize
......
......@@ -20,7 +20,13 @@ def test_should_serialize_default_root
assert_match %r{^<contact>}, @xml
assert_match %r{</contact>$}, @xml
end
def test_should_serialize_default_root_with_namespace
@xml = Contact.new.to_xml :namespace=>"http://xml.rubyonrails.org/contact"
assert_match %r{^<contact xmlns="http://xml.rubyonrails.org/contact">}, @xml
assert_match %r{</contact>$}, @xml
end
def test_should_serialize_custom_root
@xml = Contact.new.to_xml :root => 'xml_contact'
assert_match %r{^<xml-contact>}, @xml
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册