aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/controller/params_wrapper_test.rb
Commit message (Collapse)AuthorAgeFilesLines
* Enable `Layout/EmptyLinesAroundAccessModifier` copRyuta Kamizono2019-06-131-1/+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.
* Merge pull request #31005 from shuheiktgw/remove_unnecessary_semicolonsMatthew Draper2017-10-281-1/+1
| | | | Removed unnecessary semicolons
* checking for nested attributes when attribute names specified to wrap them ↵Kelton Manzanares2017-10-251-0/+14
| | | | as well
* Use frozen string literal in actionpack/Kir Shatrov2017-07-291-0/+2
|
* Don't wrap parameters if query parameter existsEugene Kenny2017-06-251-0/+8
| | | | | | | | | | | | We want to avoid overwriting a query parameter with the wrapped parameters hash. Previously this was implemented by merging the wrapped parameters at the root level if the key already existed, which was effectively a no-op. The query parameter was still overwritten in the filtered parameters hash, however. We can fix that discrepancy with a simpler implementation and less unnecessary work by skipping parameter wrapping entirely if the key was sent as a query parameter.
* Don't wrap parameters if key already existsEugene Kenny2017-06-241-0/+8
| | | | | | | | | | | | | | | | | We shouldn't perform parameter wrapping if it would overwrite one of the parameters sent with the request, as that would interfere with reading the parameter directly from the top level `params` hash. The current implementation has logic for this case, but it doesn't handle `nil`/`false` values, which means these parameters: { "user" => nil } are transformed into this `params` hash: { "user" => { "user" => nil } } and `params["user"]` no longer returns the original parameter value.
* Fix store accessors in parameters testyuuji.yaginuma2017-03-221-8/+10
| | | | | | | | * The method name must be `stored_attributes`, not `stores_attributes`. * `attribute_names` must return a non-empty value. Because `stored_attributes` is not checked if `attribute_names` is empty. Follow up to #28056
* Wrap store accessors in parametersSid Ngeth2017-03-211-0/+13
| | | | Modified params wrapper to account for model's stored_attributes
* Fix Rubocop violations and fix documentation visibilityRafael Mendonça França2016-12-281-1/+1
| | | | | | Some methods were added to public API in 5b14129d8d4ad302b4e11df6bd5c7891b75f393c and they should be not part of the public API.
* assert_equal takes expectation firstAkira Matsuda2016-12-261-1/+1
|
* Merge pull request #27007 from maclover7/jm-fix-26912Rafael Mendonça França2016-11-131-0/+10
|\ | | | | | | Don't error on an empty CONTENT_TYPE
| * Don't error on an empty CONTENT_TYPEJon Moss2016-11-101-0/+10
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit prevents a possible issue wherein an empty CONTENT_TYPE header is sent in a request to a Rails application, and then `request.content_mime_type` would return `nil`. This is because the `has_content_type?` guard method was not properly checking the validity of a request's content type; it was only checking to see whether or not the header existed, not whether it had a value stored inside. Relatedly, after an internal discussion, it was determined that the `has_content_type?` method is not meant to be part of the public API, and is therefore changed to a `:nodoc:` method in this commit. The test for this behavior is a little bit ugly, for two reasons. One is that it was difficult to determine where to place the test... I figured the best place would be with the rest of the ParamsWrapper stuff, since that's where the original issue was. Also, we have to do some fancy footwork in calling `dispatch` on the test's controller manually... this is because `ActionController::TestCase` will throw an error if you try and pass in a nil content type, which is exactly what we are trying to test here... Because of that, we have to manually call in to the controller, and bypass the `post` request helper. Fixes #26912. This is a regression in behavior between Rails versions 4.2.x and 5.0.x, which was introduced via [this commit](https://github.com/rails/rails/commit/a9f28600e901b11a9222e34bfae8642bfb753186).
* Add three new rubocop rulesRafael Mendonça França2016-08-161-4/+4
| | | | | | | | Style/SpaceBeforeBlockBraces Style/SpaceInsideBlockBraces Style/SpaceInsideHashLiteralBraces Fix all violations in the repository.
* applies remaining conventions across the projectXavier Noria2016-08-061-1/+0
|
* normalizes indentation and whitespace across the projectXavier Noria2016-08-061-7/+7
|
* remove redundant curlies from hash argumentsXavier Noria2016-08-061-25/+25
|
* modernizes hash syntax in actionpackXavier Noria2016-08-061-6/+6
|
* applies new string literal convention in actionpack/testXavier Noria2016-08-061-74/+74
| | | | | The current code base is not uniform. After some discussion, we have chosen to go with double quotes by default.
* Remove mocha from ActionPack testsMarcin Olichwirowicz2015-09-051-19/+23
|
* Switch to kwargs in ActionController::TestCase and ActionDispatch::IntegrationKir Shatrov2015-01-291-24/+24
| | | | | | | | Non-kwargs requests are deprecated now. Guides are updated as well. `post url, nil, nil, { a: 'b' }` doesn't make sense. `post url, params: { y: x }, session: { a: 'b' }` would be an explicit way to do the same
* Clear inflections after test.Zuhao Wan2014-05-281-7/+19
|
* Do not discard query parameters on requests that use wrap_parametersJosh Jordan2014-01-301-0/+20
|
* start using options objectAaron Patterson2012-11-131-1/+1
|
* Remove integration between attr_accessible/protected and ↵Guillermo Iguaran2012-09-161-40/+0
| | | | AC::Metal::ParamsWrapper
* Show in log correct wrapped keysDmitry Vorotilin2012-05-201-0/+8
|
* Merge pull request #4445 from nragaz/role_based_params_wrappingJosé Valim2012-05-041-2/+15
| | | | specify a role for identifying accessible attributes when wrapping params
* Fix warning for params_wrapper_test.kennyj2011-12-081-1/+1
|
* ParamsWrapper only wrap the accessible attributes when they were setJean-Francois Turcot2011-12-071-1/+28
|
* use classify in ParamsWrapper to derive model name from controller namelest2011-12-051-0/+35
|
* Use lazy load hooks to set parameter wrapping configuration. This means that ↵Jon Leighton2011-08-161-7/+0
| | | | it doesn't force Action Controller / Active Record to load, but it doesn't fail if they have already loaded. Thanks @josevalim for the hint.
* Don't refer to ActionController::Base in the wrap_parameters initializer - ↵Jon Leighton2011-08-161-0/+7
| | | | use config object instead. Cuts about 15% off the load time. (#734)
* renamed the wrap_parameters :only and :except options to :include and ↵Josh Kalderimis2011-05-191-6/+6
| | | | :exclude to make it consistent with controller filters
* add more robust test for wrapping params with anonymous classDavid Chelimsky2011-05-171-25/+45
|
* better test nameDavid Chelimsky2011-05-171-1/+1
|
* add failing test for https://github.com/rails/rails/issues/1089David Chelimsky2011-05-171-0/+7
|
* Make ParamsWrapper calling newly introduced `Model.attribute_names` instead ↵Prem Sichanugrist2011-05-151-10/+8
| | | | of `.column_names`
* Do not try to call `column_names` on the abstract class.Prem Sichanugrist2011-05-151-1/+14
| | | Normally the table for abstract class won't be existed, so we should not trying to call `#column_names` on it.
* Get around weird missing constant error caused by AS instead of simply ↵José Valim2011-05-111-21/+24
| | | | raising NameError, closes #477.
* Fix typos in test method namesVijay Dev2011-05-031-3/+3
|
* Fix broken params_wrapper_test on 1.8.7 :bomb:Prem Sichanugrist2011-05-031-36/+80
| | | | | I have to keep in mind that 1.8.7 does *not* preserve the hash order. Guys, let's move to use 1.9.2 in production!
* Move most processing to load time for performance and improve test suite.José Valim2011-05-031-12/+27
|
* Add `ActionController::ParamsWrapper` to wrap parameters into a nested hashPrem Sichanugrist2011-05-031-0/+187
This will allow us to do a rootless JSON/XML request to server.