aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/controller
Commit message (Collapse)AuthorAgeFilesLines
...
* 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."
* "Use assert_nil if expecting nil from ...:in `...'. This will fail in MT6."Akira Matsuda2016-12-251-4/+4
|
* "Use assert_nil if expecting nil. This will fail in minitest 6."Akira Matsuda2016-12-255-10/+10
|
* Privatize unneededly protected methods in Action Pack testsAkira Matsuda2016-12-239-21/+19
|
* Document and update API for `skip_parameter_encoding`Aaron Patterson2016-12-211-31/+8
| | | | | | | | This commit changes `parameter_encoding` to `skip_parameter_encoding`. `skip_parameter_encoding` will set encoding on all parameters to ASCII-8BIT for a given action on a particular controller. This allows the controller to handle data when the encoding of that data is unknown, for example file systems or truly binary parameters.
* Merge pull request #27414 from matthewd/fix-xml-vs-html-assertionMatthew Draper2016-12-211-12/+12
|\ | | | | Revise the "XML is not HTML" test
| * Revise the "XML is not HTML" testMatthew Draper2016-12-201-12/+12
| | | | | | | | | | | | It was depending on a side-effect of the old html-scanner, so was no longer proving what it intended to. Instead, assert more directly about the resulting observable difference.
* | Only default the response charset when it is first setMatthew Draper2016-12-201-1/+8
|/ | | | | If it is explicitly cleared (e.g., response.sending_file = true), then we should not try to set it again.
* use public Module#include instead of send :includeyuuji.yaginuma2016-11-271-1/+1
| | | | Follow up to #18767
* Use accept header instead of mangling request path.Kasper Timm Hansen2016-11-231-2/+25
| | | | | | | | | | | | | | Instead of appending a format to the request, it's much better to just pass a more appropriate accept header. Rails will figure out the format from that instead. This allows devs to use `:as` on routes that don't have a format. Introduce an `IdentityEncoder` to avoid `if request_encoder`, essentially a better version of the purpose of the `WWWFormEncoder`. One that makes conceptual sense on GET requests too. Fixes #27144.
* Fix `ActionDispatch::IntegrationTest#open_session`Tawan Sierek2016-11-181-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Reset a new session directly after its creation in `ActionDispatch::IntegrationTest#open_session`. Reset the session to a clean state before making it available to the client's test code. Issue #22742 reports unexpected behavior of integration tests that run multiple sessions. For example an `ActionDispatch::Flash` instance is shared across multiple sessions, though a client code will rightfully assume that each new session has its own flash hash. The following test failed due to this behavior: class Issue22742Test < ActionDispatch::IntegrationTest test 'issue #22742' do integration_session # initialize first session a = open_session b = open_session refute_same(a.integration_session, b.integration_session) end end Instead of creating a new `ActionDispatch::Integration::Session` instance, the same instance is shared across all newly opened test sessions. This is due to the way how new test sessions are created in `ActionDispatch::IntegrationTest#open_session`. The already existing `ActionDispatch::IntegrationTest` instance is duplicated with `Object#dup`, This approach was introduced in commit 15c31c7639b. `Object#dup` copies the instance variables, but not the objects they reference. Therefore this issue only occurred when the current test instance had been tapped in such a way that the instance variable `@integration_session` was initialized before creating the new test session. Close #22742 [Tawan Sierek + Sina Sadeghian]
* Fixed CONTENT_LENGTH header in ActionController::TestRequestArtem Rashev2016-11-151-0/+10
| | | | | | | | | | | | | CONENT_LENGTH setted by string length, which is equal to number of characters in string but StringIO.length is byte sequence and when payload contains non-ASCII characters, stream's length will be different. That's why real byte length should be used for CONTENT_LENGTH header. Add unit test for CONTENT_LENGTH header fix It just passes non-ascii symbols as parameters and verifies that "CONTENT_LENGTH" header has content bytes count as value.
* Fix style violationsRafael Mendonça França2016-11-141-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).
* | 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`.