aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test/hash_with_indifferent_access_test.rb
Commit message (Collapse)AuthorAgeFilesLines
* Merge pull request #34642 from ↵Rafael França2019-05-011-0/+28
|\ | | | | | | | | azimux/improve-hwia-initialize-by-skipping-to_h-if-already-a-hash HashWithIndifferentAccess#initialize performance improvement
| * HashWithIndifferentAccess#initialize performance improvementMiles Georgi2018-12-061-0/+28
| | | | | | | | | | | | | | | | | | Rails 4 -> Rails 5 introduced a #to_hash call in HashWithIndifferentAccess#initialize to guarantee access to the #default and #default_proc methods. This can be a very expensive operation for very large HashWithIndifferentAccess objects. This commit bypasses this #to_hash call if it is already a Hash.
* | ActiveSupport typo fixes.alkesh262019-02-011-1/+1
| |
* | Add HashWithIndifferentAccess#assocStefan Schüßler2019-01-301-0/+8
|/
* Make #to_options an alias for #symbolize_keysNick Weiland2018-11-011-0/+7
| | | | | | | | | | | | Fixes #34359 Prior to 5.2.0 (2cad8d7), HashWithIndifferentAccess#to_options acted as an alias to HashWithIndifferentAccess#symbolize_keys. Now, #to_options returns an instance of HashWithIndifferentAccess while #symbolize_keys returns and instance of Hash. This pr makes it so HashWithIndifferentAccess#to_options acts as an alias for HashWithIndifferentAccess#symbolize_keys once again.
* Fix HashWithIndifferentAccess#without bugAbraham Chan2018-09-281-0/+11
|
* Fix `CustomCops/AssertNot` to allow it to have failure messageRyuta Kamizono2018-05-131-1/+1
| | | | Follow up of #32605.
* Replace `assert !` with `assert_not`Daniel Colson2018-04-191-2/+2
| | | | | This autocorrects the violations after adding a custom cop in 3305c78dcd.
* Remove extra conditions in HWIDA since Rails 6 does not support Ruby 2.2bogdanvlviv2018-02-171-2/+0
| | | | See https://github.com/ruby/ruby/blob/ruby_2_3/NEWS
* Rails 6 requires Ruby 2.3+Jeremy Daer2018-02-171-1/+0
|
* Define transform_keys! in HashWithIndifferentAccessRafael Mendonça França2018-02-161-0/+13
| | | | | | | Make sure that when transforming the keys of a HashWithIndifferentAccess we can still access with indifferent access in Ruby 2.5. Closes #32007.
* Testing to ensure both bang and non-bang methods behaves consistentlyRyuta Kamizono2017-09-301-0/+23
| | | | Follow up of #30728.
* Ensure `HashWithIndifferentAccess#transform_keys` to return ↵yuuji.yaginuma2017-09-271-0/+7
| | | | | | | | | | | `HashWithIndifferentAccess` Currently, `#transform_values`, `#select` and `#reject` return instance of `HashWithIndifferentAccess`. But `#transform_keys` returns instance of Hash. This behavior is a bit confusing. I think that `HashWithIndifferentAccess#transform_keys` should also return instance of `HashWithIndifferentAccess` as well as other methods.
* remove depreciated assertion to eliminate warningChristina Thompson2017-07-241-1/+1
| | | | Signed-off-by: Yuki Nishijima <yk.nishijima@gmail.com>
* Fix HashWithIndifferentAccess#default when include?(nil)Lisa Ugray2017-07-171-0/+26
| | | | | | | | | | The implementation of HashWithIndifferentAccess#default didn't distinguish `default` from `default(nil)`, which caused an incorrect result for `default` if `nil` was used as a key. Define HashWithIndifferentAccess#dig so that hackery that behaves differently from Hash#default can be removed from HashWithIndifferentAccess#default.
* [Active Support] `rubocop -a --only Layout/EmptyLineAfterMagicComment`Koichi ITO2017-07-111-0/+1
|
* Use frozen-string-literal in ActiveSupportKir Shatrov2017-07-091-0/+1
|
* 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
|
* Implement `fetch_values` for HashWithIndifferentAccess (#28316)Josh Pencheon2017-04-101-0/+12
| | | | | | | `fetch_values` was added to Hash in Ruby 2.3.0: https://bugs.ruby-lang.org/issues/10017 This patch adds an implemention for instances of HWAI, in line with the existing definitions of `fetch` and `values_at`.
* Fix `warning: already initialized constant ↵Ryuta Kamizono2017-04-071-1/+0
| | | | | | HashWithIndifferentAccessTest::HashWithIndifferentAccess` Caused since #28607.
* Move HashWithIndifferentAccess tests to separate fileMichael Stock2017-03-301-0/+734
|
* test/hash: move lonely indifferent hash testSimon Eskildsen2015-07-101-11/+0
|
* - Moved hwia frozen value assignment test to hash_ext_test similar to other ↵Vipul A M2015-01-171-7/+1
| | | | | | | 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
* Fix assignment for frozen value in HWIAAditya Kapoor2015-01-171-0/+7
|
* Add necessary 'require reverse_merge' to HAWI.rbclaudiob2014-10-171-0/+10
Hashes with indifferent access should support `reverse_merge` out-of-the-box but they don't; for instance the following code fails: ```ruby require 'active_support' require 'active_support/hash_with_indifferent_access' hash = HashWithIndifferentAccess.new key: :old_value hash.reverse_merge key: :new_value ``` This PR fixes the case above by simply requiring `active_support/core_ext/hash/reverse_merge` in `hash_with_indifferent_access.rb` and adding a test that confirms the fix. --- Here are more details about the bugfix. Currently, `reverse_merge` is [defined in HashWithIndifferentAccess](https://github.com/rails/rails/blob/4e8ea13ba1a0870905a46fac5f232d9f41eef8a4/activesupport/lib/active_support/hash_with_indifferent_access.rb#L208) by invoking `super`, that is by invoking `Hash#reverse_merge`: ```ruby def reverse_merge(other_hash) super(self.class.new_from_hash_copying_default(other_hash)) end ``` However, Ruby's `Hash` does not have the `reverse_merge` by default: it must be added by ActiveSupport, and that requires the following line of code to be present: ```ruby require 'active_support/core_ext/hash/reverse_merge' ```