aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test/core_ext/hash_ext_test.rb
Commit message (Collapse)AuthorAgeFilesLines
* Improve Hash#compact! documentation and testsIgor Pstyga2016-06-031-0/+8
| | | | | | | Make it clear what should be returned when no changes were made to the hash. { c: true }.compact! # => nil
* Support for unified Integer class in Ruby 2.4+Jeremy Daer2016-05-181-17/+17
| | | | | | | | Ruby 2.4 unifies Fixnum and Bignum into Integer: https://bugs.ruby-lang.org/issues/12005 * Forward compat with new unified Integer class in Ruby 2.4+. * Backward compat with separate Fixnum/Bignum in Ruby 2.2 & 2.3. * Drops needless Fixnum distinction in docs, preferring Integer.
* Fix regression in `Hash#dig` for HashWithIndifferentAccess.Jon Moss2016-02-011-0/+6
|
* Match HashWithIndifferentAccess#default's behaviour with Hash#defaultDavid Cornu2016-01-071-2/+2
|
* :scissors:Rafael Mendonça França2015-10-301-1/+0
|
* Deprecate `HWIDA.new_from_hash_copying_default`Sean Griffin2015-10-291-1/+1
| | | | This method was already niche, and is now redundant with `.new`
* Merge pull request #16357 from gchan/hwia-respects-to-hash-defaultSean Griffin2015-10-291-0/+18
|\ | | | | | | | | `HashWithIndifferentAccess.new` respects the default value or proc on objects that respond to `#to_hash`
| * `HashWithIndifferentAccess.new` respects the default value or proc on ↵Gordon Chan2014-07-311-0/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | objects that respond to `#to_hash`. Builds on the work of #12550 where `.new` will convert the object (that respond to `#to_hash`) to a hash and add that hash's keys and values to itself. This change will also make `.new` respect the default value or proc of objects that respond to `#to_hash`. In other words, this `.new` behaves exactly like `.new_from_hash_copying_default`. `.new_from_hash_copying_default` now simply invokes `.new` and any references to `.new_from_hash_copying_default` are replaced with `.new`. Added tests confirm behavior.
* | ActiveSupport::HashWithIndifferentAccess select and reject should return ↵Bernard Potocki2015-07-171-0/+10
| | | | | | | | enumerator if called without block
* | Reuse the same test for HWIA reverse_merge!Rafael Mendonça França2015-07-101-3/+1
| |
* | Merge pull request #20828 from Sirupsen/hash-indifferent-dup-default-procRafael Mendonça França2015-07-101-0/+37
|\ \ | | | | | | active_support/indifferent_access: fix not raising when default_proc does
| * | test/hash: move lonely indifferent hash testSimon Eskildsen2015-07-101-0/+6
| | |
| * | active_support/indifferent_hash: dont raise on to_hash when default_proc raisesSimon Eskildsen2015-07-101-0/+14
| | |
| * | active_support/indifferent_hash: fix cloning default_proc on dupSimon Eskildsen2015-07-101-0/+17
| | |
* | | Removed use of mocha in active_supportRonak Jangir2015-07-101-3/+4
|/ /
* | - Moved hwia frozen value assignment test to hash_ext_test similar to other ↵Vipul A M2015-01-171-0/+8
| | | | | | | | | | | | | | tests - Fixed the wrong use of with_indifferent_access on hash in the test which failed for isolated tests - Renamed to appropriately specify what the test does
* | Pass symbol as an argument instead of a blockErik Michaels-Ober2014-11-291-1/+1
| |
* | Add tests to ensure default proc is used when `HashWithIndifferentAccess' is ↵Gordon Chan2014-07-311-0/+12
|/ | | | initialized with a block
* Make HWIA copy the default proc too.Arthur Neves2014-07-241-0/+11
| | | | [fixes #16279]
* missing activesupport test coverageEugene Gilburg2014-07-191-1/+11
|
* Add test cases for Hash#asset_valid_keysAditya Kapoor2014-06-141-0/+15
|
* Fix bug that make HashWithIndifferentAccess work differently of HashRafael Mendonça França2014-06-091-0/+8
| | | | | Before HashWithIndifferentAccess were doing deep_dup of the inner hashes when Hash doesn't do. Now both are behaving in the same way.
* Test `except!` in other cases tooAkshay Vishnoi2014-05-311-0/+8
|
* Merge pull request #10887 from sakuro/deep_transform_keys_in_nested_arraysRafael Mendonça França2014-05-201-0/+22
|\ | | | | | | | | | | | | Hash#deep_*_keys(!) recurse into nested arrays. Conflicts: activesupport/CHANGELOG.md
| * Hash#deep_*_keys(!) recurse into nested arrays.OZAWA Sakuro2013-06-081-0/+22
| | | | | | | | | | | | | | | | | | | | | | Following methods now recursively transform nested arrays, too. * Hash#deep_transform_keys * Hash#deep_transform_keys! * Hash#deep_stringify_keys * Hash#deep_stringify_keys! * Hash#deep_symbolize_keys * Hash#deep_symbolize_keys!
* | Merge pull request #12746 from coreyward/masterRafael Mendonça França2014-05-071-4/+14
|\ \ | | | | | | | | | Fix Hash#deep_merge bug and improve documentation — resolves #12738
| * | Fix Hash#deep_merge bug and improve documentation — resolves #12738Corey Ward2013-12-091-0/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | Previously merging into a hash with a falsy value would not result in the merge-block being called. The fix is simply to check for presence of the key in the hash. The documentation example for `deep_merge` now appropriately demonstrates what a deep merge does.
* | | "subhash" --> "sub-hash"Akshay Vishnoi2014-04-191-1/+1
| | |
* | | HashWithIndifferentAccess better respects #to_hashPeter Jaros2014-03-281-0/+40
| | | | | | | | | | | | | | | | | | In particular, `.new`, `#update`, `#merge`, `#replace` all accept objects which respond to `#to_hash`, even if those objects are not Hashes directly.
* | | Adding Hash#compact and Hash#compact! methodstinogomes2014-01-091-0/+28
|/ / | | | | | | | | | | | | | | | | | | | | * Adding Hash#compact and Hash#compact! methods * Using Ruby 1.9 syntax on documentation * Updating guides for `Hash#compact` and `Hash#compact!` methods * Updating CHANGELOG for ActiveSupport * Removing unecessary protected method and lambda for `Hash#compact` implementations * Performing `Hash#compact` implementation - https://gist.github.com/tinogomes/8332883 * fixing order position * Fixing typo
* | Tidy up previous commit, fix message assertion and improve testsCarlos Antonio da Silva2013-12-031-1/+6
| |
* | Modify the Hash#assert_valid_keys error message so that it shows the valid ↵Nerian2013-12-031-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | keys. Also, show the wrong value as it was entered. { :failore => "stuff", :funny => "business" }.assert_valid_keys([ :failure, :funny ]) => ArgumentError: Unknown key: failore { 'failore' => "stuff", :funny => "business" }.assert_valid_keys([ :failure, :funny ]) => ArgumentError: Unknown key: failore { 'failore' => "stuff", :funny => "business" }.assert_valid_keys([ :failure, :funny ]) => ArgumentError: Unknown key: "failore". Valid keys are: :failure, :funny { :failore => "stuff", :funny => "business" }.assert_valid_keys([ :failure, :funny ]) => ArgumentError: Unknown key: :failore. Valid keys are: :failure, :funny Conflicts: activerecord/CHANGELOG.md Closes #11624.
* | slice! should not remove default hash value/procAntonio Santos2013-10-241-0/+18
| |
* | Make HashWithIndifferentAccess#select always return the hash.Marc Schütz2013-07-061-0/+6
| | | | | | | | | | Hash#select! returns nil if the hash didn't change and thus behaves differently from select, so it's return value can't be used as result for the latter.
* | Remove deprecated Hash#diff with no replacement.Carlos Antonio da Silva2013-07-021-6/+0
| | | | | | | | | | If you're using it to compare hashes for the purpose of testing, please use MiniTest's assert_equal instead.
* | Merge pull request #10740 from mrsimo/hash-with-indifferent-access-selectRafael Mendonça França2013-06-141-0/+30
|\ \ | |/ |/| HashWithIndifferentAccess#select working as intended
| * HashWithIndifferentAccess#select working as intendedAlbert Llop2013-05-231-0/+30
| | | | | | | | | | | | Before this commit, #reject returned a HashWithIndifferentAccess, whereas #select returned a Hash. Now #select also returns a HashWithIndifferentAccess.
* | Prevent side effects in `Hash#with_indifferent_access`.Yves Senn2013-05-291-0/+7
|/
* Fix HWIA#to_hash behavior with array of hashes.kennyj2013-05-161-0/+5
|
* fix HashWithIndifferentAccess#to_hash behaviourVipul A M2013-04-191-0/+4
|
* CVE-2013-0156: Safe XML params parsing. Doesn't allow symbols or yaml.Jeremy Kemper2013-01-081-6/+22
|
* Revert "Merge branch 'master-sec'"Jeremy Kemper2013-01-081-22/+6
| | | | | This reverts commit 88cc1688d0cb828c17706b41a8bd27870f2a2beb, reversing changes made to f049016cd348627bf8db0d72382d7580bf802a79.
* CVE-2013-0156: Safe XML params parsing. Doesn't allow symbols or yaml.Jeremy Kemper2013-01-081-6/+22
|
* Namespace HashWithIndifferentAccessAkira Matsuda2013-01-071-1/+1
|
* Refactor Hash.from_xml.Steve Klabnik + Katrina Owen2012-12-211-1/+1
| | | | | | | | | | | | Three basic refactors in this PR: * We extracted the logic into a method object. We now don't define a tone of extraneous methods on Hash, even if they were private. * Extracted blocks of the case statement into methods that do the work. This makes the logic more clear. * Extracted complicated if clauses into their own query methods. They often have two or three terms, this makes it much easier to see what they _do_. We took care not to refactor too much as to not break anything, and put comments where we suspect tests are missing. We think ActiveSupport::XMLMini might be a good candidate to move to a plugin in the future.
* Test Hash#diff deprecation, also prevent deprecation message in AS testsNikita Afanasenko2012-11-111-1/+3
|
* Implement replace method so key? works correctly.David Graham2012-10-261-0/+12
|
* Revert "remove unnecessary object/conversions file"Xavier Noria2012-10-161-0/+1
| | | | | | | This file is used at least by Active Merchant, its existence is maybe not necessary but no big deal either. This reverts commit ae9b3d7cecd77b9ace38671b183e1a360bf632b6.
* Merge pull request #7007 from Mik-die/hash_extractRafael Mendonça França2012-10-121-1/+25
|\ | | | | make Hash#extract! more symmetric with Hash#slice
| * add more testcases and doc about Hash#extract!Mikhail Dieterle2012-10-081-2/+9
| |