aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_controller
Commit message (Collapse)AuthorAgeFilesLines
* move the Header hash to the super classAaron Patterson2015-09-241-27/+0
| | | | | | | I want to move the header hash to the super request object in order to consolidate behavior. We should be switching out buffering strategies rather than header strategies since things like "mutating headers after send" is an error in both cases (buffering vs streaming).
* stop directly setting headers on the controllerAaron Patterson2015-09-231-5/+0
| | | | | again, since we are going through the test harness, all this is done for us.
* stop constructing a request object in this setterAaron Patterson2015-09-231-1/+0
| | | | | Since we just go through the normal test harness that sets up a request for us, we don't need to do this anymore.
* stop applying default headers in ActionDispatch::ResponseAaron Patterson2015-09-233-6/+6
| | | | | | | | | | I'm making this change so that I can construct response objects that *don't* have the default headers applied. For example, I would like to construct a response object from the return value of a controller. If you need to construct a response object with the default headers, then please use the alternate constructor: `ActionDispatch::Response.create`
* Document Bearer prefix for Authorization header [ci skip]Eliot Sykes2015-09-231-5/+7
|
* Updated Mime Negotiations docs [ci skip]amitkumarsuroliya2015-09-231-2/+2
| | | As we all know that Accessing mime types via constants is deprecated. Now, we are using `Mime::Type[:JSON]` instead of `Mime::JSON`
* don't deal with `nil` valuesAaron Patterson2015-09-221-1/+3
| | | | | We can know whether or not there is a content type object, and just exit early. There is no need to `try` so hard.
* swap upcase and to_symAaron Patterson2015-09-211-1/+1
|
* stop calling deprecated methodsAaron Patterson2015-09-214-14/+14
| | | | | We should be asking the mime type method for the mime objects rather than via const lookup
* remove outdated commentAaron Patterson2015-09-181-4/+0
| | | | | all parameter parsing is done on the request object now, so we don't need to worry about at ParamParser middleware
* all parameter parsing is done through the request object now.Aaron Patterson2015-09-181-1/+1
|
* let the request object handle parsing XML postsAaron Patterson2015-09-181-2/+9
| | | | | The test request object will handle parsing XML posts now, so we don't need to eagerly parse them in the test harness
* remove setting request parameters for JSON requestsAaron Patterson2015-09-181-2/+0
| | | | | The request object will automatically parse these in the `parse_formatted_parameters` method, so we don't have to worry about it.
* Use rack.session_options instead of directly change envJuanito Fatas2015-09-161-1/+1
|
* fewer direct env manipulationsAaron Patterson2015-09-151-1/+1
| | | | this commit removes some direct access to `env`.
* allocate request objects with the env hash, set routes on the requestAaron Patterson2015-09-152-9/+6
| | | | | This commit is to abstract the code away from the env hash. It no longer needs to have the routes key hard coded.
* only "normalize" onceAaron Patterson2015-09-141-1/+1
|
* create a new renderer instance on calls to `for`Aaron Patterson2015-09-141-39/+46
| | | | | | | | | | | | This changes the renderer class to store the controller and defaults as an instance variable rather than allocating a new class. You can create a new renderer with an new env by calling `Renderer#new` or use new defaults by calling `Renderer#with_defaults` and saving the return value somewhere. Also I want to keep the `env` private since I would like to change the keys in the future. This commit only translates particular keys that the user requested.
* eagerly allocate the renderer objectAaron Patterson2015-09-142-9/+6
| | | | | this means the reader doesn't need to lock, but does have the added cost of a new object created for every controller
* initialize `@renderer` to avoid ivar warningsAaron Patterson2015-09-141-1/+8
|
* add a lock when allocating the rendererAaron Patterson2015-09-141-1/+5
| | | | | The controller class is shared among threads, so we need to lock when allocating the Renderer.
* Merge pull request #21584 from claudiob/remove-hawd-docClaudio B.2015-09-101-3/+2
|\ | | | | Remove wrong doc line about AC::Parameters
| * Remove wrong doc line about AC::Parametersclaudiob2015-09-101-3/+2
| | | | | | | | | | AC::Parameters does not inherit from HashWithIndifferentAccess since #20868 by @sikachu
* | Handle Content-Types that are not :json, :xml, or :url_encoded_formeileencodes2015-09-091-2/+5
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In c546a2b this was changed to mimic how the browser behaves in a real situation but left out types that were registered. When this was changed it didn't take `text/plain` or `text/html` content types into account. This is a problem if you're manipulating the `Content-Type` headers in your controller tests, and expect a certain result. The reason I changed this to use `to_sym` is because if the `Content-Type` is not registered then the symbol will not exist. If it's one of the special types we handle that specifically (:json, :xml, or :url_encoded_form). If it's any registered type we handle it by setting the `path_parameters` and then the `request_parameters`. If the `to_sym` returns nil an error will be thrown. If the controller test sets a `Content-Type` on the request that `Content-Type` should remain in the header and pass along the filename. For example: If a test sets a content type on a post ``` @request.headers['CONTENT_TYPE'] = 'text/plain' post :create, params: { name: 'foo.txt' } ``` Then `foo.txt` should be in the `request_parameters` and params related to the path should be in the `path_parameters` and the `Content-Type` header should match the one set in the `@request`. When c546a2b was committed `text/plain` and `text/html` types were throwing a "Unknown Content-Type" error which is misleading and incorrect. Note: this does not affect how this is handled in the browser, just how the controller tests handle setting `Content-Type`.
* push content_type assigment in to metalAaron Patterson2015-09-082-5/+7
| | | | | everything above metal really doesn't care about setting the content type, so lets rearrange these methods to be in metal.
* avoid useless string allocationsAaron Patterson2015-09-081-1/+1
| | | | | | | _set_content_type only does something when there is a request object, otherwise the return value of _get_content_type is always ignored. This commit moves everything to the module that has access to the request object so we'll never to_s unless there is a reason
* use accessors instead of manipulating the hashAaron Patterson2015-09-081-2/+2
| | | | | in the future I would like to make the header hash read only (or at least remove guarantees that mutations will do anything).
* stop using deprecated Abstract::ID classAaron Patterson2015-09-041-1/+1
|
* stop inheriting from Rack::RequestAaron Patterson2015-09-041-4/+4
| | | | | | Just include the modules necessary in the Request object to implement the things we need. This should make it easier to build delegate request objects because the API is smaller
* typo "description not clear corrected with proper description and ↵kishore-mohan2015-09-021-2/+2
| | | | action_controller_overview file Rails' -> Rails" [ci skip]
* Fix bug where cookies mutated by request were not persistedeileencodes2015-09-011-0/+1
| | | | | | | | | | | | | | | With changes made in 8363b8 and ae29142 cookies that are mutated on the request like `cookies.signed = x` were not retained in subsequent tests, breaking cookie authentiation in controller tests. The test added demonstrates the issue. The reason we need to select from non-deleted cookies is because without checking the `@delete_cookies` the `cookie_jar` `@cookies` will send the wrong cookies to be updated. The code must check for `@deleted_cookies` before sending an `#update` with the requests cookie_jar cookies. This follows how the cookie_jar cookies from the request were updated before these changes.
* Merge pull request #21298 from rodzyn/remove_dead_codeRafael Mendonça França2015-09-011-4/+0
|\ | | | | Remove dead code
| * Remove dead codeMarcin Olichwirowicz2015-08-191-4/+0
| |
* | add a method for getting the http auth saltAaron Patterson2015-08-291-2/+2
| |
* | env to get_header conversionAaron Patterson2015-08-291-1/+1
| |
* | fixes example for consistency [ci skip]Xavier Noria2015-08-291-3/+3
| |
* | swaps words [ci skip]Xavier Noria2015-08-291-1/+1
| |
* | revamps the docs of strong params require [ci skip]Xavier Noria2015-08-291-9/+40
| | | | | | | | References #19565.
* | revises 877e42eXavier Noria2015-08-281-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * A string in the example lacked quotes. * The tests asserted stuff about :last_name, whereas test params do not have that key. * But, the first one passed, why? After hitting my head against the wall and doing some obscure rituals realized the new #require had an important typo, wanted to iterate over the array argument (key), but it ran over its own hash keys (method #keys). * Modified the test to prevent the same typo to happen again. * The second test assigned to an unused variable safe_params that has been therefore removed. * Grammar of the second test description. * Since I was on it, reworded both test descriptions.
* | [Feature] params.require requires array of paramsGaurish Sharma2015-08-281-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This PR adds ability to accept arrays which allows you to require multiple values in one method. so instead of this: ```ruby params.require(:person).require(:first_name) params.require(:person).require(:last_name) ``` Here it will be one line for each params, so say if I require 10params, it will be 10lines of repeated code which is not dry. So I have added new method which does this in one line: ```ruby params.require(:person).require([:first_name, :last_name]) ``` Comments welcome
* | Revert "this always sets :public to false, so just do that"Aaron Patterson2015-08-271-1/+1
| | | | | | | | | | | | This reverts commit cae2b5bb59212961c4a35c939381ebece48d1177. I am an idiot.
* | this always sets :public to false, so just do thatAaron Patterson2015-08-271-1/+1
| |
* | Merge pull request #21384 from ↵Yves Senn2015-08-271-2/+2
|\ \ | | | | | | | | | | | | jeremyf/updating-ActionController-TestSession-to-behave-as-a-hash-with-indifferent Updating TestSession to access with indifference
| * | Updating TestSession to access with indifferenceJeremy Friesen2015-08-261-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The following Rails code failed (with a `KeyError` exception) under test: ```ruby class ApplicationController < ActionController::Base def user_strategy # At this point: # ```ruby # session == { # "user_strategy"=>"email", # "user_identifying_value"=>"hello@world.com" # } # ``` if session.key?(:user_strategy) session.fetch(:user_strategy) end end end ``` When I checked the session's keys (`session.keys`), I got an array of strings. If I accessed `session[:user_strategy]` I got the expected `'email'` value. However if I used `session.fetch(:user_strategy)` I got a `KeyError` exception. This appears to be a Rails 4.2.4 regression (as the code works under Rails 4.2.3). Closes #21383
* | | only call self.content_type= when there is a responseAaron Patterson2015-08-262-3/+6
| | | | | | | | | | | | | | | Apparently the AbstractController (whatever "abstract" means) is expected to work without a request and response.
* | | Pull `plain` content type handling up to `render`Aaron Patterson2015-08-261-6/+2
| | | | | | | | | | | | | | | `render` is the only possible source for the `plain` option. Pulling the conditional up to the `render` method removes far away conditionals
* | | stop passing the options hash to `_process_format`Aaron Patterson2015-08-261-2/+2
| | | | | | | | | | | | | | | | | | We don't need to pass the full hash just to pull one value out. It's better to just pass the value that the method needs to know about so that we can abstract it away from "options"
* | | remove RackDelegation moduleAaron Patterson2015-08-2610-66/+16
| | | | | | | | | | | | | | | | | | Since all controller instances are required to have a request and response object, RackDelegation is no longer needed (we always have to delegate to the response)
* | | remove useless methodAaron Patterson2015-08-261-5/+0
| | | | | | | | | | | | | | | the subclass sets the body on the response object, so we don't need the superclass doing it too
* | | include ActionView::Rendering in the minimal controllerAaron Patterson2015-08-261-1/+1
| | | | | | | | | | | | without this module, the content type is not set correctly