aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_dispatch/testing
Commit message (Collapse)AuthorAgeFilesLines
...
* Show redirect response code in assert_response messagesJon Atack2015-12-111-10/+8
| | | | | | | | | | | | Follow-up to PR #19977, which helpfully added the redirection path to the error message of assert_response if response is a redirection, but which removed the response code, obscuring the type of redirect. This PR: - brings back the response code in the error message, - updates the tests so the new messages can be tested, - and adds test cases for the change.
* Merge pull request #22514 from ↵Rafael França2015-12-111-1/+1
|\ | | | | | | | | prathamesh-sonpatki/use-assert-over-assert-predicate Use assert over assert_predicate in assert_response
| * Use assert over assert_predicate in assert_responsePrathamesh Sonpatki2015-12-061-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - `assert_predicate` appends its own error message at the end of message generated by `assert_response` and because of that the error message displays the whole `response` object. - For eg. Expected response to be a <success>, but was a redirect to <http://test.host/posts>. Expected #<ActionDispatch::TestResponse:0x007fb1cc1cf6f8....(lambda)>}>> to be successful?. - Complete message can be found here - https://gist.github.com/prathamesh-sonpatki/055afb74b66108e71ded#file-gistfile1-txt-L19. - After this change the message from `assert_predicate` won't be displayed and only message generated by `assert_response` will be shown as follows: Expected response to be a <success>, but was a redirect to <http://test.host/posts>
* | Push `before_sending` to super classeileencodes2015-12-061-0/+1
|/ | | | | | | | | | | | We want to get rid of the `Live::Response` so we are consolidating methods from `Live::Response` and `Response` by merging them together. This adds an `#empty` method to the request so we don't need to hard-code the empty array each time we call an empty `ActionDispatch::Request`. The work here is a continuation on combining controller and integration test code bases into one.
* Add redirection path in the error message of assert_response if response is ↵Prathamesh Sonpatki2015-12-041-0/+15
| | | | | | | | | | | | | | | | :redirect - If the assert_response is checking for any non-redirect response like :success and actual response is :redirect then, the error message displayed was - Expected response to be a <success>, but was <302> - This commit adds the redirect path to the error message of assert_response if the response is :redirect. So above message is changed to - Expected response to be a <success>, but was a redirect to <http://test.host/posts/lol>
* Fix double word 'string' [ci skip]Jake Worth2015-11-011-1/+1
|
* Merge branch 'master' of github.com:rails/docrailsVijay Dev2015-10-312-11/+11
|\
| * Improved readability of Assertion docs, replaced ‘Assert’ -> ↵amitkumarsuroliya2015-10-092-10/+10
| | | | | | | | | | ‘Asserts’ at all places [ci skip] Following commit https://github.com/rails/docrails/commit/495722a95687e25114ae75608dd3107ac5d6611b
| * Fixed wording in Assertion docs, changed ‘Assert’ -> ‘Asserts’Ronak Jangir2015-10-071-1/+1
| |
* | specify deprecated waring, follow the standard conventionsGaurav Sharma2015-10-281-5/+5
| | | | | | | | `skip_filter`, `skip_action_callback` may both are deprecated in Rails 5.1 so waring msg should be specific.
* | Use sufficient a regexp anchor to check `@response.content_type.to_s`yui-knk2015-10-221-1/+1
| | | | | | | | | | | | This commit follows up of ea9bc06c9a47b839d5e2db94ba6bf7e29c8f0ae9. To check `@response.content_type.to_s` is ended with `"xml"`, to use `\z` is sufficient.
* | Merge pull request #20715 from simsalabim/feature/parse-rss-atom-as-xmlSean Griffin2015-10-201-1/+1
| | | | | | | | parse RSS/ATOM responses as XML, not HTML
* | Use `Mime[:foo]` instead of `Mime::Type[:FOO]` for back compatJeremy Daer2015-10-062-2/+2
|/ | | | | | | | | | | | | | | | | 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-212-2/+2
| | | | | We should be asking the mime type method for the mime objects rather than via const lookup
* pass a request object to the headers objectAaron Patterson2015-08-211-2/+2
|
* 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.
* stop using @_env in the controller instanceAaron Patterson2015-08-071-1/+1
| | | | | | | Actions are processed through `dispatch`, so they should have the request set on them before any user land code can be executed. Lets stop setting _env on the controller, and give access to it through the `env` method.
* do not add common ports to HTTP_HOSTMichael Grosser2015-08-061-1/+5
| | | | | - webservers do not do it - it makes redirect urls ugly when request.host is used for redirection
* sop passing host and secure to the build methodAaron Patterson2015-08-051-1/+1
| | | | | eventually we will make the cookie jar derive these values from the request object rather than save a reference to the values
* move env access to the request object.Aaron Patterson2015-08-051-1/+1
| | | | | | Accessing a request object has nice advantages over accessing a hash. If you use a missing method name, you'll get an exception rather than a `nil` (is one nice feature)
* Add `:nodoc:` for internal testing methods [ci skip]Robin Dupret2015-07-281-1/+1
|
* Oops! :bomb:Akira Matsuda2015-07-171-1/+1
|
* "warning: instance variable @routes not initialized"Akira Matsuda2015-07-171-1/+1
|
* 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.
* use a lookup table for `assert_response`Aaron Patterson2015-07-131-3/+8
| | | | | | | | We shouldn't depend on specific methods imlemented in the TestResponse subclass because the response could actually be a real response object. In the future, we should either push the aliased predicate methods in TestResponse up to the real response object, or remove them
* assign the cookie hash on request allocationAaron Patterson2015-07-081-1/+1
| | | | this prevents mutations from being available globally
* add a new constructor for allocating test requestsAaron Patterson2015-07-082-9/+9
|
* make `env` a required parameterAaron Patterson2015-07-081-1/+1
|
* pass the starting env and session to build_requestAaron Patterson2015-07-081-1/+1
|
* let the superclass build the request and responseAaron Patterson2015-07-081-1/+1
| | | | | We should leverage the request / response objects that the superclass has already allocated for us.
* remove useless `new` implementationAaron Patterson2015-07-081-4/+0
|
* pass cookies from the jar in the HTTP_COOKIE headereileencodes2015-07-071-9/+4
| | | | | we should be pushing the cookies in via headers rather than maintaining some object and "recycling" it.
* Send cookies with requesteileencodes2015-07-071-1/+1
|
* Merge pull request #20138 from tgxworld/deprecated_assert_templateRafael Mendonça França2015-06-012-4/+3
|\ | | | | Deprecate `assert_template` and `assigns()`.
| * Remove `assigns` and `assert_template`.Guo Xiang Tan2015-05-302-4/+3
| |
* | 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.
* [ci skip] remove `assigns` from the integration test example in API docsRoque Pinel2015-05-171-2/+2
| | | | Based on #19976 and #18305.
* 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.
* Add missing require for String#strip_heredocPrem Sichanugrist2015-04-171-0/+1
| | | | | | This method is being used in `#xml_http_request`, but was not properly required. This causes `NoMethodError` on projects that are doing integration test.
* Compare content_type with Mime::XML instead of regexpBoris Peterbarg2015-03-161-1/+1
| | | | | Regexp is broken for both content types including charsets and for integration tests, where the content_type is a Mime::Type and not String
* Call super last in before_setupeileencodes2015-03-091-1/+1
| | | | | | | | | | | | | | | This fixes the reasons 4cf3b8a, 303567e, and fa63448 needed to be reverted in 7142059. The revert has been reverted and this fixes the issues caused previously. If we call `super` first we will end up nuking the session settings in the application tests that do `setup do` - so any session login or cookie settings will not be persisted thoughout the test sessions. Calling `super` last prevents `@integration_session` from getting nuked and set to nil if it's already set. Test added to prevent regression of this behavior in the future.
* Revert "Revert integration test refactoring that caused app test regressions"eileencodes2015-03-091-14/+10
| | | | This reverts commit 714205988315d2f98aa3e749747c44470e18676b.
* update integration test example as is not output deprecation warning [ci skip]yuuji.yaginuma2015-03-071-7/+8
|
* Revert work arounds for upstream Ruby 2.2.0 kwargs bugGenadi Samokovarov2015-03-051-1/+1
| | | | | | | | | | | | | | | | | | | The bug caused a segfault and you can find more info about it at: https://bugs.ruby-lang.org/issues/10685. We did a couple of work arounds, but 2.2.1 rolled out and those aren't needed anymore. Here are the reverted commits: - Revert "Work around for upstream Ruby bug #10685", commit 707a433870e9e06af688f85a4aedc64a90791a64. - Revert "Fix segmentation fault in ActionPack tests", commit 22e0a22d5f98e162290d9820891d8191e720ad3b. I'm also bumping the Ruby version check to 2.2.1 to prevent future segfaults.
* Work around for upstream Ruby bug #10685Genadi Samokovarov2015-03-011-1/+1
| | | | | | | | | | | | | | | | | | | | | In f6e293ec54f02f83cdb37502bea117f66f87bcae we avoided a segfault in the tests, however I think we should try to avoid the crash, as it may happen in user code as well. Here is what I distiled the bug down to: ```ruby # Rails case - works on 2.0, 2.1; crashes on 2.2 require 'action_dispatch' ActionDispatch::Response.new(200, "Content-Type" => "text/xml") # General case - works on 2.0, 2.1; crashes on 2.2 def foo(optional = {}, default_argument: nil) end foo('quux' => 'bar') ```
* Revert integration test refactoring that caused app test regressionsJeremy Kemper2015-02-261-10/+14
| | | | | | | | | | | | Haven't diagnosed yet. No similarly failing tests in Rails to work from. cc @tenderlove, @eileencodes Revert "there is always an integration session, so remove the check" Revert "lazily create the integration session" Revert "use before_setup to set up test instance variables" This reverts commits 4cf3b8ac47f109fa83a6f66eb97d6cb0eace0d05, 303567e554de26822f3107be55c471d6477a745f, and fa63448420d3385dbd043aca22dba973b45b8bb2.
* Fix default headers in test responsesJeremy Kemper2015-02-252-13/+2
| | | | | | | 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 #18665 from sgrif/sg-test-route-allSean Griffin2015-02-201-8/+14
|\ | | | | Allow `method: "all"` as a valid routing test option
| * Allow `method: "all"` as a valid routing test optionSean Griffin2015-01-231-8/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This allows the test to mirror the production code, since `via: :all` is a valid option. The behavior in 4.1 did not actually test that it matched all verbs, but instead defaulted to testing for "GET". This implementation aims to better handle the intention of passing "all". What will actually be asserted doesn't quite match up with the generated route, since it appears to just not create a constraint on the method. However, I don't think that we can easily test the lack of that constraint. Testing each of the main 4 HTTP verbs seems to be a reasonably close approximation, which should be sufficient for our needs. Fixes #18511.