aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_controller/test_case.rb
Commit message (Collapse)AuthorAgeFilesLines
* [Action Controller] require => require_relativeAkira Matsuda2017-07-011-1/+1
|
* Revert "Merge pull request #27775 from domcleal/27774-format-reset"Rafael Mendonça França2017-03-211-1/+0
| | | | | | | | | | | | | | This reverts commit c6f9f8c28a720ad4ec7cf3613dddfa451d5968e2, reversing changes made to c309073c7476f50dfb1e796d058580f176101c36. Reason: This is fixing the behavior in the wrong place. Now the request path after the request is nil and there is no way to assert that. Also the test that was added in that PR also fails in 4.2 where the reporter says it was passing. The reason the bahavior changed between Rails 4.2 and Rails 5 is that the format in the path is now respected. The correct way to fix the problem is not doign two requests in the same controller test and use integrations tests. This change caused a regression between Rails 5.0.1 and 5.0.2.
* [docs] fix ActionController documentationHrvoje Šimić2017-03-121-5/+5
| | | | [ci skip]
* Delete PATH_INFO after each controller test requestDominic Cleal2017-01-231-0/+1
| | | | | | | | | | Prevents PATH_INFO from being used to infer the request format in later test requests when no explicit format is given. As the request PATH_INFO may be set before a request, it can't be deleted during pre-request scrubbing. Fixes #27774
* Revert "Merge pull request #27586 from maclover7/jm-fix-27584"Rafael Mendonça França2017-01-111-2/+3
| | | | | | | This reverts commit 5eff7a9ca7bb2ee7f16db1ab4d11cebe28757ba5, reversing changes made to 5f03172f54a58a57a48a3121562beb2cef866cbe. Reason: It caused a regression. The test case is on the PR.
* Update `cookies` helper on all HTTP requestsJon Moss2017-01-051-3/+2
| | | | | | | | | Regression introduced by ae29142142324545a328948e059e8b8118fd7a33 / 8363b879fe759f0645179f4521cc64795efbee6e. Previously, cookies were only updated on `GET` requests. Now we will update the helper for all requests, as part of `process`. Added regression tests for all available HTTP method helpers in `ActionController::TestCase`.
* `self.` is not needed when calling its own instance methodAkira Matsuda2017-01-051-1/+1
| | | | Actually, private methods cannot be called with `self.`, so it's not just redundant, it's a bad habit in Ruby
* Merge pull request #27146 from maclover7/jm-fix-27145Eileen M. Uchitelle2016-12-191-2/+0
|\ | | | | Do not clear HTTP_COOKIES header after request
| * Do not clear HTTP_COOKIES header after requestJon Moss2016-12-111-2/+0
| |
* | Missing require "active_support/testing/constant_lookup"Akira Matsuda2016-12-141-0/+1
|/
* Fixed CONTENT_LENGTH header in ActionController::TestRequestArtem Rashev2016-11-151-2/+3
| | | | | | | | | | | | | CONENT_LENGTH setted by string length, which is equal to number of characters in string but StringIO.length is byte sequence and when payload contains non-ASCII characters, stream's length will be different. That's why real byte length should be used for CONTENT_LENGTH header. Add unit test for CONTENT_LENGTH header fix It just passes non-ascii symbols as parameters and verifies that "CONTENT_LENGTH" header has content bytes count as value.
* Remove deprecated support to non-keyword arguments #processRafael Mendonça França2016-10-101-70/+16
|
* Remove deprecated `xml_http_request` and `xhr` methodsRafael Mendonça França2016-10-101-15/+0
|
* Merge pull request #26573 from kirs/action-controller-as-formatRafael França2016-09-271-4/+4
|\ | | | | Make :as option also set request format (AC::TestCase)
| * Make :as option also set request format (AC::TestCase)Kir Shatrov2016-09-211-4/+4
| | | | | | | | | | | | | | | | right now you'd have to specify both :as and :format: ``` post :create, params: { foo: "bar" } as: :json, format: :json ```
* | Do not mutate AC::TestRequest::DEFAULT_OPTIONSKir Shatrov2016-09-101-1/+1
|/
* Fix broken heredoc indentation caused by rubocop auto-correctRyuta Kamizono2016-09-031-6/+6
| | | | | | All indentation was normalized by rubocop auto-correct at 80e66cc4d90bf8c15d1a5f6e3152e90147f00772. But heredocs was still kept absolute position. This commit aligns heredocs indentation for consistency.
* Fix typo in the hook nameRafael Mendonça França2016-08-251-1/+1
|
* Add load hooks to all tests classesRafael Mendonça França2016-08-251-0/+1
| | | | | | | | | | | | | | | | | | | | | | | Usually users extends tests classes doing something like: ActionView::TestCase.include MyCustomTestHelpers This is bad because it will load the ActionView::TestCase right aways and this will load ActionController::Base making its on_load hooks to execute early than it should. One way to fix this is using the on_load hooks of the components like: ActiveSupport.on_load(:action_view) do ActionView::TestCase.include MyCustomTestHelpers end The problem with this approach is that the test extension will be only load when ActionView::Base is loaded and this may happen too late in the test. To fix this we are adding hooks to people extend the test classes that will be loaded exactly when the test classes are needed.
* Copy edits in the documentation [ci skip]Rafael Mendonça França2016-08-191-1/+1
|
* Set the request type if as: is specifiedEverest Munro-Zeisberger2016-08-181-1/+8
| | | | Documentation & testing
* Merge pull request #25862 from ↵प्रथमेश Sonpatki2016-08-171-6/+12
|\ | | | | | | | | prathamesh-sonpatki/start-documenting-ac-testcase-again Start documenting ActionController::TestCase again
| * Start documenting ActionController::TestCase againPrathamesh Sonpatki2016-08-171-6/+12
| | | | | | | | | | | | | | | | | | | | | | | | - Rails 5 changed interface for passing arguments to request methods to keyword args for AC::TestCase but also hid the documentation. - But existing AC::TestCase tests need the new documentation about keyword args. So resurrected documentation and added a note about not using this for new tests. - The guides and other documentation is already updated to use `ActionDispatch::IntegrationTest`. [Matthew Draper, Prathamesh Sonpatki]
* | Merge pull request #26092 from kerrizor/kerrizor/force-param-encodingAaron Patterson2016-08-101-5/+8
|\ \ | | | | | | Allow specifying encoding of parameters by action
| * | Allow specifying encoding of parameters by actionKerri Miller2016-08-091-5/+8
| | | | | | | | | | | | | | | 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.
* | code gardening: removes redundant selfsXavier Noria2016-08-081-4/+4
| | | | | | | | | | | | | | | | | | 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.
* | applies remaining conventions across the projectXavier Noria2016-08-061-1/+0
| |
* | normalizes indentation and whitespace across the projectXavier Noria2016-08-061-44/+44
| |
* | applies new string literal convention in actionpack/libXavier Noria2016-08-061-36/+36
| | | | | | | | | | The current code base is not uniform. After some discussion, we have chosen to go with double quotes by default.
* | 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.
* Clean up the test request/response even after an exceptionMatthew Draper2016-06-011-23/+26
|
* Fixes #23964Ryan T. Hosford2016-03-131-0/+2
| | | | | | | | | | | | | | | | | | - 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.
* Change 'a HTTP' to 'an HTTP' [ci skip]Santosh Wadghule2016-03-031-1/+1
|
* Revert "Update Session to utilize indiffernt access"Matthew Draper2016-02-261-1/+1
| | | | | | | | | | | This reverts commit 45a75a3fcc96b22954caf69be2df4e302b134d7a. HWIAs are better than silently deeply-stringified hashes... but that's a reaction to a shortcoming of one particular session store: we should not break the basic behaviour of other, more featureful, session stores in the process. Fixes #23884
* Merge pull request #20851 from tomprats/indifferent-sessionsRafael Mendonça França2016-02-241-1/+1
|\ | | | | | | Give Sessions Indifferent Access
| * Update Session to utilize indiffernt accessTom Prats2016-01-301-1/+1
| |
* | Use symbol of mime type instead of object to get correct parserMehmet Emin İNAÇ2016-02-221-2/+2
| | | | | | | | | | | | After registering new `:json` mime type `parsers.fetch` can't find the mime type because new mime type is not equal to old one. Using symbol of the mime type as key on parsers hash solves the problem. Closes #23766
* | fix 'method redefined' warningsScott Bronson2016-02-061-0/+1
| |
* | disable controller / view thread spawning in testsAaron Patterson2016-02-051-0/+10
|/ | | | | | | | | | | | | | | | | | Tests can (and do) access the database from the main thread. In this case they were starting a transaction, then making a request. The request would create a new thread, which would allocate a new database connection. Since the main thread started a transaction that contains data that the new thread wants to see, the new thread would not see it due to data visibility from transactions. Spawning the new thread in production is fine because middleware should not be doing database manipulation similar to the test harness. Before 603fe20c it was possible to set the database connection id based on a thread local, but 603fe20c changes the connection lookup code to never look at the "connection id" but only at the thread object itself. Without that indirection, we can't force threads to use the same connection pool as another thread. Fixes #23483
* remove `present?` callsAaron Patterson2016-01-121-4/+4
| | | | | Empty strings / data structures should be treated differently than nils. We don't really need these calls here (don't pass in blank strings).
* monkey patch `recycle!` on to controllers onceAaron Patterson2016-01-121-4/+4
| | | | | | | | | | | Instead of checking whether the class has recycle! or not, we can just always add the method to all controller classes when the test harness is loaded. Technically this means that the controller test harness will not work with controllers that do not inherit from AC::Metal, but then, I'm not sure that is supported anyway. Mixing in the module one will ensure that we don't break method caches, and eliminates a runtime check so it should speed up tests (slightly).
* Remove ActionController::TestCase from documentationeileencodes2015-12-121-0/+4
| | | | | | | | | | | | | | | | | | In Rails 5.1 `ActionController::TestCase` will be moved out of Rails into it's own gem. Please use `ActionDispatch::IntegrationTest` going foward. Because this will be moved to a gem I used `# :stopdoc:` instead of deleting the documentation. This will remove it from the Rails documentation but still leave the method documented for when we move it to a gem. Guides have been updated to use the routing structure used in Integration and all test examples have been updated to inherit from `ActionDispatch::IntegrationTest` instead of `ActionController::TestCase. Fixes #22496
* Merge branch 'master' of github.com:rails/docrailsVijay Dev2015-10-311-2/+2
|\
| * Improved readability of Assertion docs, replaced ‘Assert’ -> ↵amitkumarsuroliya2015-10-091-2/+2
| | | | | | | | | | ‘Asserts’ at all places [ci skip] Following commit https://github.com/rails/docrails/commit/495722a95687e25114ae75608dd3107ac5d6611b
* | use `dispatch` instead of `process` to run requests thougheileencodes2015-10-291-4/+3
| | | | | | | | | | | | | | | | | | `dispatch` sets the request and response on the controller for us automatically, so the test harness doesn't need to know the internals of how request / response is set. Conflicts: actionpack/lib/action_controller/test_case.rb
* | 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
* | Use `Mime[:foo]` instead of `Mime::Type[:FOO]` for back compatJeremy Daer2015-10-061-3/+3
|/ | | | | | | | | | | | | | | | | Rails 4.x and earlier didn't support `Mime::Type[:FOO]`, so libraries that support multiple Rails versions would've had to feature-detect whether to use `Mime::Type[:FOO]` or `Mime::FOO`. `Mime[:foo]` has been around for ages to look up registered MIME types by symbol / extension, though, so libraries and plugins can safely switch to that without breaking backward- or forward-compatibility. Note: `Mime::ALL` isn't a real MIME type and isn't registered for lookup by type or extension, so it's not available as `Mime[:all]`. We use it internally as a wildcard for `respond_to` negotiation. If you use this internal constant, continue to reference it with `Mime::ALL`. Ref. efc6dd550ee49e7e443f9d72785caa0f240def53
* stop applying default headers in ActionDispatch::ResponseAaron Patterson2015-09-231-1/+1
| | | | | | | | | | 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`
* stop calling deprecated methodsAaron Patterson2015-09-211-3/+3
| | | | | We should be asking the mime type method for the mime objects rather than via const lookup