aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/controller
Commit message (Collapse)AuthorAgeFilesLines
* Define path with __dir__bogdanvlviv2017-05-2312-26/+26
| | | | | | ".. with __dir__ we can restore order in the Universe." - by @fxn Related to 5b8738c2df003a96f0e490c43559747618d10f5f
* Use recyclable cache keys (#29092)David Heinemeier Hansson2017-05-181-24/+45
|
* 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
|
* Reuse the Parameters#to_h check in the routing helpersRafael Mendonça França2017-04-182-3/+3
| | | | | Since this protection is now in Parameters we can use it instead of reimplementing again.
* Implement ActionController::Parameters#to_query and #to_paramRafael Mendonça França2017-04-181-3/+21
| | | | | | | | | | Previously it was raising an error because it may be unsafe to use those methods in a unpermitted parameter. Now we delegate to to_h that already raise an error when the Parameters instance is not permitted. This also fix a bug when using `#to_query` in a hash that contains a `ActionController::Parameters` instance and was returning the name of the class in the string.
* 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
|
* Default embed_authenticity_token_in_remote_forms to nil.Kasper Timm Hansen2017-04-161-0/+90
| | | | | | | Effectively treat nil values as "auto", e.g. whatever a form helper chooses to interpret it as. But treat an explicitly assigned false value as disabling.
* Improve logging when Origin header doesn't matchJon Leighton2017-04-061-0/+11
| | | | | | | | | | | | | I came up against this while dealing with a misconfigured server. The browser was setting the Origin header to "https://example.com", but the Rails app returned "http://example.com" from request.base_url (because it was failing to detect that HTTPS was used). This caused verify_authenticity_token to fail, but the message in the log was "Can't verify CSRF token", which is confusing because the failure had nothing to do with the CSRF token sent in the request. This made it very hard to identify the issue, so hopefully this will make it more obvious for the next person.
* Merge pull request #28606 from maclover7/jm-fix-25820Andrew White2017-03-302-0/+57
|\ | | | | Do not include default response headers for AC::Metal
| * Do not include default response headers for AC::MetalJon Moss2017-03-292-0/+57
| | | | | | | | | | | | | | | | | | | | | | | | In Rails 4.2, `ActionController::Metal` controllers did not include the default headers from `ActionDispatch::Response`. However, through e16afe6, and a general shift towards having `ActionController::Metal` objects contain `ActionDispatch::Response` objects (instead of just returning an array of status, headers, and body), this behavior was lost. This PR helps to restore the original behavior by having `ActionController::Metal` controllers generate Response objects without the default headers, while `ActionController::Base` now overrides the factory method to make sure its version does have the default headers.
* | Merge pull request #28603 from mikeastock/alias-reverse-mergeSean Griffin2017-03-291-0/+16
|\ \ | |/ |/| Add an alias for reverse_merge to with_defaults
| * 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.
* | Add test to make sure subclasses also get helpersRafael Mendonça França2017-03-291-0/+16
|/
* Merge pull request #28514 from y-yagi/follow_up_to_28056Andrew White2017-03-281-8/+10
|\ | | | | Fix store accessors in parameters test
| * 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
* | Make sure that ActionController::Api can include helpersRafael Mendonça França2017-03-271-0/+26
|/ | | | Closes #28554
* Merge pull request #28056 from sngeth/wrap_store_accessors_in_paramsRafael França2017-03-211-0/+13
|\ | | | | Wrap stored accessors in parameters
| * Wrap store accessors in parametersSid Ngeth2017-03-211-0/+13
| | | | | | | | Modified params wrapper to account for model's stored_attributes
* | Fix test assertionRafael Mendonça França2017-03-211-1/+1
| |
* | Fix test that was asserting the wrong thingRafael Mendonça França2017-03-211-1/+1
|/
* Revert "Merge pull request #27775 from domcleal/27774-format-reset"Rafael Mendonça França2017-03-211-14/+5
| | | | | | | | | | | | | | This reverts commit c6f9f8c28a720ad4ec7cf3613dddfa451d5968e2, reversing changes made to c309073c7476f50dfb1e796d058580f176101c36. Reason: This is fixing the behavior in the wrong place. Now the request path after the request is nil and there is no way to assert that. Also the test that was added in that PR also fails in 4.2 where the reporter says it was passing. The reason the bahavior changed between Rails 4.2 and Rails 5 is that the format in the path is now respected. The correct way to fix the problem is not doign two requests in the same controller test and use integrations tests. This change caused a regression between Rails 5.0.1 and 5.0.2.
* Fixes ActionController::Rendering#with_defaultsalpaca-tc2017-03-121-0/+10
| | | | `env` is undefined.
* 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
|
* Fix malformed asset_url when rendering template with ActionController::RendererGiorgos Vrettos2017-03-061-0/+14
|
* Add more missing requiresAndrew White2017-02-221-0/+1
| | | | Further missing requires for Timeout exposed due to Bundler 1.14.5
* Use `response#location` instead of `#location` in redirect.Mehmet Emin INAC2017-02-201-2/+2
| | | | Closes #28033
* Set correct "routes" in tests casesbogdanvlviv2017-02-201-3/+3
|
* Add `Style/EmptyLinesAroundMethodBody` in `.rubocop.yml` and remove extra ↵Ryuta Kamizono2017-02-121-1/+0
| | | | empty lines
* Correct spellingBenjamin Fleischer2017-02-053-3/+3
| | | | | | | ``` go get -u github.com/client9/misspell/cmd/misspell misspell -w -error -source=text . ```
* Delete PATH_INFO after each controller test requestDominic Cleal2017-01-231-0/+14
| | | | | | | | | | Prevents PATH_INFO from being used to infer the request format in later test requests when no explicit format is given. As the request PATH_INFO may be set before a request, it can't be deleted during pre-request scrubbing. Fixes #27774
* :warning: "Use assert_nil if expecting nil. This will fail in MT6."Akira Matsuda2017-01-182-10/+22
| | | | | | 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
|
* Merge pull request #27692 from y-yagi/make_render_work_with_ac_paramsEileen M. Uchitelle2017-01-161-1/+0
|\ | | | | make `render` work with AC::Params
| * make `render` work with AC::Paramsyuuji.yaginuma2017-01-151-1/+0
| | | | | | | | | | | | | | | | In 4.2, since AC::Params inherited `Hash`, processing in the case of `Hash` was done. But in 5.x, since AC::Params does not inherit `Hash`, need to add care for AC::Params. Related to 00285e7cf75c96553719072a27c27e4ab7d25b40
* | 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.
* Reduce string objects by using \ instead of + or << for concatenating stringsAkira Matsuda2017-01-121-1/+1
| | | | (I personally prefer writing one string in one line no matter how long it is, though)
* `self.` is not needed when calling its own instance methodAkira Matsuda2017-01-052-3/+3
| | | | Actually, private methods cannot be called with `self.`, so it's not just redundant, it's a bad habit in Ruby
* fix with_routing when testing api only controllersJulia López2016-12-291-0/+24
|
* Use `next` instead of `break`; avoid terminating whole loopJon Moss2016-12-291-0/+21
| | | | | | | | | | | | | | We want to avoid terminating the whole loop here, because it will cause parameters that should be removed to not be removed, since we are terminating early. In this specific case, `param2` is processed before `param1` due to the reversing of `route.parts`, and since `param2` fails the check on this line, it would previously cause the whole loop to fail, and `param1` would still be in `parameterized_parts`. Now, we are simply calling `next`, which is the intended behavior. Introduced by 8ca8a2d773b942c4ea76baabe2df502a339d05b1. Fixes #27454.
* 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-262-3/+3
|
* "Use assert_nil if expecting nil from ...:in `...'. This will fail in ↵Akira Matsuda2016-12-251-2/+1
| | | | minitest 6."