aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/controller/parameters
Commit message (Collapse)AuthorAgeFilesLines
* Enable `Style/RedundantBegin` cop to avoid newly adding redundant begin blockRyuta Kamizono2018-12-211-32/+26
| | | | | | | | | | 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.
* Fix `ActionController::Parameters#each_value` and add changelog entry to ↵Bogdan2018-10-151-2/+6
| | | | | | | | | | | | | this method (#34210) * Fix `ActionController::Parameters#each_value` `each_value` should yield with "value" of the params instead of "value" as an array. Related to #33979 * Add changelog entry about `ActionController::Parameters#each_value`. Follow up #33979
* Added ActionController::Parameters.each_value methodLukas Zapletal2018-09-271-0/+18
|
* Permit list usage cleanup and clearer documentationKevin Deisz2018-08-271-1/+1
|
* Convert over the rest of the whitelist referencesKevin Deisz2018-08-241-1/+1
|
* Convert hashes into parameters (#33076)Kevin Sjöberg2018-06-191-0/+21
| | | | | | | | | | | | * Convert hashes into parameters Ensure `ActionController::Parameters#transform_values` and `ActionController::Parameters#transform_values!` converts hashes into parameters. * fixup! Convert hashes into parameters [Rafael Mendonça França + Kevin Sjöberg]
* Fix `CustomCops/AssertNot` to allow it to have failure messageRyuta Kamizono2018-05-132-2/+2
| | | | Follow up of #32605.
* Merge pull request #32593 from sdhull/fix-strong-params-permit-bangRafael Mendonça França2018-04-191-1/+4
|\ | | | | | | Fixes StrongParameters `permit!` to work with nested arrays
| * Fixes StrongParameters permit! to work with nested arraysSteve Hull2018-04-161-1/+4
| | | | | | | | | | `permit!` is intended to mark all instances of `ActionController::Parameters` as permitted, however nested arrays of params were not being marked permitted because the method did shallow iteration. This fixes that by flattening the array before calling `permit!` on all each item.
* | Replace `assert !` with `assert_not`Daniel Colson2018-04-191-1/+1
|/ | | | | This autocorrects the violations after adding a custom cop in 3305c78dcd.
* Merge pull request #32441 from composerinteralia/refute-notRafael França2018-04-041-5/+5
|\ | | | | Add custom RuboCop for `assert_not` over `refute`
| * Autocorrect `refute` RuboCop violationsDaniel Colson2018-04-031-5/+5
| | | | | | | | | | | | 73e7aab behaved as expected on codeship, failing the build with exactly these RuboCop violations. Hopefully `rubocop -a` will have been enough to get a passing build!
* | Make mutating params#dig mutate underlying paramsVince DeVendra2018-03-241-0/+8
|/ | | | | | | | | | | When #dig was called on a params object and return either a Hash or an Array, and that value was subsquently mutated, it would not modify the containing params object. That means that the behavior of `params.dig(:a, :b)[:c] = 1` did not match either `params[:a][:b][:c] = 1` nor `hash.dig(:a, :b)[:c] = 1`. Similarly to `ActionController::Parameters#[]`, use `#convert_hashes_to_parameters` to pre-convert values and insert them in the receiving params object prior to returning them.
* Rails 6 requires Ruby 2.4.1+Jeremy Daer2018-02-172-2/+0
| | | | | | Skipping over 2.4.0 to sidestep the `"symbol_from_string".to_sym.dup` bug. References #32028
* Rails 6 requires Ruby 2.3+Jeremy Daer2018-02-171-16/+9
|
* Remove usage of strip_heredoc in the framework in favor of <<~Rafael Mendonça França2018-02-161-3/+2
| | | | | Some places we can't remove because Ruby still don't have a method equivalent to strip_heredoc to be called in an already existent string.
* Use assert_empty and assert_not_emptyDaniel Colson2018-01-252-3/+3
|
* Use assert_predicate and assert_not_predicateDaniel Colson2018-01-258-69/+69
|
* Change refute to assert_notDaniel Colson2018-01-252-9/+9
|
* Use respond_to test helpersDaniel Colson2018-01-251-1/+1
|
* Suppress `warning: BigDecimal.new is deprecated`Yasuo Honda2017-12-151-1/+1
| | | | | | | | | | | | | | | | | | | | `BigDecimal.new` has been deprecated in BigDecimal 1.3.3 which will be a default for Ruby 2.5. Refer https://github.com/ruby/bigdecimal/commit/533737338db915b00dc7168c3602e4b462b23503 * This commit has been made as follows: ``` cd rails git grep -l BigDecimal.new | grep -v guides/source/5_0_release_notes.md | grep -v activesupport/test/xml_mini_test.rb | xargs sed -i -e "s/BigDecimal.new/BigDecimal/g" ``` - `activesupport/test/xml_mini_test.rb` Editmanually to remove `.new` and `::` - guides/source/5_0_release_notes.md This is a Rails 5.0 release notes.
* Yield array from AC::Parameters#each for block with one argDominic Cleal2017-12-061-0/+16
| | | | Matches Hash#each behaviour as used in Rails 4.
* Use frozen string literal in actionpack/Kir Shatrov2017-07-2910-0/+20
|
* Revert "Merge pull request #29540 from kirs/rubocop-frozen-string"Matthew Draper2017-07-0210-10/+0
| | | | | This reverts commit 3420a14590c0e6915d8b6c242887f74adb4120f9, reversing changes made to afb66a5a598ce4ac74ad84b125a5abf046dcf5aa.
* Merge pull request #29540 from kirs/rubocop-frozen-stringMatthew Draper2017-07-0210-0/+10
|\ | | | | | | Enforce frozen string in Rubocop
| * Enforce frozen string in RubocopKir Shatrov2017-07-0110-0/+10
| |
* | Fallback Parameters#to_s to Hash#to_sKir Shatrov2017-06-301-0/+5
|/ | | Fixes https://github.com/rails/rails/issues/29617
* prepare for Minitest 6utilum2017-06-201-1/+1
|
* Pass block in ActionController::Parameters#deleteEugene Kenny2017-05-101-0/+21
| | | | | | | | In order to fully support the same interface as `Hash#delete`, we need to pass the block through to the underlying method, not just the key. This used to work correctly, but it regressed when `ActionController::Parameters` stopped inheriting from `Hash` in 5.0.
* Add test case to make sure we can implicit convert a Parameters to a HashRafael Mendonça França2017-04-201-0/+7
|
* Use the right assetions to better error messagesRafael Mendonça França2017-04-181-7/+7
|
* Add test to make sure that to_unsafe_h don't mutate the targetRafael Mendonça França2017-04-181-0/+10
|
* Add ActionController::Parameters#to_hash to implict conversionRafael Mendonça França2017-04-181-0/+26
| | | | | | | | Now methods that implicit convert objects to a hash will be able to work without requiring the users to change their implementation. This method will return a Hash instead of a HashWithIndefirentAccess to mimic the same implementation of HashWithIndefirentAccess#to_hash.
* Raise exception when calling to_h in a unfiltered ParametersRafael Mendonça França2017-04-181-15/+4
| | | | | | | | | | | | | | | | Before we returned either an empty hash or only the always permitted parameters (:controller and :action by default). The previous behavior was dangerous because in order to get the attributes users usually fallback to use to_unsafe_h that could potentially introduce security issues. The to_unsafe_h API is also not good since Parameters is a object that quacks like a Hash but not in all cases since to_h would return an empty hash and users were forced to check if to_unsafe_h is defined or if the instance is a ActionController::Parameters in order to work with it. This end up coupling a lot of libraries and parts of the application with something that is from the controller layer.
* Test the correct objectRafael Mendonça França2017-04-181-1/+1
|
* Add aliases for reverse_merge to with_defaultsMatt Casper2017-03-291-0/+16
| | | | | | In the context of controller parameters, reverse_merge is commonly used to provide defaults for user input. Having an alias to reverse_merge called with_defaults feels more idiomatic for Rails.
* Fix test that was asserting the wrong thingRafael Mendonça França2017-03-211-1/+1
|
* Use correct value in `reverse_merge` testyuuji.yaginuma2017-03-111-8/+4
|
* Added `reverse_merge`/`reverse_merge!` to AC::Parameters:Edouard CHIN2017-03-091-0/+29
| | | | | - This PR adds the `reverse_merge` and `reverse_merge!` method to `ActionController::Parameters` - Fixes #28353
* Tests for delegated public methods on AC::ParametersT.J. Schuck2017-03-071-0/+63
|
* :warning: "Use assert_nil if expecting nil. This will fail in MT6."Akira Matsuda2017-01-181-2/+10
| | | | | | These are followups for 307065f959f2b34bdad16487bae906eb3bfeaf28, but TBH I'm personally not very much confortable with this style. Maybe we could override assert_equal in our test_helper not to warn?
* Fix all rubocop violationsRafael Mendonça França2017-01-171-1/+1
|
* Added test to ensure that we dont break #to_h again when trying to restore ↵David Heinemeier Hansson2017-01-161-0/+5
| | | | the speed-up from 26dd9b26ab7317f94fd285245879e888344143b2 (cc: @fxn)
* Revert "significant speedup of AC::Parameters#permit" ↵David Heinemeier Hansson2017-01-161-5/+0
| | | | [26dd9b26ab7317f94fd285245879e888344143b2] as it broke Parameters#to_h on at least fields_for-style nested params.
* "Use assert_nil if expecting nil. This will fail in minitest 6."Akira Matsuda2016-12-251-4/+4
|
* Fix style violationsRafael Mendonça França2016-11-141-1/+1
|
* significant speedup of AC::Parameters#permitXavier Noria2016-11-121-0/+5
| | | | | | | | | | | | | | | | | | | | | The current implementation of AC::Parameters#permit builds permitted hashes and then calls permit! on them. This filtering is recursive, so we call permit! on terminal branches, but then ascendants call permit! on themselves when the recursion goes up the stack, which recurses all the way down again because permit! is recursive itself. Repeat this for every parent node and you get some scary O-something going on that I don't even want to compute. Instead, since the whole point of the permit recursion is to build permitted hashes along the way and at that point you know you've just come up with a valid filtered version, you can already switch the toggle on the spot. I have seen 2x speedups in casual benchmarks with small structures. As the previous description shows, the difference in performance is going to be a function of the nesting. Note that that the involved methods are private and used only by permit.
* adds support for arbitrary hashes in strong parametersXavier Noria2016-11-111-0/+33
|
* Merge pull request #26820 from y-yagi/add_bang_merge_to_parametersRafael França2016-11-101-0/+17
|\ | | | | add `ActionController::Parameters#merge!`
| * add `ActionController::Parameters#merge!`yuuji.yaginuma2016-10-181-0/+17
| | | | | | | | | | This method has the same behavior as `Hash#merge!`, returns current `ActionController::Parameters`.