aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/controller/test_case_test.rb
Commit message (Collapse)AuthorAgeFilesLines
* Remove unused test controller actionAndrew White2016-02-161-5/+0
|
* Move test for #22828 into it's own testAndrew White2016-02-161-2/+10
| | | | | | The `cookies` hash isn't updated with the value generated by the output from `to_header` so it wasn't testing anything. Rendering the cookie value in the controller makes sure that the escaping is actually working.
* Escape cookie's key and value in ActionController::TestCaseTakayuki Matsubara2015-12-301-0/+7
| | | | | Get an incorrect cookie value in controller action method if cookie value contains an escapable string.
* Prevent ActionController::Parameters from being passed to url_for directlyJean Boussier2015-12-151-1/+1
|
* switch to JSON.dump to avoid infinite recursionAaron Patterson2015-10-291-1/+1
|
* Write the cookie jar it was not committed in TestCaseRafael Mendonça França2015-10-281-1/+1
| | | | | | | | | | | | | | | | | | | For ActionController::Base we write the cookies in a middleware if it was not yet committed no matter if the response was committed or not. [1] For ActionController::Live we write the cookies before the response is committed. [2] We already mimic ActionController::Live in ActionController::TestCase but we don't mimic the ActionController::Base behavior because we were checking if the response was committed before writing the cookies. Now we are matching the behavior of the middleware and writing the cookies if it was not written before. [1]: https://github.com/rails/rails/blob/80c6b901d4d87cee610ab0a438ff6e3c6bf118d1/actionpack/lib/action_dispatch/middleware/cookies.rb#L599-L604 [2]: https://github.com/rails/rails/blob/80c6b901d4d87cee610ab0a438ff6e3c6bf118d1/actionpack/lib/action_controller/metal/live.rb#L218-L223
* don't access the response object before a request was madeAaron Patterson2015-09-231-1/+10
| | | | | | | It doesn't make sense to access the response object before a request is made (how was a response object created without making a request?) This commit splits testing default headers and default header mutation tests and removes access to the pre-request response object.
* Handle Content-Types that are not :json, :xml, or :url_encoded_formeileencodes2015-09-091-0/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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`.
* remove more direct `env` mutationsAaron Patterson2015-08-241-1/+1
|
* Get rid of mocha tests - part 1Marcin Olichwirowicz2015-08-241-8/+10
|
* Stop using deprecated `render :text` in testPrem Sichanugrist2015-07-171-26/+26
| | | | | | | | | 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.
* use `Rack::Test::UploadedFile` when uploading filesAaron Patterson2015-07-091-2/+2
| | | | | We should use rack-test's upload file objects on the test side so that we will be able to correctly generate mime blob posts in the future
* set parameters as a query stringAaron Patterson2015-07-091-1/+1
| | | | | | 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
* use JSON to communicate between the controller and the testsAaron Patterson2015-07-091-12/+12
|
* build and assign parameters rather than rely on mutationsAaron Patterson2015-07-081-3/+3
| | | | | We should assign parameters to the request object rather than mutate the hash that is returned by `query_parameters` or `request_parameters`
* request objects are no longer recycledAaron Patterson2015-07-081-6/+0
| | | | | | 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.
* let the superclass build the request and responseAaron Patterson2015-07-081-5/+2
| | | | | We should leverage the request / response objects that the superclass has already allocated for us.
* Remove `assigns` and `assert_template`.Guo Xiang Tan2015-05-301-41/+0
|
* Deprecate `:nothing` option for render methodMehmet Emin İNAÇ2015-05-281-3/+3
| | | | `head` method works similar to `render` method with `:nothing` option
* Merge pull request #19808 from byroot/action-parameterRafael Mendonça França2015-05-271-0/+20
|\ | | | | [PoC] Stop shadowing parameters named `action`
| * Allow to parameters named `action` or `controller` from AC::TestCase helpersJean Boussier2015-04-181-0/+20
| |
* | Issue#17703 Test case for tempfile attributeSiva Gollapalli2015-04-161-0/+5
|/ | | | | | | | | | + To avoid regression I am adding this test case on action pack Changed to assert from assert_equal + Added msg to assertion Modified msg
* Fix default headers in test responsesJeremy Kemper2015-02-251-0/+46
| | | | | | | Fixes regression in #18423. Merge default headers for new responses, but don't merge when creating a response from the last session request. hat tip @senny :heart:
* Merge pull request #18771 from kirs/deprecate-xhrRafael Mendonça França2015-02-051-3/+18
|\ | | | | Migrating xhr methods to keyword arguments syntax
| * Migrating xhr methods to keyword arguments syntaxKir Shatrov2015-02-011-3/+18
| | | | | | | | | | | | | | | | | | | | | | | | in `ActionController::TestCase` and `ActionDispatch::Integration` Old syntax: `xhr :get, :create, params: { id: 1 }` New syntax example: `get :create, params: { id: 1 }, xhr: true`
* | Merge pull request #18721 from sj26/pre-discard-flashAaron Patterson2015-02-011-0/+12
|\ \ | |/ |/| Pre-discard flash messages
| * Fix flash remaining after last flash deletedSamuel Cochran2015-01-291-0/+12
| | | | | | | | | | | | | | Inside a controller functional test after the last flash is deleted it still persists the flash because to_session_value is nil. We should delete it from the session when the serialized version is nil, same as the flash middleware.
* | Consistent usage of spaces in hashes across our codebaseRafael Mendonça França2015-01-291-14/+18
| |
* | Switch to kwargs in ActionController::TestCase and ActionDispatch::IntegrationKir Shatrov2015-01-291-87/+279
|/ | | | | | | | 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
* Remove deprecated option `use_route` in controller testsRafael Mendonça França2015-01-041-25/+0
|
* Deprecate `use_route` in controller testsGodfrey Chan2014-11-231-2/+2
| | | | Reference #17453
* Test using `ActionController::TestCase` with enginesGodfrey Chan2014-11-231-0/+52
| | | | | | Reference #17453 [Godfrey Chan, Washington Luiz]
* Make sure assert_select can assert body tagRafael Mendonça França2014-11-181-0/+21
| | | | | | | | | This reverts commit f93df52845766216f0fe36a4586f8abad505cac4, reversing changes made to a455e3f4e9dbfb9630d47878e1239bc424fb7d13. Conflicts: actionpack/lib/action_controller/test_case.rb actionview/lib/action_view/test_case.rb
* Pass the route name explicitlyGodfrey Chan2014-11-101-0/+12
| | | | | | Follow up to 212057b9. Since that commit, we need to pass the `route_name` explicitly. This is one of the left-over cases that was not handled in that commit, which was causing `use_route` to be ignored in functional tests.
* Use Hash#each_key instead of Hash#keys.eachErik Michaels-Ober2014-09-291-1/+1
| | | | | | Hash#keys.each allocates an array of keys; Hash#each_key iterates through the keys without allocating a new array. This is the reason why Hash#each_key exists.
* Merge branch 'master' into loofahRafael Mendonça França2014-08-121-5/+6
|\ | | | | | | | | | | | | Conflicts: actionpack/CHANGELOG.md actionpack/test/controller/integration_test.rb actionview/CHANGELOG.md
| * Fixes to TestCaseTest.Guo Xiang Tan2014-08-081-4/+5
| |
| * Fix spelling.Guo Xiang Tan2014-08-071-1/+1
| |
* | Merge pull request #11218 from kaspth/loofah-integrationRafael Mendonça França2014-07-101-179/+0
|\ \ | |/ |/| | | | | | | | | | | Loofah-integration Conflicts: actionpack/CHANGELOG.md actionview/CHANGELOG.md
| * Removed tag.rb since it has been deprecated.Timm2014-06-151-179/+0
| |
* | Remove symbolized_path_parameters.Guo Xiang Tan2014-07-021-3/+3
|/ | | | This pull request is a continuation of https://github.com/rails/rails/commit/925bd975 and https://github.com/rails/rails/commit/8d8ebe3d.
* Deprecate all *_filter callbacks in favor of *_action callbacksRafael Mendonça França2014-05-271-1/+1
| | | | | This is the continuation of the work started at 9d62e04838f01f5589fa50b0baa480d60c815e2c
* use symbol keys for path_parametersAaron Patterson2014-05-221-5/+5
|
* Fix controller test not resetting @_url_optionsTony Wooster2014-02-261-0/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Commit 4f2cd3e9 introduced a bug by reordering the call to `@controller.recycle!` above the call to `build_request_uri`. The impact of this was that the `@_url_options` cache ends up not being reset between building a request URI (occurring within the test controller) and the firing of the actual request. We encountered this bug because we had the following setup: class MinimumReproducibleController < ActionController::Base before_filter { @param = 'param' } def index render text: url_for(params) end def default_url_options { custom_opt: @param } end end def test_index get :index # builds url, then fires actual request end The first step in `get :index` in the test suite would populate the @_url_options cache. The subsequent call to `url_for` inside of the controller action would then utilize the uncleared cache, thus never calling the now-updated default_url_options. This commit fixes this bug calling recycle! twice, and removes a call to set response_body, which should no longer be needed since we're recycling the request object explicitly.
* Clear filtered request attributes between requests in testsAndrew White2014-01-271-0/+8
| | | | | | | | The request attributes filtered_parameters, filtered_env and filtered_path are memoized for performance reasons. However this can cause unusual behavior in tests where there are multiple calls to get, post, etc. Fixes #13803.
* Eliminate `JSON.{parse,load,generate,dump}` and `def to_json`Godfrey Chan2013-11-051-2/+3
| | | | | | | | | | | | | | | JSON.{dump,generate} offered by the JSON gem is not compatiable with Rails at the moment and can cause a lot of subtle bugs when passed certain data structures. This changed all direct usage of the JSON gem in internal Rails code to always go through AS::JSON.{decode,encode}. We also shouldn't be implementing `to_json` most of the time, and these occurances are replaced with an equivilent `as_json` implementation to avoid problems down the road. See [1] for all the juicy details. [1]: intridea/multi_json#138 (comment)
* Re-remove deprecated API.kennyj2013-06-281-7/+0
|
* Revert "Add the options method to action_controller testcase."Rafael Mendonça França2013-05-161-5/+0
| | | | | | | | | | | | This reverts commit 0303c2325fab253adf5e4a0b738cb469c048f008. Conflicts: actionpack/lib/action_controller/test_case.rb REASON: It will conflict with a lot of test cases. Better to call `process` directly since this is a very uncommon HTTP method. Fixes #10638.
* Fix rake test warnings in actionpackMack Earnhardt2013-03-171-1/+1
|