aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_dispatch/testing
Commit message (Collapse)AuthorAgeFilesLines
* fix `follow_redirect!` not using the same HTTP verb on 307 redirection:Edouard CHIN2019-07-251-3/+8
| | | | | | | | | | - According to the HTTP 1.1 spec, the 307 redirection guarantees that the method and the body will not be changed during redirection. This PR fixes that since follow_redirect! would always follow the redirection my making a GET request. Ref https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/307
* No Woman, No tryAkira Matsuda2019-07-121-1/+0
|
* Enable `Layout/EmptyLinesAroundAccessModifier` copRyuta Kamizono2019-06-131-1/+0
| | | | | | | | | | | We sometimes say "✂️ newline after `private`" in a code review (e.g. https://github.com/rails/rails/pull/18546#discussion_r23188776, https://github.com/rails/rails/pull/34832#discussion_r244847195). Now `Layout/EmptyLinesAroundAccessModifier` cop have new enforced style `EnforcedStyle: only_before` (https://github.com/rubocop-hq/rubocop/pull/7059). That cop and enforced style will reduce the our code review cost.
* Change `ActionDispatch::Response#content_type` returning Content-Type header ↵yuuji.yaginuma2019-06-012-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | as it is Since #35709, `Response#conten_type` returns only MIME type correctly. It is a documented behavior that this method only returns MIME type, so this change seems appropriate. https://github.com/rails/rails/blob/39de7fac0507070e3c5f8b33fbad6fced84d97ed/actionpack/lib/action_dispatch/http/response.rb#L245-L249 But unfortunately, some users expect this method to return all Content-Type that does not contain charset. This seems to be breaking changes. We can change this behavior with the deprecate cycle. But, in that case, a method needs that include Content-Type with additional parameters. And that method name is probably the `content_type` seems to properly. So I changed the new behavior to more appropriate `media_type` method. And `Response#content_type` changed (as the method name) to return Content-Type header as it is. Fixes #35709. [Rafael Mendonça França & Yuuji Yaginuma ]
* Raise exception when building invalid mime typeJohn Hawthorn2019-03-141-2/+2
| | | | | | | This allows mime types in the form text/html, text/*, or */* This required a few minor test/code changes where previously nil was used as a mime string.
* appropriate typo fixalkesh262019-02-191-1/+1
|
* Support testing of non-ActionDispatch-routed apps.Darren Cheng2019-02-051-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The [Grape API framework](https://github.com/ruby-grape/grape) regularly writes tests like [spec/grape/api_spec.rb](https://github.com/ruby-grape/grape/blob/master/spec/grape/api_spec.rb). When attempting to write a test in a Rails environment similar to the following: ``` describe Grape::Api, type: :request do let(:app) { Class.new(Grape::API) do get 'test' do { foo: 'bar' } end end } it '200s' do get 'test' end end ``` The following exception is thrown: ``` NoMethodError: undefined method `url_helpers' for #<Array:0x00007fb4e4bc4c88> -- 0: .../lib/action_dispatch/testing/integration.rb:330:in `block in create_session' 1: .../lib/action_dispatch/testing/integration.rb:326:in `initialize' 2: .../lib/action_dispatch/testing/integration.rb:326:in `new' 3: .../lib/action_dispatch/testing/integration.rb:326:in `create_session' 4: .../lib/action_dispatch/testing/integration.rb:316:in `integration_session' 5: .../lib/action_dispatch/testing/integration.rb:348:in `block (2 levels) in <module:Runner>' ``` This change explicitly ensures that `app.routes` is an `ActionDispatch::Routing::RouteSet` instance.
* Merge pull request #34952 from rails/template-stuffAaron Patterson2019-01-221-1/+8
|\ | | | | Template Handler Refactoring
| * Only cache the view_context_class in one placeAaron Patterson2019-01-181-1/+8
| | | | | | | | | | | | | | This patch removes the instance writer of view_context_class. Subclasses may override it, but it doesn't need to be written. This also eliminates the need to cache the return value of the class level `view_context_class` method.
* | Remove deprecated methods in ActionDispatch::TestResponseRafael Mendonça França2019-01-171-27/+0
|/ | | | | `#success?`, `missing?` and `error?` were deprecated in Rails 5.2 in favor of `#successful?`, `not_found?` and `server_error?`.
* Allow using parsed_body in ActionController::TestCaseTobias Bühlmann2018-12-161-6/+5
| | | | | | | | | | | | … by switching the initialzation of an appropriate response parser in `ActionDispatch::TestResponse` from eagerly to lazily. By doing so, the response parser can be correctly set for `ActionController::TestCase`, which doesn't include the content type header in the constructor but only sets it at a later time. Fixes #34676.
* Revert "Merge pull request #33970 from rails/eager-url-helpers"schneems2018-10-031-27/+10
| | | | | | | Until #34050 can be resolved This reverts commit 7f870a5ba2aa9177aa4a0e03a9d027928ba60e49, reversing changes made to 6556898884d636c59baae008e42783b8d3e16440.
* Eagerly build the routing helper module after routes are committedAaron Patterson2018-09-251-10/+27
| | | | | | | | | | | | | | This commit eagerly builds the route helper module after the routes have been drawn and finalized. This allows us to cache the helper module but not have to worry about people accessing the module while route definition is "in-flight", and automatically deals with cache invalidation as the module is regenerated anytime someone redraws the routes. The restriction this commit introduces is that the url helper module can only be accessed *after* the routes are done being drawn. Refs #24554 and #32892
* Merge pull request #33973 from rails/remove-catch-allAaron Patterson2018-09-251-0/+5
|\ | | | | Remove deprecated catch-all route in the AV tests
| * Add hack to deal with warningsAaron Patterson2018-09-241-1/+1
| | | | | | | | | | We should be able to remove this once the catch-all route is gone from AP
| * Remove deprecated catch-all route in the AV testsAaron Patterson2018-09-241-0/+5
| | | | | | | | | | | | | | | | This commit removes a deprecated catch-all route in the AV tests. It defines and includes the necessary routes for each test such that we don't need the catch-all anymore. This also helps push us toward #33970
* | Enable `Performance/UnfreezeString` copyuuji.yaginuma2018-09-231-3/+2
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In Ruby 2.3 or later, `String#+@` is available and `+@` is faster than `dup`. ```ruby # frozen_string_literal: true require "bundler/inline" gemfile(true) do source "https://rubygems.org" gem "benchmark-ips" end Benchmark.ips do |x| x.report('+@') { +"" } x.report('dup') { "".dup } x.compare! end ``` ``` $ ruby -v benchmark.rb ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-linux] Warming up -------------------------------------- +@ 282.289k i/100ms dup 187.638k i/100ms Calculating ------------------------------------- +@ 6.775M (± 3.6%) i/s - 33.875M in 5.006253s dup 3.320M (± 2.2%) i/s - 16.700M in 5.032125s Comparison: +@: 6775299.3 i/s dup: 3320400.7 i/s - 2.04x slower ```
* Clarify example of the test [ci skip] 黄松2018-08-251-2/+2
| | | ActionDispatch::TestProcess::FixtureFile
* Enable Start/EndWith and RegexpMatch copsBart de Water2018-07-282-3/+3
| | | | | In cases where the MatchData object is not used, this provides a speed-up: https://github.com/JuanitoFatas/fast-ruby/#stringmatch-vs-stringmatch-vs-stringstart_withstringend_with-code-start-code-end
* Prevent `RequestEncoder#encode_params` to parse falsey paramsAlireza Bashiri2018-07-201-1/+1
| | | | | | | | | | | | | | When a `get` method called with `as: :json` and `params: nil` or `params: false` (explicitly or implicitly) `RequestEncoder#encode_params` converts it into a `null` or `false` value which includes a unexpected `null=` or `false` query string into request URL. From now on `RequestEncoder#encode_params` checks whether `params` is nil or not otherwise returns. Move down `nil` conversion guard Update CHANGELOG.md
* Pass along arguments to underlying `get` method in `follow_redirect!` (#33299)Remo Fritzsche2018-07-051-3/+4
| | | | | | | | | | | | | | | | * Allow get arguments for follow_redirect Now all arguments passed to `follow_redirect!` are passed to the underlying `get` method. This for example allows to set custom headers for the redirection request to the server. This is especially useful for setting headers that may, outside of the testing environment, be set automatically on every request, i.e. by a web application firewall. * Allow get arguments for follow_redirect [Remo Fritzsche + Rafael Mendonça França]
* Merge pull request #29955 from padi/update_actiondispatch_integration_docsRyuta Kamizono2018-05-041-0/+6
|\ | | | | | | | | Updates documentation on ActionDispatch::Integration::Session#process [ci skip]
| * Updates (rdoc) documentation on ActionDispatch::Integration::Session#processMarc Rendl Ignacio2017-07-271-0/+6
| | | | | | | | | | | | Adds missing information on 2 parameters: +xhr+ and +as+ [ci skip]
* | [Action Pack] require => require_relativeAkira Matsuda2017-10-213-4/+4
| | | | | | | | | | This basically reverts e9fca7668b9eba82bcc832cb0061459703368397, d08da958b9ae17d4bbe4c9d7db497ece2450db5f, d1fe1dcf8ab1c0210a37c2a78c1ee52cf199a66d, and 68eaf7b4d5f2bb56d939f71c5ece2d61cf6680a3
* | [ci skip]Enable link to ActionDispatch::Integration::Session#process in rdocwillnet2017-10-121-12/+12
| |
* | Use tt in doc for ActionPack [ci skip]Yoshiyuki Hirano2017-08-261-1/+1
| |
* | Deprecate ActionDispatch::TestResponse response aliasesTrevor Wistaff2017-08-071-3/+21
| | | | | | | | https://github.com/rails/rails/issues/30072
* | Use frozen string literal in actionpack/Kir Shatrov2017-07-299-0/+18
|/
* Merge branch 'master' into require_relative_2017Xavier Noria2017-07-021-1/+1
|\
| * Revert "Merge pull request #29540 from kirs/rubocop-frozen-string"Matthew Draper2017-07-029-9/+0
| | | | | | | | | | This reverts commit 3420a14590c0e6915d8b6c242887f74adb4120f9, reversing changes made to afb66a5a598ce4ac74ad84b125a5abf046dcf5aa.
| * Merge pull request #29540 from kirs/rubocop-frozen-stringMatthew Draper2017-07-029-0/+9
| |\ | | | | | | | | | Enforce frozen string in Rubocop
| | * Enforce frozen string in RubocopKir Shatrov2017-07-019-0/+9
| | |
| * | Merge pull request #29506 from pat/frozen-string-literalsMatthew Draper2017-07-021-1/+1
| |\ \ | | |/ | |/| | | | Make ActiveSupport frozen-string-literal friendly.
| | * Make ActionView frozen string literal friendly.Pat Allan2017-06-201-1/+1
| | | | | | | | | | | | Plus a couple of related ActionPack patches.
* | | [Action Dispatch] require => require_relativeAkira Matsuda2017-07-013-4/+4
|/ /
* | Calling `follow_redirect!` does not reset the `html_document`:Edouard CHIN2017-06-261-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | - When making a request to a controller that redirects, `follow_redirect!` would not reset the `html_document` ivar, it only resets the `html_document` ivar from the session (not the runner) - If one was doing something like this; ```ruby get '/redirect' assert_select 'you are being redirected' follow_redirect! # html_document is memoized and doesn't get reset ``` - To fix the issue we can do the same for any other methods (`get`, `post`...) and define a method in the runner that delegates to the session but clears the html_document_first - Fixes #29367
* | Removed reference to unexisting methods:Edouard CHIN2017-06-231-2/+1
|/ | | | `get/post_via_redirect`, `xhr` and his alias `xml_http_request` were respectively removed in 092033d59f7e2b248f6c6ab6c0b67339c5e9f2df and eb52e5d42fbdc9288925a402dcb3c5664d1125b7
* `respond_to_missing?` should be privateRyuta Kamizono2017-04-221-5/+6
| | | | | | | Follow up of 03d3f036. Some of `respond_to?` were replaced to `respond_to_missing?` in 03d3f036. But the visibility is still public. It should be private.
* Merge pull request #28394 from shime/docs-action-dispatchXavier Noria2017-03-224-11/+9
|\ | | | | [docs] fix ActionDispatch documentation
| * [docs] fix ActionDispatch documentationHrvoje Šimić2017-03-134-11/+9
| |
* | Cleanup documentation fixes (#28460)Vipul A M2017-03-171-3/+3
| |
* | Updates incorrect documentation [ci skip]Dmitriy Budnik2017-03-161-4/+3
| | | | | | | | | | Looking on code for this method it's clear that it's just returns `response.status` instead of full `response` object. It's better to correct docs as probably lots of specs are relying on this behavior.
* | Fix Typo [ci skip]Olivier2017-03-131-1/+1
|/ | | Arcticle --> Article
* Remove unused requireRyuta Kamizono2017-02-121-1/+0
| | | | | | These files are not using `strip_heredoc`. Closes #27976
* Reduce string objects by using \ instead of + or << for concatenating stringsAkira Matsuda2017-01-121-2/+2
| | | | (I personally prefer writing one string in one line no matter how long it is, though)
* String#end_with? should be faster than Regexp hereAkira Matsuda2017-01-051-1/+1
|
* fix with_routing when testing api only controllersJulia López2016-12-291-2/+5
|
* Only move fixture_file_upload to IntegrationTestMatthew Draper2016-12-072-18/+22
| | | | | The rest of the helpers are better placed on Session -- and this is the only one that cares which class it is defined on.
* [ci skip] Update the `as` docs.Kasper Timm Hansen2016-11-271-1/+2
| | | | Mention the Accept header and how that figures into the request format.
* Remove default argument value.Kasper Timm Hansen2016-11-271-1/+1
| | | | Wrongly added when fixing the request path wrangling.