aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/dispatch/request
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.
* Add #dig to ActionDispatch::Request::Sessionclaudiob2018-04-041-0/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | ### Summary The `session` object is not a real Hash but responds to many methods of Hash such as `[]`, `[]`, `fetch`, `has_key?`. Since Ruby 2.3, Hash also supports a `dig` method. This commit adds a `dig` method to `ActionDispatch::Request::Session` with the same behavior as `Hash#dig`. This is useful if you store a hash in your session, such as: ```ruby session[:user] = { id: 1, avatar_url: "http://example.org/nyancat.jpg" } ``` Then you can shorten your code from `session[:user][:avatar_url]` to `session.dig :user, :avatar_url`. ### Other Information I cherry-picked a commit from https://github.com/rails/rails/pull/23864, and modify a bit. The changes are below: * Converts only the first key to a string adjust to the `fetch` method. * Fixes a test case because we cannot use the indifferent access since ee5b621e2f8fde380ea4bc75b0b9d6f98499f511.
* Consistent behavior for session and cookies with to_h and to_hash methodIgor Kasyanchuk2018-01-311-0/+1
|
* Use frozen string literal in actionpack/Kir Shatrov2017-07-295-0/+10
|
* Revert "Merge pull request #29540 from kirs/rubocop-frozen-string"Matthew Draper2017-07-025-5/+0
| | | | | This reverts commit 3420a14590c0e6915d8b6c242887f74adb4120f9, reversing changes made to afb66a5a598ce4ac74ad84b125a5abf046dcf5aa.
* Enforce frozen string in RubocopKir Shatrov2017-07-015-0/+5
|
* Merge pull request #28895 from codeforkjeff/fix-session-keys-and-values-methodsMatthew Draper2017-05-281-0/+18
|\ | | | | Add lazy loading to #keys and #values methods in Session
| * Add lazy loading to #keys and #values methods in Sessioncodeforkjeff2017-04-261-0/+18
| | | | | | | | | | | | | | This fixes a bug where session.keys and session.values return an empty array unless one of the other methods that does lazy loading from the underlying store is called first. #keys and #values should also call #load_for_read!
* | Define path with __dir__bogdanvlviv2017-05-232-3/+3
|/ | | | | | ".. with __dir__ we can restore order in the Universe." - by @fxn Related to 5b8738c2df003a96f0e490c43559747618d10f5f
* "Use assert_nil if expecting nil. This will fail in minitest 6."Akira Matsuda2016-12-251-1/+1
|
* Add more rubocop rules about whitespacesRafael Mendonça França2016-10-292-3/+3
|
* Remove mona lisa image from the testsRafael Mendonça França2016-10-251-1/+1
| | | | | This image has copyright that we are not giving so it is better to use one image that we own the copyright.
* Remove deprecated support to non-keyword arguments in ↵Rafael Mendonça França2016-10-101-1/+3
| | | | | | `ActionDispatch::IntegrationTest`, `#process`, `#get`, `#post`, `#patch`, `#put`, `#delete`, and `#head`.
* Deprecated ActionDispatch::ParamsParser::ParamsParserRafael Mendonça França2016-10-101-1/+1
| | | | | | ActionDispatch::ParamsParser class was removed in favor of ActionDispatch::Http::Parameters so it is better to move the error constant to the new class.
* Add three new rubocop rulesRafael Mendonça França2016-08-164-46/+46
| | | | | | | | Style/SpaceBeforeBlockBraces Style/SpaceInsideBlockBraces Style/SpaceInsideHashLiteralBraces Fix all violations in the repository.
* normalizes indentation and whitespace across the projectXavier Noria2016-08-061-7/+7
|
* remove redundant curlies from hash argumentsXavier Noria2016-08-061-14/+14
|
* modernizes hash syntax in actionpackXavier Noria2016-08-064-8/+8
|
* applies new string literal convention in actionpack/testXavier Noria2016-08-065-124/+124
| | | | | The current code base is not uniform. After some discussion, we have chosen to go with double quotes by default.
* Modifies mime-registration test not to interfere with real mime typesBenjamin Fleischer2016-05-231-3/+3
| | | | | | | | | | | | | | | | The tests introduced in https://github.com/rails/rails/pull/23816/files#diff-384a5a15d8d53de799fb6541688ea5f9R153 register the JSON API media type `application/vnd.api+json` with `Mime[:json]`. The JSON API media type should not be registered with `Mime[:json]`, as discussed in #23712. Moreover, since the actual mime type used in the test is incidental, I've changed this to a valid, but fictional `applcation/vnd.rails+json`. These tests were causing failures in https://github.com/rails/rails/pull/25050#issuecomment-221092934 where `Mime[:jsonapi]` is being added, so that JSON API request params are parsed with the JSONAPI gem.
* Ensure compatibility between ActionDispatch::Request::Session and RackJon Moss2016-05-041-0/+26
| | | | | | | | | | | | | | Adding the `each` method is required for ensuring compatibility between Rails, and other Rack frameworks (like Sinatra, etc.), that are mounted within Rails, and wish to use its session tooling. Prior to this, there was an inconsistency between ActionDispatch::Request::Session and Rack::Session::Cookie, due to the absence of the `each` method. This should hopefully fix that error. :) For a full integration test with Sinatra and a standalone Rack application, you can check out the gist for that here: https://gist.github.com/maclover7/08cd95b0bfe259465314311941326470. Solves #15843.
* Deprecate :controller and :action path parametersAndrew White2016-03-014-7/+21
| | | | | | | | Allowing :controller and :action values to be specified via the path in config/routes.rb has been an underlying cause of a number of issues in Rails that have resulted in security releases. In light of this it's better that controllers and actions are explicitly whitelisted rather than trying to blacklist or sanitize 'bad' values.
* Revert "Merge pull request #20851 from tomprats/indifferent-sessions"Matthew Draper2016-02-261-10/+0
| | | | | | | This reverts commit 22db455dbe9c26fe6d723cac0758705d9943ea4b, reversing changes made to 40be61dfda1e04c3f306022a40370862e3a2ce39. This finishes off what I meant to do in 6216a092ccfe6422f113db906a52fe8ffdafdbe6.
* Revert "Update Session to utilize indiffernt access"Matthew Draper2016-02-261-1/+1
| | | | | | | | | | | This reverts commit 45a75a3fcc96b22954caf69be2df4e302b134d7a. HWIAs are better than silently deeply-stringified hashes... but that's a reaction to a shortcoming of one particular session store: we should not break the basic behaviour of other, more featureful, session stores in the process. Fixes #23884
* Merge pull request #20851 from tomprats/indifferent-sessionsRafael Mendonça França2016-02-241-0/+10
|\ | | | | | | Give Sessions Indifferent Access
| * Update Session to utilize indiffernt accessTom Prats2016-01-301-1/+1
| |
| * Update session to have indifferent accessTom Prats2016-01-291-0/+10
| |
* | Make sure we unregister the mime type before registeringRafael Mendonça França2016-02-221-10/+22
| | | | | | | | Also make sure we don't change the global state of our test suite.
* | Use symbol of mime type instead of object to get correct parserMehmet Emin İNAÇ2016-02-221-0/+16
| | | | | | | | | | | | After registering new `:json` mime type `parsers.fetch` can't find the mime type because new mime type is not equal to old one. Using symbol of the mime type as key on parsers hash solves the problem. Closes #23766
* | Fix typoRafael Mendonça França2016-02-171-1/+1
| |
* | The JSON API media type should only work wih a JSON API handlerBenjamin Fleischer2016-02-161-9/+2
|/ | | | | | | | | | | | Since the media type 'application/vnd.api+json' is a spec, it is inappropriate to handle it with the JSON renderer. This PR removes support for a JSON API media type. I would recommend the media type be registered on its own as `jsonapi` when a jsonapi Renderer and deserializer (Http::Parameters::DEFAULT_PARSERS) are added. Is related to work in https://github.com/rails/rails/pull/21496
* Push `before_sending` to super classeileencodes2015-12-061-1/+1
| | | | | | | | | | | | We want to get rid of the `Live::Response` so we are consolidating methods from `Live::Response` and `Response` by merging them together. This adds an `#empty` method to the request so we don't need to hard-code the empty array each time we call an empty `ActionDispatch::Request`. The work here is a continuation on combining controller and integration test code bases into one.
* Deprecate exception#original_exception in favor of exception#causeYuki Nishijima2015-11-031-2/+2
|
* Merge pull request #21251 from rodzyn/more_param_parser_testsSean Griffin2015-10-301-0/+14
|\ | | | | Add test for parsing application/vnd.api+json
| * Add test for parsing application/vnd.api+jsonMarcin Olichwirowicz2015-08-211-0/+14
| |
* | implement abstract store methodsAaron Patterson2015-09-041-1/+1
| | | | | | | | converts old ID methods to the new abstract store methods in Rack
* | use a request object in the session middlewareAaron Patterson2015-08-221-19/+21
|/ | | | | This commit allows us to use one request object rather than allocating multiple request objects to deal with the session.
* point at rack masterAaron Patterson2015-08-201-1/+1
|
* Add failing spec on utf8 filename with percent characterKohei Suzuki2015-08-041-0/+11
|
* Stop using deprecated `render :text` in testPrem Sichanugrist2015-07-171-1/+1
| | | | | | | | | This will silence deprecation warnings. Most of the test can be changed from `render :text` to render `:plain` or `render :body` right away. However, there are some tests that needed to be fixed by hand as they actually assert the default Content-Type returned from `render :body`.
* Make AC::Parameters not inherited from HashPrem Sichanugrist2015-07-151-1/+1
| | | | | | | | This is another take at #14384 as we decided to wait until `master` is targeting Rails 5.0. This commit is implementation-complete, as it guarantees that all the public methods on the hash-inherited Parameters are still working (based on test case). We can decide to follow-up later if we want to remove some methods out from Parameters.
* Removed magic comments # encoding: utf-8 , since its default from ruby 2.0 ↵Vipul A M2015-02-031-1/+0
| | | | onwards.
* Consistent usage of spaces in hashes across our codebaseRafael Mendonça França2015-01-293-3/+3
|
* Switch to kwargs in ActionController::TestCase and ActionDispatch::IntegrationKir Shatrov2015-01-294-16/+15
| | | | | | | | 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
* Don't convert empty arrays to nils when deep munging paramsChris Sinjakli2014-12-152-4/+4
|
* Merge pull request #13999 from jamox/update_rackAaron Patterson2014-07-081-1/+5
|\ | | | | This updates rails to use edge rack
| * Upgraded rackJarmo Isotalo2014-05-191-1/+5
| | | | | | | | | | | | | | | | As Rack has some non backwards compatible changes added required modifications to keep behaviour in rails close to same as before. Also modified generators to include rack/rack for not yet released version of rack
* | Avoid hardcoded value in test setup/teardown.Zuhao Wan2014-06-051-1/+2
| |
* | Merge pull request #15349 from tgxworld/remove_duplicated_method_callRafael Mendonça França2014-06-031-4/+1
|\ \ | | | | | | Remove duplicated HashWithIndifferentAccess#with_indifferent_access.
| * | Remove duplicated HashWithIndifferentAccess#with_indifferent_access.Guo Xiang Tan2014-05-261-4/+1
| |/