aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_dispatch/testing/integration.rb
Commit message (Collapse)AuthorAgeFilesLines
...
* Simplify `as` passed check.Kasper Timm Hansen2016-06-251-1/+1
| | | | `if !var.nil?` is the same as just `if var`
* make `as` option work with get parametersyuuji.yaginuma2016-06-251-2/+4
| | | | | | | | Currently, if path is a relative path, add format without the discrimination of the query. Therefore, if there is a query, format at end of the query would been added, format was not be specified correctly. This fix add format to end of path rather than query.
* add missing `as` to request kwargs of `ActionDispatch::IntegrationTest`yuuji.yaginuma2016-05-271-2/+3
| | | | Follow up to #21671
* Deprecate `request_via_redirect` method.Prathamesh Sonpatki2016-04-241-5/+6
| | | | | | | | - Followup of https://github.com/rails/rails/issues/18693. - I think we missed deprecating `request_via_redirect` in that pull request. - Originally requested by DHH here https://github.com/rails/rails/issues/18333.
* Pass over all Rails 5 warnings, to make sure:Vipul A M2016-04-121-1/+1
| | | | | | | | | | - we are ending sentences properly - fixing of space issues - fixed continuity issues in some sentences. Reverts https://github.com/rails/rails/commit/8fc97d198ef31c1d7a4b9b849b96fc08a667fb02 . This change reverts making sure we add '.' at end of deprecation sentences. This is to keep sentences within Rails itself consistent and with a '.' at the end.
* extract ActionDispatch::IntegrationTest::BehaviorScott Bronson2016-03-071-22/+35
| | | | | Similar to 176fbfd6, this makes it possible for other test frameworks to hook into Rails integration test facilities.
* Prevent not-intended loading of `ActionDispatch::IntegrationTest`yui-knk2016-03-071-0/+2
| | | | | | | | | | After 9d378747326d26cf1afdac4433ead22967af0984 `ActionDispatch::IntegrationTest` class is loaded and defined in all Rails environments, not only test but also production. This is not-intended loading of a class which is only used in test environment. To prevent not-intended loading, add `ActiveSupport.run_load_hooks` to `ActionDispatch::IntegrationTest` with `action_dispatch_integration_test` name and use it in `ActionMailer`.
* Do not run app.executor callbacks in integration testsJorge Bejar and Santiago Pastorino2016-03-021-11/+2
| | | | | | | | This reverts changes made to integration tests in PR #23807. The issue happens when using capybara with a driver that needs to start a server in a separate thread like (poltergeist, selenium, etc). Both threads the capybara server one and the test thread end running syncronize over the interlock.
* Publish AS::Executor and AS::Reloader APIsMatthew Draper2016-03-021-2/+11
| | | | | | These should allow external code to run blocks of user code to do "work", at a similar unit size to a web request, without needing to get intimate with ActionDipatch.
* Add fixes accidentally removed.Kasper Timm Hansen2016-02-121-1/+2
| | | | | | | | | | | | | | Yesterday, when improving how `parsed_body` extracted a parser I wrote 77bbf1e. Then I thought that was too many changes in one commit and broke it up locally... or so I thought. When pushed the extra commits removed the changes! Wups! In shame, lob those changes together here: * 3b94c38 which meant to fix the CHANGELOG syntax error. * 5007df5 which meant to mention `parsed_body` in the docs. * 036a7a0 which meant to memoize the `parsed_body`.
* [ci skip] Mention `parsed_body` in docs.Kasper Timm Hansen2016-02-111-2/+1
| | | | Little easier to understand when you know the method that's used.
* Make `parsed_body` extract parser from the content type.Kasper Timm Hansen2016-02-111-4/+8
| | | | | | | We're not guaranteed to have a `RequestEncoder` to assign on `get` requests because we aren't extracting the parser from the response content type. Until now.
* Add `parsed_body` to spare writing out parsing routines.Kasper Timm Hansen2016-02-101-12/+26
| | | | | | | | | | | | | | | When testing: ```ruby post articles_path, params: { article: { title: 'Ahoy!' } }, as: :json ``` It's common to want to make assertions on the response body. Perhaps the server responded with JSON, so you write `JSON.parse(response.body)`. But that gets tedious real quick. Instead add `parsed_body` which will automatically parse the reponse body as what the last request was encoded `as`.
* Merge pull request #21671 from kaspth/integration-request-encoding-helpersDavid Heinemeier Hansson2016-02-101-4/+79
|\ | | | | Add `as` to encode a request as a specific mime type.
| * Add `as` to encode a request as a specific mime type.Kasper Timm Hansen2016-01-041-4/+79
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Turns ``` post articles_path(format: :json), params: { article: { name: 'Ahoy!' } }.to_json, headers: { 'Content-Type' => 'application/json' } ``` into ``` post articles_path, params: { article: { name: 'Ahoy!' } }, as: :json ```
* | Sleep well, sweet princeSean Griffin2016-02-021-1/+1
|/ | | | | Prototype, you have served us well. But you are no longer how we make an XMLHttpRequest. RIP
* 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.
* 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 `Mime[:foo]` instead of `Mime::Type[:FOO]` for back compatJeremy Daer2015-10-061-1/+1
| | | | | | | | | | | | | | | | | 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 calling deprecated methodsAaron Patterson2015-09-211-1/+1
| | | | | 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
|
* 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
* Add `:nodoc:` for internal testing methods [ci skip]Robin Dupret2015-07-281-1/+1
|
* Merge pull request #20138 from tgxworld/deprecated_assert_templateRafael Mendonça França2015-06-011-1/+0
|\ | | | | Deprecate `assert_template` and `assigns()`.
| * Remove `assigns` and `assert_template`.Guo Xiang Tan2015-05-301-1/+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.
* [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.
* 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 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-251-1/+1
| | | | | | | 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:
* Add missing commaArthur Neves2015-02-131-1/+1
|
* Correct module name in deprecation message.Guo Xiang Tan2015-02-131-1/+1
|
* Improve deprecation message.Guo Xiang Tan2015-02-131-1/+3
|
* Do not recommend `xhr` since it is going to be deprecated.Guo Xiang Tan2015-02-131-3/+0
|
* remove meta programmingAaron Patterson2015-02-121-3/+3
| | | | | there's really no benefit here. It's the same number of lines without the meta programming and is faster
* there is always an integration session, so remove the checkAaron Patterson2015-02-121-1/+0
|
* lazily create the integration sessionAaron Patterson2015-02-121-7/+5
| | | | now we don't have to call reset! everywhere
* use before_setup to set up test instance variablesAaron Patterson2015-02-121-7/+6
|
* Skip url_helpers instead of caching, speed up integration testseileencodes2015-02-121-10/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We shouldn't cache if it's not absolutely necessary. Removes route caching and instead skips using the `url_helpers` is the integration test session doesn't require it. Benchmark ips on integration and controller index method tests below. Without any caching or changes to `#url_helpers`: ``` Calculating ------------------------------------- INDEX: Integration Test 71.000 i/100ms INDEX: Functional Test 99.000 i/100ms ------------------------------------------------- INDEX: Integration Test 728.878 (± 8.0%) i/s - 3.692k INDEX: Functional Test 1.015k (± 6.7%) i/s - 5.148k Comparison: INDEX: Functional Test: 1015.4 i/s INDEX: Integration Test: 728.9 i/s - 1.39x slower ``` With caching on `#url_helpers`: ``` Calculating ------------------------------------- INDEX: Integration Test 74.000 i/100ms INDEX: Functional Test 99.000 i/100ms ------------------------------------------------- INDEX: Integration Test 752.377 (± 6.9%) i/s - 3.774k INDEX: Functional Test 1.021k (± 6.7%) i/s - 5.148k Comparison: INDEX: Functional Test: 1021.1 i/s INDEX: Integration Test: 752.4 i/s - 1.36x slower ``` Afer removing the caching and bypassing the `url_helpers` when not necessary in the session: ``` Calculating ------------------------------------- INDEX: Integration Test 87.000 i/100ms INDEX: Functional Test 97.000 i/100ms ------------------------------------------------- INDEX: Integration Test 828.433 (± 6.4%) i/s - 4.176k INDEX: Functional Test 926.763 (± 7.2%) i/s - 4.656k Comparison: INDEX: Functional Test: 926.8 i/s INDEX: Integration Test: 828.4 i/s - 1.12x slower ```
* Migrating xhr methods to keyword arguments syntaxKir Shatrov2015-02-011-8/+16
| | | | | | | | | | | | in `ActionController::TestCase` and `ActionDispatch::Integration` Old syntax: `xhr :get, :create, params: { id: 1 }` New syntax example: `get :create, params: { id: 1 }, xhr: true`
* Consistent usage of spaces in hashes across our codebaseRafael Mendonça França2015-01-291-2/+2
|
* Use fixed fonts only in the name of the parameterRafael Mendonça França2015-01-291-3/+3
|
* Switch to kwargs in ActionController::TestCase and ActionDispatch::IntegrationKir Shatrov2015-01-291-37/+104
| | | | | | | | 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
* Deprecate *_via_redirect integration test methodsAditya Kapoor2015-01-281-0/+5
|
* Move longer form example from integration guide to api reference, below anZachary Scott2014-12-291-0/+78
| | | | | | | | existing example. [ci skip] My reasoning is that this is probably too much information for the complete Rails testing guide, as we're trying to cover testing all aspects of the framework.