aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/json_serialization_test.rb
Commit message (Collapse)AuthorAgeFilesLines
* Merge pull request #35891 from Shopify/schema-cache-deduplicationKasper Timm Hansen2019-06-191-1/+1
|\ | | | | Deduplicate various Active Record schema cache structures
| * Deduplicate various Active Record schema cache structuresJean Boussier2019-06-031-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | Real world database schemas contain a lot of duplicated data. Some column names like `id`, `created_at` etc can easily be repeated hundreds of times. Same for SqlTypeMetada, most database will contain only a limited number of possible combinations. This result in a lot of wasted memory. The idea here is to make these data sctructures immutable, use a registry to substitute similar instances with pre-existing ones.
* | Enable `Layout/EmptyLinesAroundAccessModifier` copRyuta Kamizono2019-06-131-1/+0
|/ | | | | | | | | | | We sometimes say "✂️ newline after `private`" in a code review (e.g. https://github.com/rails/rails/pull/18546#discussion_r23188776, https://github.com/rails/rails/pull/34832#discussion_r244847195). Now `Layout/EmptyLinesAroundAccessModifier` cop have new enforced style `EnforcedStyle: only_before` (https://github.com/rubocop-hq/rubocop/pull/7059). That cop and enforced style will reduce the our code review cost.
* Use respond_to test helpersDaniel Colson2018-01-251-1/+1
|
* Use frozen-string-literal in ActiveRecordKir Shatrov2017-07-191-0/+2
|
* Merge pull request #25564 from brewski/serializable_hash_fixSean Griffin2017-07-171-4/+2
|\ | | | | Correctly handle frozen options for ActiveRecord::Serialization#seria…
| * Correctly handle frozen options for ↵Brian Abreu2016-12-091-4/+2
| | | | | | | | ActiveRecord::Serialization#serializable_hash.
* | Revert "Merge pull request #29540 from kirs/rubocop-frozen-string"Matthew Draper2017-07-021-1/+0
| | | | | | | | | | This reverts commit 3420a14590c0e6915d8b6c242887f74adb4120f9, reversing changes made to afb66a5a598ce4ac74ad84b125a5abf046dcf5aa.
* | Enforce frozen string in RubocopKir Shatrov2017-07-011-0/+1
| |
* | Restore `fixtures :author_addresses`Ryuta Kamizono2017-04-271-1/+1
| | | | | | | | | | This change reverted in eac6f369 but it is needed for data integrity. See #25328.
* | Revert "Merge pull request #27636 from ↵Rafael Mendonça França2017-04-261-1/+1
| | | | | | | | | | | | | | | | | | mtsmfm/disable-referential-integrity-without-superuser-privilege-take-2" This reverts commit c1faca6333abe4b938b98fedc8d1f47b88209ecf, reversing changes made to 8c658a0ecc7f2b5fc015d424baf9edf6f3eb2b0b. See https://github.com/rails/rails/pull/27636#issuecomment-297534129
* | Use `SET CONSTRAINTS` for `disable_referential_integrity` without superuser ↵Fumiaki MATSUSHIMA2017-03-261-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | privileges (take 2) Re-create https://github.com/rails/rails/pull/21233 eeac6151a5 was reverted (127509c071b4) because it breaks tests. ---------------- ref: 72c1557254 - We must use `authors` fixture with `author_addresses` because of its foreign key constraint. - Tests require PostgreSQL >= 9.4.2 because it had a bug about `ALTER CONSTRAINTS` and fixed in 9.4.2.
* | Allow ActiveRecord::Base.as_json to accept a frozen HashIsaac Betesh2017-02-081-0/+11
| |
* | Revert "Merge pull request #21233 from ↵Rafael Mendonça França2017-01-031-1/+1
| | | | | | | | | | | | | | | | | | | | mtsmfm/disable-referential-integrity-without-superuser-privileges" This reverts commit eeac6151a55cb7d5f799e1ae33aa64a839cbc3aa, reversing changes made to 5c40239d3104543e70508360d27584a3e4dc5baf. Reason: Broke the isolated tests. https://travis-ci.org/rails/rails/builds/188721346
* | Merge pull request #21233 from ↵Rafael França2017-01-031-1/+1
|\ \ | | | | | | | | | | | | mtsmfm/disable-referential-integrity-without-superuser-privileges Use `SET CONSTRAINTS` for `disable_referential_integrity` without superuser privileges
| * | Use `SET CONSTRAINTS` for `disable_referential_integrity` without superuser ↵Fumiaki MATSUSHIMA2016-12-031-1/+1
| |/ | | | | | | | | | | | | | | | | privileges ref: 72c1557254 - We must use `authors` fixture with `author_addresses` because of its foreign key constraint. - Tests require PostgreSQL >= 9.4.2 because it had a bug about `ALTER CONSTRAINTS` and fixed in 9.4.2.
* / assert_equal takes expectation firstAkira Matsuda2016-12-261-1/+1
|/
* Add more rubocop rules about whitespacesRafael Mendonça França2016-10-291-3/+3
|
* improve error message when include assertions failMichael Grosser2016-09-161-5/+5
| | | | | | assert [1, 3].includes?(2) fails with unhelpful "Asserting failed" message assert_includes [1, 3], 2 fails with "Expected [1, 3] to include 2" which makes it easier to debug and more obvious what went wrong
* normalizes indentation and whitespace across the projectXavier Noria2016-08-061-8/+8
|
* modernizes hash syntax in activerecordXavier Noria2016-08-061-26/+26
|
* applies new string literal convention in activerecord/testXavier Noria2016-08-061-12/+12
| | | | | The current code base is not uniform. After some discussion, we have chosen to go with double quotes by default.
* 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