aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/controller
Commit message (Collapse)AuthorAgeFilesLines
* Enable `Layout/EmptyLinesAroundAccessModifier` copRyuta Kamizono2019-06-1318-24/+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.
* Bump rubocop to 0.71Abhay Nikam2019-06-061-2/+0
|
* Give HelperMethods module a nameJohn Hawthorn2019-06-031-2/+2
|
* Remove unnecessary require pathname from actionpack controller specsAbhay Nikam2019-06-023-3/+0
|
* Change `ActionDispatch::Response#content_type` returning Content-Type header ↵yuuji.yaginuma2019-06-0110-76/+76
| | | | | | | | | | | | | | | | | | | | | | | | | | as it is Since #35709, `Response#conten_type` returns only MIME type correctly. It is a documented behavior that this method only returns MIME type, so this change seems appropriate. https://github.com/rails/rails/blob/39de7fac0507070e3c5f8b33fbad6fced84d97ed/actionpack/lib/action_dispatch/http/response.rb#L245-L249 But unfortunately, some users expect this method to return all Content-Type that does not contain charset. This seems to be breaking changes. We can change this behavior with the deprecate cycle. But, in that case, a method needs that include Content-Type with additional parameters. And that method name is probably the `content_type` seems to properly. So I changed the new behavior to more appropriate `media_type` method. And `Response#content_type` changed (as the method name) to return Content-Type header as it is. Fixes #35709. [Rafael Mendonça França & Yuuji Yaginuma ]
* Implemented deep_transform_keys/! for ActionController::ParametersGustavo Gutierrez2019-05-222-0/+18
|
* Merge pull request #36302 from eugeneius/parameters_transform_keys_enumeratorRyuta Kamizono2019-05-201-2/+14
|\ | | | | | | Return parameters enumerator from transform_keys/!
| * Return parameters enumerator from transform_keys/!Eugene Kenny2019-05-181-2/+14
|/ | | | | | | | | | | | | | | | | Previously calling `ActionController::Parameters#transform_keys/!` without passing a block would return an enumerator for the underlying hash, which was inconsistent with the behaviour when a block was passed: ActionController::Parameters.new(foo: "bar").transform_keys { |k| k } => <ActionController::Parameters {"foo"=>"bar"} permitted: false> ActionController::Parameters.new(foo: "bar").transform_keys.each { |k| k } => {"foo"=>"bar"} An enumerator for the parameters is now returned instead, ensuring that evaluating it produces another parameters object instead of a hash: ActionController::Parameters.new(foo: "bar").transform_keys.each { |k| k } => <ActionController::Parameters {"foo"=>"bar"} permitted: false>
* fixed usage of Parameters when a non-numeric key existsL.Fexon2019-05-131-2/+28
| | | | | | | | | | test for non-numeric key in nested attributes test: extra blank line between tests removed test for non-numeric key fixed (by Daniel) Update according to feedback
* Only build middleware proxy when instrumentatingJohn Hawthorn2019-05-081-1/+1
| | | | | | | | | | | | | | | | | The instrumentation proxy adds three stack frames per-middleware, even when nothing is listening. This commit, when the middleware stack is built, only adds instrumentation when the `process_middleware.action_dispatch` event has already been subscribed to. The advantage to this is that we don't have any extra stack frames in apps which don't need middleware instrumentation. The disadvantage is that the subscriptions need to be in place when the middleware stack is built (during app boot). I think this is likely okay because temporary AS::Notifications subscriptions are strongly discouraged.
* Remove redundant test setups in log_subscriber_testst00122019-04-241-21/+1
| | | | | | | Because controllers' `perform_caching` config is `true` by default, it means we actually enable the caching in all those tests implicitly (and it works). Which also means we can avoid repeatedly declaring that and just specify it once in the setup method (just for declaration).
* Always reject files external to appJohn Hawthorn2019-04-032-9/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously, when using `render file:`, it was possible to render files not only at an absolute path or relative to the current directory, but relative to ANY view paths. This was probably done for absolutely maximum compatibility when addressing CVE-2016-0752, but I think is unlikely to be used in practice. Tihs commit removes the ability to `render file:` with a path relative to a non-fallback view path. Make FallbackResolver.new private To ensure nobody is making FallbackResolvers other than "/" and "". Make reject_files_external_... no-op for fallbacks Because there are only two values used for path: "" and "/", and File.join("", "") == File.join("/", "") == "/", this method was only testing that the absolute paths started at "/" (which of course all do). This commit doesn't change any behaviour, but it makes it explicit that the FallbackFileSystemResolver works this way. Remove outside_app_allowed argument Deprecate find_all_anywhere This is now equivalent to find_all Remove outside_app argument Deprecate find_file for find Both LookupContext#find_file and PathSet#find_file are now equivalent to their respective #find methods.
* url -> URL where apt inside actionpack/Sharang Dashputre2019-04-014-7/+7
|
* Merge pull request #35688 from jhawthorn/render_file_rfcAaron Patterson2019-03-303-9/+21
|\ | | | | RFC: Introduce Template::File
| * Introduce Template::File as new render file:John Hawthorn2019-03-273-9/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The previous behaviour of render file: was essentially the same as render template:, except that templates can be specified as an absolute path on the filesystem. This makes sense for historic reasons, but now render file: is almost exclusively used to render raw files (not .erb) like public/404.html. In addition to complicating the code in template/resolver.rb, I think the current behaviour is surprising to developers. This commit deprecates the existing "lookup a template from anywhere" behaviour and replaces it with "render this file exactly as it is on disk". Handlers will no longer be used (it will render the same as if the :raw handler was used), but formats (.html, .xml, etc) will still be detected (and will default to :plain). The existing render file: behaviour was the path through which Rails apps were vulnerable in the recent CVE-2019-5418. Although the vulnerability has been patched in a fully backwards-compatible way, I think it's a strong hint that we should drop the existing previously-vulnerable behaviour if it isn't a benefit to developers.
* | Remove :all symbol from Mime::ALLJohn Hawthorn2019-03-271-0/+13
|/ | | | | | .all isn't a valid file extension, so it shouldn't used as a symbol. This also makes Mime::ALL better match how */* is parsed from an Accept header.
* Address rubocop offencesRyuta Kamizono2019-03-211-1/+1
|
* Fix test broken by 04ae0b0b5e594e0bb99c5cd608921745977bcdcdRafael Mendonça França2019-03-191-3/+4
| | | | | This test was trying to set the exception_app in the wrapper proxy instead in the middleware itself.
* Fix a ContentNegotiation test descriptionSharang Dashputre2019-03-191-1/+1
|
* Only accept formats from registered mime typesJohn Hawthorn2019-03-102-6/+18
| | | | | [CVE-2019-5418] [CVE-2019-5419]
* Pass the template format to the digestorAaron Patterson2019-02-151-11/+14
| | | | | | | | | | | | | | | This commit passes the template format to the digestor in order to come up with a key. Before this commit, the digestor would depend on the side effect of the template renderer setting the rendered_format on the lookup context. I would like to remove that mutation, so I've changed this to pass the template format in to the digestor. I've introduced a new instance variable that will be alive during a template render. When the template is being rendered, it pushes the current template on to a stack, setting `@current_template` to the template currently being rendered. When the cache helper asks the digestor for a key, it uses the format of the template currently on the stack.
* Ensure that `redirect_back` with `fallback_location` to another host is allowedbogdanvlviv2019-01-251-0/+29
| | | | I would like to add those tests to prevent regression.
* Merge pull request #35018 from gmcgibbon/revert_redirect_to_allow_other_hostRafael França2019-01-223-42/+12
|\ | | | | Revert ensure external redirects are explicitly allowed
| * Revert ensure external redirects are explicitly allowedGannon McGibbon2019-01-223-42/+12
| |
* | Merge pull request #34952 from rails/template-stuffAaron Patterson2019-01-221-55/+0
|\ \ | |/ |/| Template Handler Refactoring
| * Templates should be eval'd in the context of an AV::Base objectAaron Patterson2019-01-171-55/+0
| |
* | Remove secret_token rack env and cookie upgrade codeRafael Mendonça França2019-01-172-3/+10
| | | | | | | | Now that secret_token was removed all this code is now dead.
* | Remove deprecated `fragment_cache_key` helper in favor of ↵Rafael Mendonça França2019-01-171-8/+0
| | | | | | | | `combined_fragment_cache_key`
* | Ensure external redirects are explicitly allowedGannon McGibbon2019-01-173-12/+42
| | | | | | | | Add `fallback_location` and `allow_other_host` options to `redirect_to`.
* | Revert "Don't handle params option in a special way in url_for helper"Rafael Mendonça França2019-01-162-1/+9
|/ | | | | | | | | | | This reverts commit e385e4678fc64be6e176c3bdac6641db9fe48d85. While this option was undocumented it exists to make possible to pass parameters to the route helpers that are reserved like `:domain`. While `url_for(domain: 'foo.com')` would generate a URL in the `foo.com` domain `url_for(params: { domain: 'foo.com' })` would generate a URL with `?domain=foo.com`.
* Enable `Lint/UselessAssignment` cop to avoid unused variable warnings (#34904)Ryuta Kamizono2019-01-092-4/+4
| | | | | | | | | | | | | | * Enable `Lint/UselessAssignment` cop to avoid unused variable warnings Since we've addressed the warning "assigned but unused variable" frequently. 370537de05092aeea552146b42042833212a1acc 3040446cece8e7a6d9e29219e636e13f180a1e03 5ed618e192e9788094bd92c51255dda1c4fd0eae 76ebafe594fc23abc3764acc7a3758ca473799e5 And also, I've found the unused args in c1b14ad which raises no warnings by the cop, it shows the value of the cop.
* Allow using combine the Cache-Control `public` and `no-cache` headersyuuji.yaginuma2019-01-071-0/+10
| | | | | | | | | | | | | | | | | Since #30367, if `no-cache` includes Cache-Control headers, special keys like `public`, `must-revalidate` are ignored. But in my understanding, `public` still need in case of want to cache authenticated pages. The authenticated pages to be cacheable, but still authenticated for every user, need to specify the `Cache-Control: public, no-cache`. For keys other than `public`, I did not know the case where it was necessary to use it in combination with `no-cache`, so I fixed that can be used only for `public`. Ref: https://www.mnot.net/cache_docs/#CACHE-CONTROL Fixes #34780.
* Make Rails Facebook-freeSasha Koss2018-12-241-2/+2
| | | If Basecamp is a Facebook-free business, then Rails should be Facebook-free framework.
* Remove unused methodsyuuji.yaginuma2018-12-231-26/+0
| | | | These were unused since 11af089cee0a0e744e267d32becfe2c66a586d31 and e35b98e6f5c54330245645f2ed40d56c74538902.
* Enable `Style/RedundantBegin` cop to avoid newly adding redundant begin blockRyuta Kamizono2018-12-213-50/+38
| | | | | | | | | | 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.
* Module#{define_method,alias_method,undef_method,remove_method} become public ↵Ryuta Kamizono2018-12-211-1/+1
| | | | | | since Ruby 2.5 https://bugs.ruby-lang.org/issues/14133
* Pass the correct value as JSONyuuji.yaginuma2018-12-191-1/+1
| | | | | | | | | | | | This takes away the following log. ``` Error occurred while parsing request parameters. Contents: {:foo=>"heyo"} ``` Pass the correct value as JSON
* Merge pull request #34737 from r7kamura/feature/test-case-params-nilKasper Timm Hansen2018-12-181-0/+12
|\ | | | | Allow nil params on controller HTTP test methods
| * Allow nil params on controller HTTP test methodsr7kamura2018-12-181-0/+12
| |
* | More exercise `test_running_prepended_before_and_after_action`Ryuta Kamizono2018-12-191-1/+3
|/ | | | | Just testing that `after_action` is invoked before `prepend_after_action`.
* Allow using parsed_body in ActionController::TestCaseTobias Bühlmann2018-12-161-0/+14
| | | | | | | | | | | | … by switching the initialzation of an appropriate response parser in `ActionDispatch::TestResponse` from eagerly to lazily. By doing so, the response parser can be correctly set for `ActionController::TestCase`, which doesn't include the content type header in the constructor but only sets it at a later time. Fixes #34676.
* Merge pull request #20865 from colavitam/only-except-behaviorRafael Mendonça França2018-11-191-0/+22
|\ | | | | | | :only and :except are now chained for routing resource(s)
| * :only and :except are now chained for routing resource(s)Michael Colavita2015-07-131-0/+22
| | | | | | | | | | | | | | | | | | | | | | Allow chaining the :only and :except options for routing resource(s). Previously, the following yielded routes for both show and destroy: resource :account, :only => [:show, :destroy], :except => :destroy This now yields only the show action. This chaining can be useful for passing optional :except options to code that makes use of the :only option (e.g. for a gem with its own routing methods).
* | Allow rescue from parameter parse errorsGannon McGibbon2018-11-132-0/+60
| | | | | | | | [Gannon McGibbon + Josh Cheek]
* | Fix `ActionController::Parameters#each_value` and add changelog entry to ↵Bogdan2018-10-151-2/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | this method (#34210) * Fix `ActionController::Parameters#each_value` `each_value` should yield with "value" of the params instead of "value" as an array. Related to #33979 * Add changelog entry about `ActionController::Parameters#each_value`. Follow up #33979
* | Revert "Merge pull request #33970 from rails/eager-url-helpers"schneems2018-10-031-4/+3
| | | | | | | | | | | | | | Until #34050 can be resolved This reverts commit 7f870a5ba2aa9177aa4a0e03a9d027928ba60e49, reversing changes made to 6556898884d636c59baae008e42783b8d3e16440.
* | Merge pull request #33256 from ilkkao/ilkkao/remove-unused-params-optionRyuta Kamizono2018-10-011-1/+1
|\ \ | | | | | | | | | Don't handle params option in a special way in url_for helper
| * | Don't handle params option in a special way in url_for helperIlkka Oksanen2018-08-201-1/+1
| | |
* | | Add `Style/RedundantFreeze` to remove redudant `.freeze`Yasuo Honda2018-09-292-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Since Rails 6.0 will support Ruby 2.4.1 or higher `# frozen_string_literal: true` magic comment is enough to make string object frozen. This magic comment is enabled by `Style/FrozenStringLiteralComment` cop. * Exclude these files not to auto correct false positive `Regexp#freeze` - 'actionpack/lib/action_dispatch/journey/router/utils.rb' - 'activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb' It has been fixed by https://github.com/rubocop-hq/rubocop/pull/6333 Once the newer version of RuboCop released and available at Code Climate these exclude entries should be removed. * Replace `String#freeze` with `String#-@` manually if explicit frozen string objects are required - 'actionpack/test/controller/test_case_test.rb' - 'activemodel/test/cases/type/string_test.rb' - 'activesupport/lib/active_support/core_ext/string/strip.rb' - 'activesupport/test/core_ext/string_ext_test.rb' - 'railties/test/generators/actions_test.rb'
* | | Merge pull request #33979 from lzap/masterRafael França2018-09-271-0/+18
|\ \ \ | | | | | | | | Added ActionController::Parameters.each_value methods