aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_controller
Commit message (Collapse)AuthorAgeFilesLines
* Fix deadlock that can occur when child live thread tries to load a constant ↵Alex Chinn2016-08-151-1/+6
| | | | after writing to the stream.
* AC::Metal is already defining default encoding as UTF 8, let's reuse it.Prathamesh Sonpatki2016-08-141-1/+1
|
* Mark method as nodocRafael Mendonça França2016-08-121-3/+3
| | | | They are not part of the public API
* [ci skip] Add documentation to Parameter EncodingAlex Kitchens2016-08-111-0/+1
|
* Merge pull request #26092 from kerrizor/kerrizor/force-param-encodingAaron Patterson2016-08-104-6/+42
|\ | | | | Allow specifying encoding of parameters by action
| * Allow specifying encoding of parameters by actionKerri Miller2016-08-094-6/+42
| | | | | | | | | | At GitHub we need to handle parameter encodings that are not UTF-8. This patch allows us to specify encodings per parameter per action.
* | Remove unused methodAndrew White2016-08-101-5/+0
|/ | | | | | | In c546a2b parameter handling in AC test cases was changed to round tripping through encoders/decoders so that they matched reality and in 0adb8f8 the old methods were removed but the `html_format?` method was overlooked.
* revises more Lint/EndAlignment offensesXavier Noria2016-08-081-1/+1
|
* code gardening: removes redundant selfsXavier Noria2016-08-085-8/+8
| | | | | | | | | A few have been left for aesthetic reasons, but have made a pass and removed most of them. Note that if the method `foo` returns an array, `foo << 1` is a regular push, nothing to do with assignments, so no self required.
* Add back unintentionally removed newline.Kasper Timm Hansen2016-08-071-0/+1
|
* Modify LogSubscriber for single partial's cache message.Stan Lo2016-08-081-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Implement naive partial caching mechanism. Add test for LogSubscriber Use ActionView::Base#log_payload to store log_subscriber's payload, so we can pass cache result into it. Fixed tests Remove useless settings Check if #log_payload exists before calling it. Because other classes also includes CacheHelper but don't have is attribute Use @log_payload_for_partial_reder instead of #log_payload to carry ActionView's payload. Update test's hash syntax Add configuration to enable/disable fragment caching logging Remove unless test and add new test to ensure cache info won't effect next rendering's log Move :enable_fragment_cache_logging config from ActionView to ActionPack Apply new config to tests Update actionview's changelog Update configuration guide Improve actionview's changelog Refactor PartialRenderer#render and log tests Mute subscriber's log instead of disabling instrumentation. Fix typo, remove useless comment and use new hash syntax Improve actionpack's log_subscriber test Fix rebase mistake Apply new config to all caching intstrument actions
* applies remaining conventions across the projectXavier Noria2016-08-065-5/+0
|
* normalizes indentation and whitespace across the projectXavier Noria2016-08-0610-184/+184
|
* modernizes hash syntax in actionpackXavier Noria2016-08-068-27/+27
|
* applies new string literal convention in actionpack/libXavier Noria2016-08-0622-130/+130
| | | | | The current code base is not uniform. After some discussion, we have chosen to go with double quotes by default.
* Move the YAML hook closer to `init_with`.Kasper Timm Hansen2016-08-021-8/+9
| | | | | Looked odd, so completely detached from the other necessary part of the implementation.
* Replace implicit formats with a case statement.Kasper Timm Hansen2016-08-021-7/+8
| | | | | | The coder that Psych passes in has a `tag` method we can use to detect which serialization format we're reviving for. Use it and make it clearer alongside the `load_tags` fiddling.
* Let Psych 2.0.9+ deserialize 2.0.8 serialized parameters.Kasper Timm Hansen2016-08-021-2/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | If we were to serialize an `ActionController::Parameters` on Psych 2.0.8, we'd get: ```yaml --- !ruby/hash:ActionController::Parameters key: :value ``` Because 2.0.8 didn't store instance variables, while 2.0.9 did: https://github.com/tenderlove/psych/commit/8f84ad0fc711a82a1040def861cb121e8985fd4c That, coupled with 2.0.8 calling `new` instead of `allocate` meant parameters was deserialized just fine: https://github.com/tenderlove/psych/commit/af308f8307899cb9e1c0fffea4bce3110a1c3926 However, if users have 2.0.8 serialized parameters, then upgrade to Psych 2.0.9+ and Rails 5, it would start to blow up because `initialize` will never be called, and thus `@parameters` will never be assigned. Hello, `NoMethodErrors` on `NilClass`! :) To fix this we register another variant of the previous serialization format and take it into account in `init_with`. I've tested this in our app and previously raising code now deserializes like a champ. I'm unsure how to test this in our suite because we use Psych 2.0.8 and don't know how to make us use 2.0.9+ for just one test.
* Make Parameters support legacy YAML encodings.Kasper Timm Hansen2016-08-011-0/+19
| | | | | | | | | | | | | | | | | | | | | By changing ActionController::Parameter's superclass, Rails 5 also changed the YAML serialization format. Since YAML doesn't know how to handle parameters it would fallback to its routine for the superclass, which in Rails 4.2 was Hash while just Object in Rails 5. As evident in the tags YAML would spit out: 4.2: !ruby/hash-with-ivars:ActionController::Parameters 5.0: !ruby/object:ActionController::Parameters Thus when loading parameters YAML from 4.2 in Rails 5, it would parse a hash dump as it would an Object class. To fix this we have to provide our own `init_with` to be aware of the past format as well as the new one. Then we add a `load_tags` mapping, such that when the YAML parser sees `!ruby/hash-with-ivars:ActionController::Parameters`, it knows to call our `init_with` function and not try to instantiate it as a normal hash subclass.
* Reset rack.input when the environment is scrubbed for the next requestNick Sieger2016-07-271-0/+1
| | | | | | | | | | | | | | | | | Before this change, posted parameters would leak across requests. The included test case failed like so: 1) Failure: TestCaseTest#test_multiple_mixed_method_process_should_scrub_rack_input: --- expected +++ actual @@ -1 +1 @@ -{"bar"=>"an bar", "controller"=>"test_case_test/test", "action"=>"test_params"} +{"foo"=>"an foo", "bar"=>"an bar", "controller"=>"test_case_test/test", "action"=>"test_params"} An argument could be made that this situation isn't encountered often and that one should limit the number of requests per test case, but I still think the parameter leaking is an unexpected side-effect.
* Fix incorrect indentation in method comment [ci skip]Junya Ogura2016-07-211-3/+3
|
* Fix adding implicitly rendered namespaced template digests to ETagsJavan Makhmali2016-07-131-1/+1
|
* Trust `Object#dup` in `ActionController::Parameters`, using ↵Tim Rogers2016-07-081-15/+1
| | | | | | `#initialize_copy` to manually duplicate the underlying parameters hash It looks like `ActionController::Parameters#dup` is leftover from when the class inherited from `Hash`. We can just trust `#dup`, which already copies the `@permitted` instance variable (confirmed by tests). We still define a `#initialize_copy` to make `@parameters` a copy that can be mutated without affecting the original instance.
* Changes to a dupped `ActionController::Parameters` mutate the originalTim Rogers2016-07-071-0/+5
| | | | | | | | | | | | | | When `ActionController::Parameters` is duplicated with `#dup`, it doesn't create a duplicate of the instance variables (e.g. `@parameters`) but rather maintains the reference (see <http://ruby-doc.org/core-2.3.1/Object.html>). Given that the parameters object is often manipulated as if it were a hash (e.g. with `#delete` and similar methods), this leads to unexpected behaviour, like the following: ``` params = ActionController::Parameters.new(foo: "bar") duplicated_params = params.dup duplicated_params.delete(:foo) params == duplicated_params ``` This fixes the bug by defining a private `#initialize_copy` method, used internally by `#dup`, which makes a copy of `@parameters`.
* [ci skip] Add 'params' formatting in ActionController::BaseAlex Kitchens2016-06-301-4/+4
|
* Fix adding implicitly rendered template digests to ETagsJavan Makhmali2016-06-281-1/+7
| | | | Signed-off-by: Jeremy Daer <jeremydaer@gmail.com>
* `params.permitted?` is false by defaultJon Moss2016-06-231-0/+2
| | | | | In the docs: "+permit_all_parameters+ - If it's +true+, all the parameters will be permitted by default. The default is +false+."
* Update ActionController::Parameters documentation [ci skip]Benjamin Quorning2016-06-221-19/+18
| | | | | | | | | | The changes in this commit are twofold: 1. The examples showing `#require` accepting two arguments were wrong - you have to wrap the arguments (two, or more) in an array. 2. `ActionController::Parameters` has an `#inspect` method now (since https://github.com/rails/rails/pull/23732), and the documentation should reflect that.
* Fix typo in ActionController::Renderer [ci skip]Alex Kitchens2016-06-101-1/+1
|
* Clean up the test request/response even after an exceptionMatthew Draper2016-06-011-23/+26
|
* Tiny document fixes [ci skip]Robin Dupret2016-05-301-1/+1
| | | | | | Add a missing capital letter and avoid using absolute links to the API because they may refer to out-dated documentation on the Edge site.
* ActionController::Parameters: Fix #dig doc codeChristian Wesselhoeft2016-05-291-5/+5
| | | This example code wasn't getting wrapped in a `<code>` tag due to incorrect indentation.
* fix incorrect class name [ci skip]yuuji.yaginuma2016-05-281-1/+1
|
* Respect `log_warning_on_csrf_failure` setting for all CSRF failuresMatthew Caruana Galizia2016-05-231-1/+3
| | | | | | | | | | | | CSRF verification for non-XHR GET requests (cross-origin `<script>` tags) didn't check this flag before logging failures. Setting `config.action_controller.log_warning_on_csrf_failure = false` now disables logging for these CSRF failures as well. Closes #25086. Signed-off-by: Jeremy Daer <jeremydaer@gmail.com>
* Action Mailer: Declarative exception handling with `rescue_from`.Jeremy Daer2016-05-151-12/+1
| | | | | | | | | | | | | | | | | | | | | | | Follows the same pattern as controllers and jobs. Exceptions raised in delivery jobs (enqueued by `#deliver_later`) are also delegated to the mailer's rescue_from handlers, so you can handle the DeserializationError raised by delivery jobs: ```ruby class MyMailer < ApplicationMailer rescue_from ActiveJob::DeserializationError do … end ``` ActiveSupport::Rescuable polish: * Add the `rescue_with_handler` class method so exceptions may be handled at the class level without requiring an instance. * Rationalize `exception.cause` handling. If no handler matches the exception, fall back to the handler that matches its cause. * Handle exceptions raised elsewhere. Pass `object: …` to execute the `rescue_from` handler (e.g. a method call or a block to instance_exec) against a different object. Defaults to `self`.
* Helpers doc grammar fix [skip ci]Jon Atack2016-05-071-2/+2
|
* Merge pull request #24029 from ↵Sean Griffin2016-05-062-8/+10
|\ | | | | | | | | | | | | rthbound/dont-call-each-when-calling-body-on-response Dont call each when calling body on response to fix #23964 Fixes #23964
| * Fixes #23964Ryan T. Hosford2016-03-132-8/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Adds #each_chunk to ActionDispatch::Response. it's a method which will be called by ActionDispatch::Response#each. - Make Response#each a proper method instead of delegating to @stream - In Live, instead of overriding #each, override #each_chunk. - `#each` should just spit out @str_body if it's already set - Adds #test_set_header_after_read_body_during_action to prove this fixes #23964 - Adds #test_each_isnt_called_if_str_body_is_written to ensure #each_chunk is not called when @str_body is available - Call `@response.sent!` in AC::TestCase's #perform so a test response acts a bit more like a real response. Makes test that call `#assert_stream_closed` pass again. - Additionally assert `#committed?` in `#assert_stream_closed` - Make test that was calling @response.stream.each pass again by calling @response.each instead.
* | Implement helpers proxy in controller instance levelRafael Mendonça França2016-05-052-2/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | It is a common pattern in the Rails community that when people want to :xa use any kind of helper that is defined inside app/helpers they includes the helper module inside the controller like: module UserHelper def my_user_helper # ... end end class UsersController < ApplicationController include UserHelper def index render inline: my_user_helper end end This has problem because the helper can't access anything that is defined in the view level context class. Also all public methods of the helper become available in the controller what can lead to undesirable methods being routed and behaving as actions. Also if you helper depends on other helpers or even Action View helpers you need to include each one of these dependencies in your controller otherwise your helper is not going to work. We already have a helpers proxy at controller class level but that proxy doesn't have access to the instance variables defined in the controller. With this new instance level helper proxy users can reuse helpers in the controller without having to include the modules and with access to instance variables defined in the controller. class UsersController < ApplicationController def index render inline: helpers.my_user_helper end end
* | Move protected instance variable to the right placeRafael Mendonça França2016-05-051-3/+4
| | | | | | | | | | | | | | | | | | There were a lot of protected instance variables in AbsctractController::Rendering that were related to Action Controller and Action View. Moving to ActionController::Base's protected instance list we make it closer to where they are really defined.
* | Fix some typos in comments.Joe Rafaniello2016-05-041-1/+1
| | | | | | | | [ci skip]
* | Merge pull request #24845 from tomkadwill/action_controller_typosRafael França2016-05-042-3/+3
|\ \ | | | | | | Fix actionpack typos [ci skip]
| * | Fix actionpack typos [ci skip]Tom Kadwill2016-05-042-3/+3
| | |
* | | Merge pull request #24777 from tomkadwill/action_pack_typos_3Vipul A M2016-04-302-5/+5
|\ \ \ | | | | | | | | Fix actionpack typos [ci skip]
| * | | Fix actionpack typos [ci skip]Tom Kadwill2016-04-302-5/+5
| |/ /
* | | Merge pull request #24641 from rafaelfranca/fix-per-form-token-with-full-urlJeremy Daer2016-04-251-1/+2
|\ \ \ | | | | | | | | | | | | Discart the schema and host information when building the per-form token
| * | | Discart the schema and host information when building the per-form tokenRafael Mendonça França2016-04-201-1/+2
| |/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When the token is generated by the form we were using the schema and host information while only using the path to compare if the action was the same. This was causing the token to be invalid. To fix this we use the same information to generate the token and check it. Fix #24257
* | | Merge pull request #24697 from tomkadwill/action_pack_typos_2Vipul A M2016-04-234-10/+10
|\ \ \ | | | | | | | | Actionpack documentation typos [ci skip]
| * | | Actionpack documentation typos [ci skip]Tom Kadwill2016-04-234-10/+10
| |/ /
* | | Merge pull request #24669 from tomkadwill/action_pack_typosVipul A M2016-04-221-10/+9
|\ \ \ | | | | | | | | Actioncable and Actionpack documentation typos [ci skip]