aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_controller/test_case.rb
Commit message (Collapse)AuthorAgeFilesLines
* 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
* 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.
* 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
* remove more direct `env` mutationsAaron Patterson2015-08-241-1/+3
|
* rm useless methodAaron Patterson2015-08-241-4/+0
| | | | superclass already has this method, so remove this one
* remove more `env` accessAaron Patterson2015-08-231-11/+19
|
* remove more env accessAaron Patterson2015-08-231-3/+3
|
* remove more env accessAaron Patterson2015-08-231-4/+6
|
* convert more `@env` access to get / set headerAaron Patterson2015-08-231-1/+1
|
* Fix master buildMarcin Olichwirowicz2015-08-171-0/+1
|
* Refactor how assign_parameters sets generated_path & query_string_keyseileencodes2015-08-151-8/+20
| | | | | | | | | | | | | This is part of a larger refactoring on controller tests. We needed to move these methods here so that we could get rid of the `|| key == :action || key == :controller` in `assign_parameters`. We know this is ugly and intend to fix it but for now `generate_extras` needs to be used in the two methods to access the path and the query_string_keys. We're adding `:controller` and `:action` to the `query_string_keys` because we always need a controller and action. If someone passed `action` or `controller` in in there test they are unambigious - we know they have to go into the query params.
* Rename `extra_keys` variables to `query_string_keys`eileencodes2015-08-081-2/+2
| | | | | | `extra_keys` is a confusing variable name because it's not clear what is "extra". This renames it to `query_string_keys` so it's clear that the "extra" is just the query string.
* Adds missing argument handling for ActionController::TestSession toMatthew Gerrior2015-08-061-0/+4
| | | | allow testing controllers that use session#fetch with a default value.
* Rack implements `redirect?` so we don't need itAaron Patterson2015-07-141-3/+0
| | | | Rack [already implements `redirect?` on the response object](https://github.com/rack/rack/blob/1569a985e17d9caaf94d0e97d95ef642c4ab14ba/lib/rack/response.rb#L141) so we don't need to implement our own.
* Change AC::TestResponse to AD::TestResponsePrem Sichanugrist2015-07-141-1/+1
| | | | | ActionController::TestResponse was removed in d9fe10c and caused a test failure on Action View as its test case still refers to it.
* only have one TestResponse classAaron Patterson2015-07-131-4/+1
|
* move buffer caching on to the bufferAaron Patterson2015-07-131-4/+0
|
* we don't really need an extra method to set the script nameAaron Patterson2015-07-101-5/+1
|
* Remove useless conditionalAaron Patterson2015-07-101-12/+0
| | | | PATH_INFO is already set, so this branch will never execute.
* default `PATH_INFO` to the generated pathAaron Patterson2015-07-101-1/+2
| | | | | | we were already generating a path in the previous code (it was just not returned), so lets just use the already computed path to popluate the PATH_INFO header
* always default the SCRIPT_NAME to whatever is on the controllerAaron Patterson2015-07-101-1/+1
|
* remove useless ivar clearingAaron Patterson2015-07-101-6/+0
| | | | Since we only work with new instances, these ivars will not be set.
* call the `path_parameters=` setter rather than rely on mutationsAaron Patterson2015-07-101-1/+3
| | | | | We should call the setter on `path_parameters` so that we know the hash will only contain the values that we've set.
* start collecting `env` mutationsAaron Patterson2015-07-101-5/+3
| | | | | I'd like to put all env mutations together so we can understand how to change this code to call `call` on the controller
* Parameters are converted to a query stringAaron Patterson2015-07-101-17/+0
| | | | | Since parameters are converted to a query string, they will automatically be turned in to strings by the query parser
* no more HWIAAaron Patterson2015-07-101-1/+1
| | | | | non_path_parameters is used internally (it never escapes this method) so we should be able to safely use a regular hash.
* remove param dup'ing logicAaron Patterson2015-07-101-8/+0
| | | | | since we are serializing parameters, we don't need to do all the dup checks on each object.
* encode / decode parameters before assigning them to the requestAaron Patterson2015-07-101-5/+58
| | | | | | We should roundtrip the parameters through their respective encoders / decoders so that the controller will get parameters similar to what they actually get in a real world situation
* set parameters as a query stringAaron Patterson2015-07-091-6/+9
| | | | | | We should convert request parameters to a query string, then let the request object parse that query string. This should give us results that are more similar to the real-world
* build and assign parameters rather than rely on mutationsAaron Patterson2015-07-081-1/+15
| | | | | We should assign parameters to the request object rather than mutate the hash that is returned by `query_parameters` or `request_parameters`
* assign the cookie hash on request allocationAaron Patterson2015-07-081-1/+1
| | | | this prevents mutations from being available globally
* request objects are no longer recycledAaron Patterson2015-07-081-10/+8
| | | | | | Instead of trying to manually clear out a request object, lets just allocate a new one. The rack ENV is reused and cleaned (still), but the request object is not.
* add a new constructor for allocating test requestsAaron Patterson2015-07-081-11/+13
|
* pass the starting env and session to build_requestAaron Patterson2015-07-081-3/+3
|
* pass the session and env in to the test requestAaron Patterson2015-07-081-4/+8
|
* allocate new responses rather than recycling themAaron Patterson2015-07-081-12/+5
| | | | | There is no reason to "recycle" response objects when we can just allocate a new one.
* pass cookies from the jar in the HTTP_COOKIE headereileencodes2015-07-071-8/+7
| | | | | we should be pushing the cookies in via headers rather than maintaining some object and "recycling" it.
* Send cookies with requesteileencodes2015-07-071-1/+4
|
* Update RDoc for ActionController::TestCase for kwargs.Victor Costan2015-06-121-1/+1
|
* Merge pull request #20138 from tgxworld/deprecated_assert_templateRafael Mendonça França2015-06-011-6/+0
|\ | | | | Deprecate `assert_template` and `assigns()`.
| * Remove `assigns` and `assert_template`.Guo Xiang Tan2015-05-301-6/+0
| |
* | Use `any?` rather than `present?` to check argseileencodes2015-05-311-1/+1
|/ | | | | | It's better to use Ruby methods when possible over methods defined by Active Support because then it does not need to rely on any dependencies.
* Remove unused code.Guo Xiang Tan2015-05-291-2/+0
| | | | Code was moved into the `assign` method.
* Merge pull request #19808 from byroot/action-parameterRafael Mendonça França2015-05-271-15/+12
|\ | | | | [PoC] Stop shadowing parameters named `action`
| * Allow to parameters named `action` or `controller` from AC::TestCase helpersJean Boussier2015-04-181-15/+12
| |
* | Move `TemplateAssertions` to their own fileeileencodes2015-05-091-188/+1
| | | | | | | | | | | | | | | | | | | | | | This moves `TemplateAssertions` out of the `test_case.rb` file and into it's own `template_assertions` file. It still inherits from `ActionController`.` This is in preparation for combining the code for Integration tests and Controller tests. This will need to be it's own file to be added to the `requires` for Integration tests. This does not currently change ANY behavior, just moving it for access later on.
* | Use `args` instead of `*args` in `kwargs_request?` methodeileencodes2015-05-021-3/+3
|/ | | | | | `*args` is not required here and should be avoided when not necessary because `*args` are slower than `args` and create unnecessary array allocations.
* Revert "Merge pull request #19682 from ↵Santiago Pastorino2015-04-121-5/+2
| | | | | | | supercaracal/fix_force_ssl_redirection_flash_error" This reverts commit d215620340be7cb29e2aa87aab22da5ec9e6e6a7, reversing changes made to bbbbfe1ac02162ecb5e9a7b560134a3221f129f3.
* fix fails to force_ssl_redirection if session_store is disabledTaishi Kasuga2015-04-091-2/+5
|