aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test/json
Commit message (Collapse)AuthorAgeFilesLines
* Enable `Layout/EmptyLinesAroundAccessModifier` copRyuta Kamizono2019-06-132-2/+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.
* Enable `Style/RedundantBegin` cop to avoid newly adding redundant begin blockRyuta Kamizono2018-12-211-13/+11
| | | | | | | | | | Currently we sometimes find a redundant begin block in code review (e.g. https://github.com/rails/rails/pull/33604#discussion_r209784205). I'd like to enable `Style/RedundantBegin` cop to avoid that, since rescue/else/ensure are allowed inside do/end blocks in Ruby 2.5 (https://bugs.ruby-lang.org/issues/12906), so we'd probably meets with that situation than before.
* Test that nested structs to_json works as expectedEileen Uchitelle2018-10-111-0/+10
| | | | | Check that options passed to the to_json are passed to all objects that respond to as_json.
* Remove unused `require "active_support/core_ext/regexp"`Ryuta Kamizono2018-07-291-1/+0
| | | | | | | | Ruby 2.4 has native `Regexp#match?`. https://ruby-doc.org/core-2.4.0/Regexp.html#method-i-match-3F Related #32034.
* Enable `Layout/SpaceBeforeComma` rubocop rule, and fixed moreRyuta Kamizono2017-12-121-3/+3
| | | | Follow up of #31390.
* Enable `Style/DefWithParentheses` rubocop ruleRyuta Kamizono2017-11-271-1/+1
| | | | | | | The def with blank `()` was newly added in #31176, but we have not used the blank `()` style in most part of our code base. So I've enabled `Style/DefWithParentheses` to prevent to newly added the code.
* Fix #to_json for unreadable IO objects, fixes #26132Paul Kuruvilla2017-10-231-0/+4
|
* Fix RuboCop offensesKoichi ITO2017-08-161-2/+2
| | | | And enable `context_dependent` of Style/BracesAroundHashParameters cop.
* [Active Support] `rubocop -a --only Layout/EmptyLineAfterMagicComment`Koichi ITO2017-07-113-0/+3
|
* Use frozen-string-literal in ActiveSupportKir Shatrov2017-07-093-0/+3
|
* Revert "Merge pull request #29540 from kirs/rubocop-frozen-string"Matthew Draper2017-07-023-3/+0
| | | | | This reverts commit 3420a14590c0e6915d8b6c242887f74adb4120f9, reversing changes made to afb66a5a598ce4ac74ad84b125a5abf046dcf5aa.
* Enforce frozen string in RubocopKir Shatrov2017-07-013-0/+3
|
* Add missing requiresAndrew White2017-02-221-0/+4
| | | | | Bundler 1.14.5 moved to lazily loading 'rubygems/spec_fetcher' which revealed some missing requires from the JSON encoding test file.
* Use appropriate assertion based on expectationCorey Ward2017-01-171-2/+7
| | | | | | | This resolves a stern Minitest “warning” about an upcoming behavior change in MiniTest 6 that will result in the test failing. https://github.com/seattlerb/minitest/issues/666
* class Foo < Struct.new(:x) creates an extra unneeded anonymous classAkira Matsuda2017-01-131-1/+1
| | | | because Struct.new returns a Class, we just can give it a name and use it directly without inheriting from it
* "Use assert_nil if expecting nil. This will fail in minitest 6."Akira Matsuda2016-12-251-1/+1
|
* Privatize unneededly protected methods in Active Support testsAkira Matsuda2016-12-241-1/+1
|
* Fix typo in constant referenceAndrew White2016-11-131-1/+1
|
* It's a NAN not InfinityAndrew White2016-11-131-1/+1
|
* Use literal values in assertionsAndrew White2016-11-131-6/+4
| | | | | Using the method you're testing to generate expected values can lead to bugs being masked.
* Fix an issue with JSON encoding of "Infinity" and "NaN" valuesPrathamesh Sonpatki2016-10-301-0/+22
| | | | | | | | | | | - When `as_json` returns `Infinity` or `NaN` as the value of any of the key, we don't used to call `as_json` on it as it was treated as primitive. - This used to pass `Infinity` or `NaN` to `JSON.generate` and Ruby used to throw an error for `Infinity/NaN not allowed in JSON.` - This patch changes the code to call `as_json` on these primitives so that they are converted to proper values before being passed to `JSON.generate`. - Fixes #26877.
* Add more rubocop rules about whitespacesRafael Mendonça França2016-10-293-30/+30
|
* Add three new rubocop rulesRafael Mendonça França2016-08-163-70/+70
| | | | | | | | Style/SpaceBeforeBlockBraces Style/SpaceInsideBlockBraces Style/SpaceInsideHashLiteralBraces Fix all violations in the repository.
* Add `Style/EmptyLines` in `.rubocop.yml` and remove extra empty linesRyuta Kamizono2016-08-071-1/+0
|
* applies remaining conventions across the projectXavier Noria2016-08-061-10/+10
|
* normalizes indentation and whitespace across the projectXavier Noria2016-08-061-8/+7
|
* remove redundant curlies from hash argumentsXavier Noria2016-08-061-1/+1
|
* modernizes hash syntax in activesupportXavier Noria2016-08-062-34/+34
|
* applies new string literal convention in activesupport/testXavier Noria2016-08-063-81/+81
| | | | | The current code base is not uniform. After some discussion, we have chosen to go with double quotes by default.
* systematic revision of =~ usage in ASXavier Noria2016-07-221-4/+10
| | | | | Where appropriate prefer the more concise Regexp#match?, String#include?, String#start_with?, and String#end_with?
* Define `Pathname#as_json`Ryunosuke Sato2016-06-251-0/+2
| | | | | | | | | | | | | | | | | When the Pathname object is converted as JSON, it should be a string that means itself. Expected: ``` >> Pathname.new('/path/to/somewhere.txt').as_json "/path/to/somewhere.txt" ``` Actual: ``` >> Pathname.new('/path/to/somewhere.txt').as_json {"path"=>"/path/to/somewhere.txt"} ```
* Define `URI::Generic#as_json`Ryunosuke Sato2016-06-251-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When the URI object is converted as JSON, it is expected that it is a string that means its URI. Expected: ``` >> URI.parse('http://example.com').as_json "http://example.com" ``` Actual: ``` >> URI.parse('http://example.com').as_json {"scheme"=>"http", "user"=>nil, "password"=>nil, "host"=>"example.com", "port"=>80, "path"=>"", "query"=>nil, "opaque"=>nil, "fragment"=>nil, "parser"=> {"regexp"=> {"SCHEME"=>"(?-mix:\\A[A-Za-z][A-Za-z0-9+\\-.]*\\z)", "USERINFO"=>"(?-mix:\\A(?:%\\h\\h|[!$&-.0-;=A-Z_a-z~])*\\z)", "HOST"=> "(?-mix:\\A(?:(?<IP-literal>\\[(?:(?<IPv6address>(?:\\h{1,4}:){6}(?<ls32>\\h{1,4}:\\h{1,4}|(?<IPv4address>(?<dec-octet>[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5]|\\d)\\.\\g<dec-octet>\\.\\g<dec-octet>\\.\\g<dec-octet>))|::(?:\\h{1,4}:){5}\\g<ls32>|\\h{,4}::(?:\\h{1,4}:){4}\\g<ls32>|(?:(?:\\h{1,4}:)?\\h{1,4})?::(?:\\h{1,4}:){3}\\g<ls32>|(?:(?:\\h{1,4}:){,2}\\h{1,4})?::(?:\\h{1,4}:){2}\\g<ls32>|(?:(?:\\h{1,4}:){,3}\\h{1,4})?::\\h{1,4}:\\g<ls32>|(?:(?:\\h{1,4}:){,4}\\h{1,4})?::\\g<ls32>|(?:(?:\\h{1,4}:){,5}\\h{1,4})?::\\h{1,4}|(?:(?:\\h{1,4}:){,6}\\h{1,4})?::)|(?<IPvFuture>v\\h+\\.[!$&-.0-;=A-Z_a-z~]+))\\])|\\g<IPv4address>|(?<reg-name>(?:%\\h\\h|[!$&-.0-9;=A-Z_a-z~])*))\\z)", "ABS_PATH"=> "(?-mix:\\A\\/(?:%\\h\\h|[!$&-.0-;=@-Z_a-z~])*(?:\\/(?:%\\h\\h|[!$&-.0-;=@-Z_a-z~])*)*\\z)", "REL_PATH"=> "(?-mix:\\A(?:%\\h\\h|[!$&-.0-;=@-Z_a-z~])+(?:\\/(?:%\\h\\h|[!$&-.0-;=@-Z_a-z~])*)*\\z)", "QUERY"=>"(?-mix:\\A(?:%\\h\\h|[!$&-.0-;=@-Z_a-z~\\/?])*\\z)", "FRAGMENT"=>"(?-mix:\\A(?:%\\h\\h|[!$&-.0-;=@-Z_a-z~\\/?])*\\z)", "OPAQUE"=>"(?-mix:\\A(?:[^\\/].*)?\\z)", "PORT"=> "(?-mix:\\A[\\x09\\x0a\\x0c\\x0d ]*\\d*[\\x09\\x0a\\x0c\\x0d ]*\\z)"}}} ```
* Merge pull request #23011 from arnvald/bugfix/correctly_parse_dateGodfrey Chan2016-06-251-5/+11
|\ | | | | | | Use correct timezone when parsing date in json
| * Use correct timezone when parsing date in jsonGrzegorz Witek2016-01-221-5/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | Fixes https://github.com/rails/rails/issues/22171 Time specified in ISO 8601 format without `Z` should be considered as local time, yet until now it was treated as UTC. This commit fixes problem by parsing time using timezone specified in application config. The downside of this solution is performance hit (`Time.zone.parse` is ~ 1.6x slower than `Time.parse`), so maybe there's a better solution.
* | Fix behavior of JSON encoding for Exceptionnamusyaka2016-04-091-0/+5
|/
* Expand the JSON test coverage for Struct and Hash (?!)Godfrey Chan2015-07-111-1/+13
|
* Add tests to ensure we don't interfere with json gem's outputGodfrey Chan2015-07-112-102/+108
|
* Escape HTML entities in JSON keysRafael Mendonça França2015-06-161-0/+7
| | | | Fixes CVE-2015-3226
* Skip the failing tests on Rubinius for nowRobin Dupret2015-03-021-0/+2
|
* Removed magic comments # encoding: utf-8 , since its default from ruby 2.0 ↵Vipul A M2015-02-032-2/+0
| | | | onwards.
* Remove deprecated ActiveSupport::JSON::Encoding::CircularReferenceError.Rafael Mendonça França2015-01-041-24/+0
|
* Remove deprecated ActiveSupport::JSON::Encoding.encode_big_decimal_as_string=Rafael Mendonça França2015-01-041-16/+0
|
* Remove redundant `to_s` in interpolationclaudiob2014-10-301-1/+1
|
* Merge pull request #15856 from zuhao/refactor_activesupport_decoding_testYves Senn2014-06-221-11/+19
|\ | | | | Use with_parse_json_times helper in tests.
| * Use with_parse_json_times helper in tests.Zuhao Wan2014-06-221-11/+19
| |
* | Avoid hardcoded magic number in test teardown.Zuhao Wan2014-06-221-14/+19
|/
* Extract out with_env_tz helper method.Zuhao Wan2014-06-181-7/+3
| | | | | It’s used at so many places that extracting it out into a helper file is worth doing.
* Fix #to_json for BasicObject EnumerablesSammy Larbi2014-03-141-10/+33
|
* Add support for JSON time_precision to Time and DateTimeAndrew White2014-01-261-1/+19
|
* Rename subsecond_fraction_digits option to time_precisionAndrew White2014-01-261-3/+3
|