aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/dispatch/response_test.rb
Commit message (Collapse)AuthorAgeFilesLines
* Use assert_predicate and assert_not_predicateDaniel Colson2018-01-251-8/+8
|
* Use respond_to test helpersDaniel Colson2018-01-251-1/+1
|
* Add 'Referrer-Policy' header to default headers setGuillermo Iguaran2018-01-081-2/+4
|
* Add secure `X-Download-Options` and `X-Permitted-Cross-Domain-Policies` to ↵Guillermo Iguaran2017-12-091-2/+6
| | | | default headers set.
* Unused variablesAkira Matsuda2017-09-011-2/+2
|
* Merge pull request #29767 from yui-knk/ac_testRafael França2017-08-081-7/+2
|\ | | | | Remove needless restoring of `default_charset`
| * Remove needless restoring of `default_charset`yui-knk2017-07-131-7/+2
| | | | | | | | | | | | `default_charset` is not changed in this test case, so we do not need to backup an original value and restore it.
* | Use frozen string literal in actionpack/Kir Shatrov2017-07-291-0/+2
|/
* Revert "Merge pull request #29540 from kirs/rubocop-frozen-string"Matthew Draper2017-07-021-1/+0
| | | | | This reverts commit 3420a14590c0e6915d8b6c242887f74adb4120f9, reversing changes made to afb66a5a598ce4ac74ad84b125a5abf046dcf5aa.
* Enforce frozen string in RubocopKir Shatrov2017-07-011-0/+1
|
* Fix Rubocop violations and fix documentation visibilityRafael Mendonça França2016-12-281-1/+1
| | | | | | Some methods were added to public API in 5b14129d8d4ad302b4e11df6bd5c7891b75f393c and they should be not part of the public API.
* "Use assert_nil if expecting nil. This will fail in minitest 6."Akira Matsuda2016-12-251-2/+2
|
* Do not raise exception when content_type is a empty stringRafael Mendonça França2016-12-091-0/+5
| | | | | When content type header is blank we were raising an exception because `empty?` was being called on nil.
* Add more rubocop rules about whitespacesRafael Mendonça França2016-10-291-3/+3
|
* Add three new rubocop rulesRafael Mendonça França2016-08-161-10/+10
| | | | | | | | Style/SpaceBeforeBlockBraces Style/SpaceInsideBlockBraces Style/SpaceInsideHashLiteralBraces Fix all violations in the repository.
* remove redundant curlies from hash argumentsXavier Noria2016-08-061-2/+2
|
* modernizes hash syntax in actionpackXavier Noria2016-08-061-8/+8
|
* applies new string literal convention in actionpack/testXavier Noria2016-08-061-99/+99
| | | | | The current code base is not uniform. After some discussion, we have chosen to go with double quotes by default.
* Add tests for 1xx, 204 and 304 responses to response_test.rbMasaru Nomura2016-07-091-0/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | In response_test.rb, we haven't had a test to make sure that 1) these responses don't have a message-body as described in RFC7231[1] 2) 1xx and 204 responses must not have a Content-Length header field as described in RFC7230-section3.3.2[2] [1] https://tools.ietf.org/html/rfc7231 [2] https://tools.ietf.org/html/rfc7230#section-3.3.2 Even though our implementation doesn't allow users to send a Content-Length header field in a 304 response, sending the header field is valid as mentioned in RFC7230-section3.3.2[2]. So I've decided not to test whether or not a 304 response has the header. The citation from the section is as follows; ``` A server MAY send a Content-Length header field in a 304 (Not Modified) response to a conditional GET request (Section 4.1 of [RFC7232]); a server MUST NOT send Content-Length in such a response unless its field-value equals the decimal number of octets that would have been sent in the payload body of a 200 (OK) response to the same request. ```
* Merge pull request #24029 from ↵Sean Griffin2016-05-061-0/+33
|\ | | | | | | | | | | | | rthbound/dont-call-each-when-calling-body-on-response Dont call each when calling body on response to fix #23964 Fixes #23964
| * Fixes #23964Ryan T. Hosford2016-03-131-0/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - 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.
* | Strong ETag validatorsJeremy Daer2016-03-311-5/+30
|/ | | | | | | | | | | | | | | | | | * Introduce `Response#strong_etag=` and `#weak_etag=` and analogous options for `fresh_when` and `stale?`. `Response#etag=` sets a weak ETag. Strong ETags are desirable when you're serving byte-for-byte identical responses that support Range requests, like PDFs or videos (typically done by reproxying the response from a backend storage service). Also desirable when fronted by some CDNs that support strong ETags only, like Akamai. * No longer strips quotes (`"`) from ETag values before comparing them. Quotes are significant, part of the ETag. A quoted ETag and an unquoted one are not the same entity. * Support `If-None-Match: *`. Rarely useful for GET requests; meant to provide some optimistic concurrency control for PUT requests.
* Added a test for generating Strong ETagPrathamesh Sonpatki2016-02-241-0/+8
|
* Response etags to always be weak: Prefixed W/ to value returned by ↵abhishek2016-01-201-7/+7
| | | | ActionDispatch::Http::Cache::Response#etag= such that etags set in fresh_when and stale? are weak. For #17556.
* Commit before freezing the headersMatthew Draper2016-01-121-0/+21
| | | | | This shouldn't generally come up: under a standard flow, we don't start sending until after the commit. But application code always finds a way.
* Push `before_sending` to super classeileencodes2015-12-061-0/+5
| | | | | | | | | | | | 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.
* Remove skipped JRuby tests that are passing on 9.0.3.0.Guo Xiang Tan2015-10-271-2/+0
|
* Use `Mime[:foo]` instead of `Mime::Type[:FOO]` for back compatJeremy Daer2015-10-061-5/+5
| | | | | | | | | | | | | | | | | 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
* Merge pull request #21848 from yui-knk/test_suppress_warningsSean Griffin2015-10-041-3/+2
|\ | | | | Suppress warnings of `assigned but unused variable`
| * Suppress warnings of `assigned but unused variable`yui-knk2015-10-031-3/+2
| |
* | Introduce `Headers#add`. Move `Response#add_header` upstream.Jeremy Daer2015-10-031-10/+10
|/ | | | | | | * Introduce `ActionDispatch::Http::Headers#add` to add a value to a multivalued header. * Move `Response#add_header` upstream: https://github.com/rack/rack/pull/957 * Match upstream `Response#have_header?` -> `#has_header?` name change.
* Response#add_header for adding to multi-valued headers like VaryJeremy Daer2015-10-011-0/+59
|
* adding test for content type with default charsetGaurav Sharma2015-10-021-1/+11
| | | | | * first test is for `default_charset` i.e `ActionDispatch::Response.default_charset = “utf-8”` * In below test we are passing `ActionDispatch::Response.default_charset = 'utf-16’` so name of the test is irrelevant — “read content type without charset”
* stop applying default headers in ActionDispatch::ResponseAaron Patterson2015-09-231-3/+3
| | | | | | | | | | 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`
* split cookie testsAaron Patterson2015-09-231-1/+6
| | | | these should really be multiple tests.
* don't mutate a response object after to_aAaron Patterson2015-09-231-0/+2
| | | | | | When the response object is `to_a`'d, that means it's been written to the socket. It doesn't make sense to mutate the response object after it's been written (and this may raise an exception in the future).
* stop calling deprecated methodsAaron Patterson2015-09-211-5/+5
| | | | | We should be asking the mime type method for the mime objects rather than via const lookup
* ensure that mutating headers will impact the content_type methodAaron Patterson2015-09-081-0/+5
|
* ensure that content type defaults to text / html when setting charsetAaron Patterson2015-09-081-0/+7
|
* Merge pull request #20590 from vngrs/set_default_charsetRafael Mendonça França2015-07-271-0/+7
|\ | | | | Document, refactor and create test case for ActionDispatch::Response
| * Document, refactor and create test case for ↵Mehmet Emin İNAÇ2015-06-171-0/+7
| | | | | | | | ActionDispatch::Response#charset= method
* | Skip a few failing tests on JRuby with the attached ticketsRobin Dupret2015-07-171-0/+2
|/
* remove `header=` on the response object.Aaron Patterson2015-06-151-0/+2
| | | | | | People should be free to mutate the header object, but not to set a new header object. That header object may be specific to the webserver, and we need to hide it's internals.
* Revert "Revert integration test refactoring that caused app test regressions"eileencodes2015-03-091-4/+0
| | | | This reverts commit 714205988315d2f98aa3e749747c44470e18676b.
* 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') ```
* Fix segmentation fault in ActionPack testseileencodes2015-02-281-1/+1
| | | | | | Introduced in f6e293e ActionPack tests began sefaulting. I found that it was the kwargs and the test causing the seg fault was missing the new default_headers argument.
* Revert integration test refactoring that caused app test regressionsJeremy Kemper2015-02-261-0/+4
| | | | | | | | | | | | 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.
* lazily create the integration sessionAaron Patterson2015-02-121-4/+0
| | | | now we don't have to call reset! everywhere
* Remove deprecated `ActionDispatch::Response#to_ary`Rafael Mendonça França2015-01-041-16/+2
|
* Add support for Rack::ContentLength middelwareJavan Makhmali2014-09-061-0/+14
|