aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/controller/parameters
Commit message (Collapse)AuthorAgeFilesLines
* "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`.
* | Add more rubocop rules about whitespacesRafael Mendonça França2016-10-292-7/+7
| |
* | Soften this test since YAML.dump may produce keys in other orders.Charles Oliver Nutter2016-10-211-6/+4
|/
* ActionController::Parameters#deep_dup (#26567)Pavel Evstigneev2016-10-111-0/+22
| | | | | | | | | | | * ActionController::Parameters#deep_dup * Tests for ActionController::Parameters#deep_dup * Fix test for ActionController::Parameters#deep_dup * More tests for ActionController::Parameters#deep_dup [Rafael Mendonça França + Pavel Evstigneev]
* Remove deprecated comparing support with `ActionController::Parameters`Rafael Mendonça França2016-10-101-8/+0
|
* call `.to_h` to avoid using deprecated methodyuuji.yaginuma2016-09-071-0/+7
| | | | | | | | | | | `ActionController::Parameters#merge` call `HashWithIndifferentAccess#merge`. In addition, it calls `HashWithIndifferentAccess#update` from `HashWithIndifferentAccess#merge`, where it is called the `#to_hash` of argument. But `ActionController::Parameters#to_hash` is deprecated, warning message is displayed. To avoid this, modify to convert object to `Hash`. Fixes #26415
* Merge pull request #26094 from igorkasyanchuk/masterRafael França2016-08-161-4/+4
|\ | | | | Show unpermitted parameters as symbols in logs (so they could be copy…
| * Show unpermitted parameters as symbols in logs (so they could be copy-pasted ↵Igor Kasyanchuk2016-08-101-4/+4
| | | | | | | | to the code)
* | Add three new rubocop rulesRafael Mendonça França2016-08-165-14/+14
| | | | | | | | | | | | | | | | Style/SpaceBeforeBlockBraces Style/SpaceInsideBlockBraces Style/SpaceInsideHashLiteralBraces Fix all violations in the repository.
* | Fix broken alignments caused by auto-correct commit 411ccbdRyuta Kamizono2016-08-105-18/+36
|/ | | | Hash syntax auto-correcting breaks alignments. 411ccbdab2608c62aabdb320d52cb02d446bb39c
* applies remaining conventions across the projectXavier Noria2016-08-061-1/+1
|
* normalizes indentation and whitespace across the projectXavier Noria2016-08-061-11/+11
|
* remove redundant curlies from hash argumentsXavier Noria2016-08-066-71/+35
|
* modernizes hash syntax in actionpackXavier Noria2016-08-061-6/+6
|
* applies new string literal convention in actionpack/testXavier Noria2016-08-0610-111/+111
| | | | | The current code base is not uniform. After some discussion, we have chosen to go with double quotes by default.
* Fix wrong assignment.Kasper Timm Hansen2016-08-021-4/+5
| | | | Screwed up both the left and right hand sides!
* Set `always_permitted_parameters`.Kasper Timm Hansen2016-08-021-0/+9
| | | | | | | The tests were written with the common false value seen in Rails apps, show that intent in the code. Should also fix the build on 5-0-stable.
* Let Psych 2.0.9+ deserialize 2.0.8 serialized parameters.Kasper Timm Hansen2016-08-021-2/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | If we were to serialize an `ActionController::Parameters` on Psych 2.0.8, we'd get: ```yaml --- !ruby/hash:ActionController::Parameters key: :value ``` Because 2.0.8 didn't store instance variables, while 2.0.9 did: https://github.com/tenderlove/psych/commit/8f84ad0fc711a82a1040def861cb121e8985fd4c That, coupled with 2.0.8 calling `new` instead of `allocate` meant parameters was deserialized just fine: https://github.com/tenderlove/psych/commit/af308f8307899cb9e1c0fffea4bce3110a1c3926 However, if users have 2.0.8 serialized parameters, then upgrade to Psych 2.0.9+ and Rails 5, it would start to blow up because `initialize` will never be called, and thus `@parameters` will never be assigned. Hello, `NoMethodErrors` on `NilClass`! :) To fix this we register another variant of the previous serialization format and take it into account in `init_with`. I've tested this in our app and previously raising code now deserializes like a champ. I'm unsure how to test this in our suite because we use Psych 2.0.8 and don't know how to make us use 2.0.9+ for just one test.
* Make Parameters support legacy YAML encodings.Kasper Timm Hansen2016-08-011-0/+32
| | | | | | | | | | | | | | | | | | | | | By changing ActionController::Parameter's superclass, Rails 5 also changed the YAML serialization format. Since YAML doesn't know how to handle parameters it would fallback to its routine for the superclass, which in Rails 4.2 was Hash while just Object in Rails 5. As evident in the tags YAML would spit out: 4.2: !ruby/hash-with-ivars:ActionController::Parameters 5.0: !ruby/object:ActionController::Parameters Thus when loading parameters YAML from 4.2 in Rails 5, it would parse a hash dump as it would an Object class. To fix this we have to provide our own `init_with` to be aware of the past format as well as the new one. Then we add a `load_tags` mapping, such that when the YAML parser sees `!ruby/hash-with-ivars:ActionController::Parameters`, it knows to call our `init_with` function and not try to instantiate it as a normal hash subclass.
* Remove duplicate test and fix a typo in the testPrathamesh Sonpatki2016-07-122-6/+1
| | | | | - Tests for dup'ing params was separately added in a separate file in https://github.com/rails/rails/pull/25735.
* Trust `Object#dup` in `ActionController::Parameters`, using ↵Tim Rogers2016-07-081-1/+19
| | | | | | `#initialize_copy` to manually duplicate the underlying parameters hash It looks like `ActionController::Parameters#dup` is leftover from when the class inherited from `Hash`. We can just trust `#dup`, which already copies the `@permitted` instance variable (confirmed by tests). We still define a `#initialize_copy` to make `@parameters` a copy that can be mutated without affecting the original instance.
* Changes to a dupped `ActionController::Parameters` mutate the originalTim Rogers2016-07-071-0/+25
| | | | | | | | | | | | | | When `ActionController::Parameters` is duplicated with `#dup`, it doesn't create a duplicate of the instance variables (e.g. `@parameters`) but rather maintains the reference (see <http://ruby-doc.org/core-2.3.1/Object.html>). Given that the parameters object is often manipulated as if it were a hash (e.g. with `#delete` and similar methods), this leads to unexpected behaviour, like the following: ``` params = ActionController::Parameters.new(foo: "bar") duplicated_params = params.dup duplicated_params.delete(:foo) params == duplicated_params ``` This fixes the bug by defining a private `#initialize_copy` method, used internally by `#dup`, which makes a copy of `@parameters`.
* Merge pull request #24177 from vipulnsward/rename-testRafael França2016-07-011-1/+1
|\ | | | | Renamed NestedParametersTest to NestedParametersPermitTest
| * - Renamed NestedParametersTest to NestedParametersPermitTest, to indicate ↵Vipul A M2016-03-131-1/+1
| | | | | | | | what we are actually testing in this file
* | `params.permitted?` is false by defaultJon Moss2016-06-231-0/+6
| | | | | | | | | | In the docs: "+permit_all_parameters+ - If it's +true+, all the parameters will be permitted by default. The default is +false+."
* | Filter scalar values when params permit hashes or arraysSean Griffin2016-04-151-0/+9
|/ | | | | | This brings the behavior more inline with other similar cases, such as receiving a hash when an array of scalars was expected. Prior to this commit, the key would be present, but the value would be `nil`
* Add `ActionController::Parameters#dig`Sean Griffin2016-03-091-0/+20
| | | | | | This method will only be added when used with Ruby 2.3.0 or greater. This method has the same behavior as `Hash#dig`, except it will convert hashes to `ActionController::Parameters`, similar to `#[]` and `#fetch`.
* Show permitted flag in the output of AC::Parameters#inspectPrathamesh Sonpatki2016-02-241-3/+13
| | | | - Fixes #23822.
* Deprecate AC::Parameters#== with a HashBenjamin Quorning2016-02-191-2/+4
|
* Fix AC::Parameters#== with other AC::ParametersBenjamin Quorning2016-02-191-0/+33
| | | | Creating a protected getter method for `@parameters`.
* Tests for AC::Parameters#==Benjamin Quorning2016-02-191-0/+6
|
* fields_for_style needs to test for AC::ParametersAaron Patterson2016-02-171-0/+21
| | | | | | | | | | | | | While iterating an AC::Parameters object, the object will mutate itself and stick AC::Parameters objects where there used to be hashes: https://github.com/rails/rails/blob/f57092ad728fa1de06c4f5fd9d09dcc2c4738fd9/actionpack/lib/action_controller/metal/strong_parameters.rb#L632 If you use `permit` after this iteration, the `fields_for_style` method wouldn't return true because the child objects are now AC::Parameters objects rather than Hashes. fixes #23701
* Implement ActionController::Parameters#inspectBenjamin Quorning2016-02-171-0/+9
| | | | Now that AC::Parameters is no longer a Hash, it shouldn't look like a hash.
* Remove `const_missing` which fallback to deprecated `NEVER_UNPERMITTED_PARAMS`Ryuta Kamizono2016-02-151-6/+0
| | | | `NEVER_UNPERMITTED_PARAMS` is deprecated in Rails 4.2. See #15933.
* Fix `ActionController::Parameters#==` bugJon Moss2016-01-211-0/+6
| | | | See bug #21032.
* Merge pull request #22985 from akshay-vishnoi/fix-typoRafael França2016-01-161-1/+1
|\ | | | | test `include?`- fix typo
| * test `include?`- fix typoAkshay Vishnoi2016-01-091-1/+1
| |
* | AC::Parameters#at_json: restore Rails 4.2’s valueclaudiob2016-01-121-0/+6
|/ | | | | | Fixes #23026 See discussion at #23026
* Merge pull request #22850 from prathamesh-sonpatki/fix_ac_params_unsafe_h_2Kasper Timm Hansen2015-12-311-0/+8
|\ | | | | Fix AC::Parameters#to_unsafe_h to return all unfiltered values
| * Fix AC::Parameters#to_unsafe_h to return all unfiltered valuesPrathamesh Sonpatki2015-12-311-0/+8
| | | | | | | | | | | | | | - AC::Parameters#convert_parameters_to_hashes should return filtered or unfiltered values based on whether it is called from `to_h` or `to_unsafe_h` instead of always defaulting to `to_h`. - Fixes #22841
* | Fix test for AC::Parameters#to_unsafe_hPrathamesh Sonpatki2015-12-301-2/+2
|/ | | | - Test should call `to_unsafe_h` instead of `to_h`
* Add AC::Parameters#include?Justin Coyne2015-12-291-0/+6
| | | | Fixes #22818
* Only dup Ruby's Hash and Array.Kasper Timm Hansen2015-12-171-0/+28
| | | | | | | | When calling `to_h` on an `ActionController::Parameters` instance it would `deep_dup` its internal parameters. This inadvertently called `dup` on a passed Active Record model which would create new models. Fix by only dupping Ruby's Arrays and Hashes.
* Make Parameters#to_h and #to_unsafe_h return HWIAPrem Sichanugrist2015-12-141-4/+4
| | | | | | | This makes these two methods to be more inline with the previous behavior of Parameters as Parameters used to be inherited from HWIA. Fixes #21391
* Remove skip on tests that have been fixed.Guo Xiang Tan2015-10-241-4/+0
|