aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/json_serialization_test.rb
Commit message (Collapse)AuthorAgeFilesLines
* rewrite tests to have no side-effects on `include_root_in_json`.Yves Senn2013-03-041-33/+55
|
* Fix serializable_hash with xml generation and default :except optionCarlos Antonio da Silva2012-06-221-0/+15
| | | | | | | | | | | | | | | | | | | | | | | | When generating xml with a custom implementation of serializable_hash, if using the :except option, it was being overriden by the default AR implementation that attempts to ignore the inheritance column from STI automatically. So, if you have an implementation like this: def serializable_hash(options={}) super({ except: %w(some_attr) }.merge!(options)) end The :except option was correctly being used for :json generation, but not for :xml, because the options hash already contained the :except key with the inheritance column, thus overriding the customization. This commit fixes this problem by removing the :except logic from the xml serializer, that happened before calling serializable_hash. Since serializable_hash also does the same check for inheritance column, this logic was duplicated in both places, thus it's safe to remove it from xml serializer (see ActiveRecord::Serialization#serializable_hash). This is an attempt to solve issue #2498, that claims for a "Single transformation API for both xml and json representations".
* Add some coverage for AR serialization with serializable_hashCarlos Antonio da Silva2012-06-221-0/+32
| | | | | | ActiveRecord json/xml serialization should use as base serializable_hash, provided by ActiveModel. Add some more coverage around options :only and :except for both json and xml serialization.
* please use ruby -I lib:test path/to/test.rb, or export RUBY_OPTAaron Patterson2011-06-061-1/+1
|
* Refactor Active Record test connection setup. Please see the ↵Jon Leighton2011-06-041-1/+1
| | | | RUNNING_UNIT_TESTS file for details, but essentially you can now configure things in test/config.yml. You can also run tests directly via the command line, e.g. ruby path/to/test.rb (no rake needed, uses default db connection from test/config.yml). This will help us fix the CI by enabling us to isolate the different Rails versions to different databases.
* Failing test - JSON serialization shouldn't merge base opts into include opts.John Mileham2011-05-261-0/+9
|
* Fix broken testJon Leighton2010-10-191-1/+5
|
* Fix the tests (I have actually verified that these are also the 'right' ↵Jon Leighton2010-10-031-1/+1
| | | | fixes, rather than just making the tests pass again)
* fixed some issues with JSON encodingJakub Suder2010-09-071-0/+7
| | | | | | | | | | | - as_json in ActiveModel should return a hash and handle :only/:except/:methods options - Array and Hash should call as_json on their elements - json methods should not modify options argument [#5374 state:committed] Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
* Deletes trailing whitespaces (over text files only find * -type f -exec sed ↵Santiago Pastorino2010-08-141-1/+1
| | | | 's/[ \t]*$//' -i {} \;)
* enable AS::JSON.encode to encode AR::Relation by providing `as_json` methodMislav Marohnić2010-07-131-0/+7
| | | | | | [#5073 state:resolved] Signed-off-by: José Valim <jose.valim@gmail.com>
* Really make include_root_in_json default to true [#3770 state:resolved]José Valim2010-06-081-11/+8
|
* Reset class attribute after changing itEvan Phoenix2010-03-221-0/+2
|
* Fix AR json encodingJeremy Kemper2009-06-081-4/+4
|
* * Add pluggable JSON backends with support for the JSON gem. [rick]rick2009-04-231-56/+56
| | | | | | | | | | | | | | Example: ActiveSupport::JSON.backend = "JSONGem" All internal Rails JSON encoding is now handled by ActiveSupport::JSON.encode(). Use of #to_json is not recommended, as it may clash with other libraries that overwrite it. However, you can recover Rails specific functionality if you really want to use #to_json. gem 'json' ActiveSupport::JSON.backend = "JSONGem" class ActiveRecord::Base alias to_json rails_to_json end
* Fix the AR json serialization tests to comply with the earlier change to ↵Michael Koziarski2009-01-161-1/+1
| | | | quote keys correctly
* Tweak ActiveRecord::Base#to_json to include a root value in the returned ↵Rick Olson2008-04-011-0/+25
| | | | | | hash: {post: {title: ...}} [rick] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@9202 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* Merge branch 'ar-test-cleanup' of git://git.geeksomnia.com/railsJeremy Kemper2008-01-211-3/+3
| | | | git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8681 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* belongs_to supports :dependent => :destroy and :delete. Closes #10592.Jeremy Kemper2008-01-191-1/+1
| | | | git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8675 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* Fix pathsJeremy Kemper2008-01-181-6/+6
| | | | git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8661 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* Move tests to casesJeremy Kemper2008-01-181-0/+180
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8660 5ecf4fe2-1ee6-0310-87b1-e25e094e27de