diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2013-05-17 12:01:30 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2013-05-17 12:01:30 -0700 |
commit | f796ed6088ab1e347fcfe573a6346d1235453156 (patch) | |
tree | 81c7e25d21ac4dd5f26bd3c6ca91f8d0be7c2cbf /activemodel/test/cases/serializers | |
parent | eaf54865b1313094ffca16aca1b199394bc58bae (diff) | |
parent | 677b64fcd527529390e232ceedf8fa8bfac224e2 (diff) | |
download | rails-f796ed6088ab1e347fcfe573a6346d1235453156.tar.gz rails-f796ed6088ab1e347fcfe573a6346d1235453156.tar.bz2 rails-f796ed6088ab1e347fcfe573a6346d1235453156.zip |
Merge branch 'master' into stmt
* master: (330 commits)
plugin new missing license spec
let Ruby do the is_a check for us
Mocha 0.14.0 was released with MT5 support. Switch back to gem
Fix named routing regression from 3.2.13
Revert "just call the class method since we know the callbacks are stored at the"
test refactor
Add more data to AR::UnknownAttributeError
Raise when multiple included blocks are defined
Revert "Integration tests support the OPTIONS http method"
restore whitespace in Gemfile between sqlite3 and sprockets
Revert "Add the options method to action_controller testcase."
Check if APP_RAKEFILE is defined
Fix detection of engine in rake db:load_config Broken by d1d7c86d0c8dcb7e75a87644b330c4e9e7d6c1c1
Remove trailing line break
tiny types should only be integers when the length is <= 1. fixes #10620
add failing test exposing mysql adapter tinyint bug
require things we need
Revert "Merge pull request #10600 from aditya-kapoor/code_refactor"
just call the class method since we know the callbacks are stored at the class level
this variable is used, so we don't have to use double assignments
...
Diffstat (limited to 'activemodel/test/cases/serializers')
-rw-r--r-- | activemodel/test/cases/serializers/json_serialization_test.rb | 2 | ||||
-rw-r--r-- | activemodel/test/cases/serializers/xml_serialization_test.rb | 54 |
2 files changed, 28 insertions, 28 deletions
diff --git a/activemodel/test/cases/serializers/json_serialization_test.rb b/activemodel/test/cases/serializers/json_serialization_test.rb index 9134c4980c..f0347081ee 100644 --- a/activemodel/test/cases/serializers/json_serialization_test.rb +++ b/activemodel/test/cases/serializers/json_serialization_test.rb @@ -91,7 +91,7 @@ class JsonSerializationTest < ActiveModel::TestCase end test "should allow attribute filtering with only" do - json = @contact.to_json(:only => [:name, :age]) + json = @contact.to_json(only: [:name, :age]) assert_match %r{"name":"Konata Izumi"}, json assert_match %r{"age":16}, json diff --git a/activemodel/test/cases/serializers/xml_serialization_test.rb b/activemodel/test/cases/serializers/xml_serialization_test.rb index 04ecf8a31b..901f42f29b 100644 --- a/activemodel/test/cases/serializers/xml_serialization_test.rb +++ b/activemodel/test/cases/serializers/xml_serialization_test.rb @@ -35,7 +35,7 @@ end class SerializableContact < Contact def serializable_hash(options={}) - super(options.merge(:only => [:name, :age])) + super(options.merge(only: [:name, :age])) end end @@ -70,33 +70,33 @@ class XmlSerializationTest < ActiveModel::TestCase end test "should serialize default root with namespace" do - @xml = @contact.to_xml :namespace => "http://xml.rubyonrails.org/contact" + @xml = @contact.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 test "should serialize custom root" do - @xml = @contact.to_xml :root => 'xml_contact' + @xml = @contact.to_xml root: 'xml_contact' assert_match %r{^<xml-contact>}, @xml assert_match %r{</xml-contact>$}, @xml end test "should allow undasherized tags" do - @xml = @contact.to_xml :root => 'xml_contact', :dasherize => false + @xml = @contact.to_xml root: 'xml_contact', dasherize: false assert_match %r{^<xml_contact>}, @xml assert_match %r{</xml_contact>$}, @xml assert_match %r{<created_at}, @xml end test "should allow camelized tags" do - @xml = @contact.to_xml :root => 'xml_contact', :camelize => true + @xml = @contact.to_xml root: 'xml_contact', camelize: true assert_match %r{^<XmlContact>}, @xml assert_match %r{</XmlContact>$}, @xml assert_match %r{<CreatedAt}, @xml end test "should allow lower-camelized tags" do - @xml = @contact.to_xml :root => 'xml_contact', :camelize => :lower + @xml = @contact.to_xml root: 'xml_contact', camelize: :lower assert_match %r{^<xmlContact>}, @xml assert_match %r{</xmlContact>$}, @xml assert_match %r{<createdAt}, @xml @@ -114,7 +114,7 @@ class XmlSerializationTest < ActiveModel::TestCase end test "should allow skipped types" do - @xml = @contact.to_xml :skip_types => true + @xml = @contact.to_xml skip_types: true assert_match %r{<age>25</age>}, @xml end @@ -130,7 +130,7 @@ class XmlSerializationTest < ActiveModel::TestCase end test "should serialize nil" do - assert_match %r{<pseudonyms nil=\"true\"/>}, @contact.to_xml(:methods => :pseudonyms) + assert_match %r{<pseudonyms nil=\"true\"/>}, @contact.to_xml(methods: :pseudonyms) end test "should serialize integer" do @@ -146,11 +146,11 @@ class XmlSerializationTest < ActiveModel::TestCase end test "should serialize array" do - assert_match %r{<social type=\"array\">\s*<social>twitter</social>\s*<social>github</social>\s*</social>}, @contact.to_xml(:methods => :social) + assert_match %r{<social type=\"array\">\s*<social>twitter</social>\s*<social>github</social>\s*</social>}, @contact.to_xml(methods: :social) end test "should serialize hash" do - assert_match %r{<network>\s*<git type=\"symbol\">github</git>\s*</network>}, @contact.to_xml(:methods => :network) + assert_match %r{<network>\s*<git type=\"symbol\">github</git>\s*</network>}, @contact.to_xml(methods: :network) end test "should serialize yaml" do @@ -159,29 +159,29 @@ class XmlSerializationTest < ActiveModel::TestCase test "should call proc on object" do proc = Proc.new { |options| options[:builder].tag!('nationality', 'unknown') } - xml = @contact.to_xml(:procs => [ proc ]) + xml = @contact.to_xml(procs: [ proc ]) assert_match %r{<nationality>unknown</nationality>}, xml end test 'should supply serializable to second proc argument' do proc = Proc.new { |options, record| options[:builder].tag!('name-reverse', record.name.reverse) } - xml = @contact.to_xml(:procs => [ proc ]) + xml = @contact.to_xml(procs: [ proc ]) assert_match %r{<name-reverse>kcats noraa</name-reverse>}, xml end test "should serialize string correctly when type passed" do - xml = @contact.to_xml :type => 'Contact' + xml = @contact.to_xml type: 'Contact' assert_match %r{<contact type="Contact">}, xml assert_match %r{<name>aaron stack</name>}, xml end test "include option with singular association" do - xml = @contact.to_xml :include => :address, :indent => 0 - assert xml.include?(@contact.address.to_xml(:indent => 0, :skip_instruct => true)) + xml = @contact.to_xml include: :address, indent: 0 + assert xml.include?(@contact.address.to_xml(indent: 0, skip_instruct: true)) end test "include option with plural association" do - xml = @contact.to_xml :include => :friends, :indent => 0 + xml = @contact.to_xml include: :friends, indent: 0 assert_match %r{<friends type="array">}, xml assert_match %r{<friend type="Contact">}, xml end @@ -198,60 +198,60 @@ class XmlSerializationTest < ActiveModel::TestCase test "include option with ary" do @contact.friends = FriendList.new(@contact.friends) - xml = @contact.to_xml :include => :friends, :indent => 0 + xml = @contact.to_xml include: :friends, indent: 0 assert_match %r{<friends type="array">}, xml assert_match %r{<friend type="Contact">}, xml end test "multiple includes" do - xml = @contact.to_xml :indent => 0, :skip_instruct => true, :include => [ :address, :friends ] - assert xml.include?(@contact.address.to_xml(:indent => 0, :skip_instruct => true)) + xml = @contact.to_xml indent: 0, skip_instruct: true, include: [ :address, :friends ] + assert xml.include?(@contact.address.to_xml(indent: 0, skip_instruct: true)) assert_match %r{<friends type="array">}, xml assert_match %r{<friend type="Contact">}, xml end test "include with options" do - xml = @contact.to_xml :indent => 0, :skip_instruct => true, :include => { :address => { :only => :city } } + xml = @contact.to_xml indent: 0, skip_instruct: true, include: { address: { only: :city } } assert xml.include?(%(><address><city>Springfield</city></address>)) end test "propagates skip_types option to included associations" do - xml = @contact.to_xml :include => :friends, :indent => 0, :skip_types => true + xml = @contact.to_xml include: :friends, indent: 0, skip_types: true assert_match %r{<friends>}, xml assert_match %r{<friend>}, xml end test "propagates skip-types option to included associations and attributes" do - xml = @contact.to_xml :skip_types => true, :include => :address, :indent => 0 + xml = @contact.to_xml skip_types: true, include: :address, indent: 0 assert_match %r{<address>}, xml assert_match %r{<apt-number>}, xml end test "propagates camelize option to included associations and attributes" do - xml = @contact.to_xml :camelize => true, :include => :address, :indent => 0 + xml = @contact.to_xml camelize: true, include: :address, indent: 0 assert_match %r{<Address>}, xml assert_match %r{<AptNumber type="integer">}, xml end test "propagates dasherize option to included associations and attributes" do - xml = @contact.to_xml :dasherize => false, :include => :address, :indent => 0 + xml = @contact.to_xml dasherize: false, include: :address, indent: 0 assert_match %r{<apt_number type="integer">}, xml end test "don't propagate skip_types if skip_types is defined at the included association level" do - xml = @contact.to_xml :skip_types => true, :include => { :address => { :skip_types => false } }, :indent => 0 + xml = @contact.to_xml skip_types: true, include: { address: { skip_types: false } }, indent: 0 assert_match %r{<address>}, xml assert_match %r{<apt-number type="integer">}, xml end test "don't propagate camelize if camelize is defined at the included association level" do - xml = @contact.to_xml :camelize => true, :include => { :address => { :camelize => false } }, :indent => 0 + xml = @contact.to_xml camelize: true, include: { address: { camelize: false } }, indent: 0 assert_match %r{<address>}, xml assert_match %r{<apt-number type="integer">}, xml end test "don't propagate dasherize if dasherize is defined at the included association level" do - xml = @contact.to_xml :dasherize => false, :include => { :address => { :dasherize => true } }, :indent => 0 + xml = @contact.to_xml dasherize: false, include: { address: { dasherize: true } }, indent: 0 assert_match %r{<address>}, xml assert_match %r{<apt-number type="integer">}, xml end |