Commit Graph

5087 Commits

Author SHA1 Message Date
Vlad Bokov
59dbf68960 Display diagnostics in text format for xhr request 2014-04-14 20:48:13 +07:00
James Coglan
77252c332e Add a failing test for a URL helper that was broken by a6b9ea2. 2014-04-10 13:54:41 +01:00
Andriel Nuernberg
85e424de6c Avoid URI parsing
This parsing is unecessary once the Request object already has the
needed information.
2014-04-09 14:19:53 -03:00
Vipul A M
a44d7107df Remove unused subclass_controller_with_flash_type_bar var from flash test. 2014-04-07 10:34:17 +05:30
Guo Xiang Tan
8bbaa94c81 Fix setup of adding _flash_types test.
Adding flash types to a controller within any of the tests will result
in a global state change of the controller under test.

This patch will prevent state leaks and allow us to run the test in random order.
2014-04-06 13:30:49 -07:00
Boris Kuznetsov
6af07c27ae Append link to bad code to backtrace when exception is SyntaxError 2014-03-27 00:36:59 +04:00
David Heinemeier Hansson
9d44b3f886 Update test helper to use latest Digestor API 2014-03-21 19:39:08 +01:00
Attila Domokos
102c556e0b Cleaning and adding tests for Session
Adding tests for Session `destroy`, `update` and `delete` methods. No changes for code under test.
2014-03-19 21:01:08 -05:00
Aaron Patterson
ba3ad256c6 Merge pull request #14090 from Fortisque/kevin/stream_error_in_main_thread_if_not_committed
re-raise error if error occurs before committing in streaming
2014-03-17 10:49:07 -07:00
Jeremy Kemper
cbc3b89c10 Add an explicit require for 4ece124396669d3580e7f229ab407a0d4882727a rather than assume SecureRandom is available 2014-03-16 16:08:16 -07:00
Jeremy Kemper
4ece124396 Avoid concurrent test collision on the same memcache server by namespacing keys 2014-03-16 16:06:27 -07:00
Andrew White
bb0518891c Use nested_scope? not shallow? to determine whether to copy options
The method `shallow?` returns false if the parent resource is a singleton so
we need to check if we're not inside a nested scope before copying the :path
and :as options to their shallow equivalents.

Fixes #14388.
2014-03-16 09:35:35 +00:00
Kevin Casey
933e9b4fe2 re-raise error if error occurs before committing in streaming
update the tests, using an if-else
2014-03-14 23:54:43 -07:00
Rafael Mendonça França
274d5e45e0 Merge pull request #14329 from pch/digestor-lookup-fix
Ensure LookupContext in Digestor selects correct variant
2014-03-14 14:58:34 -03:00
Łukasz Strzałkowski
f72feae9ba Don't pass variant in params, it's ignored
We're setting variant above, in request object directly
2014-03-13 17:53:11 +01:00
Aaron Patterson
3df07d093a use the body proxy to freeze headers
avoid freezing the headers until the web server has actually read data
from the body proxy.  Once the webserver has read data, then we should
throw an error if someone tries to set a header
2014-03-12 17:40:08 -07:00
Aaron Patterson
77a09218f6 only write the jar if the response isn't committed
when streaming responses, we need to make sure the cookie jar is written
to the headers before returning up the stack. This commit introduces a
new method on the response object that writes the cookie jar to the
headers as the response is committed.  The middleware and test framework
will not write the cookie headers if the response has already been
committed.

fixes #14352
2014-03-12 16:07:26 -07:00
Piotr Chmolowski
025c691536 Ensure LookupContext in Digestor selects correct variant
Related to: #14242 #14243 14293

Variants passed to LookupContext#find() seem to be ignored, so
I've used the setter instead: `finder.variants = [ variant ]`.

I've also added some more test cases for variants. Hopefully this
time passing tests will mean it actually works.
2014-03-09 08:47:17 +01:00
Andrew White
af4c9b78ff Copy shallow options from normal options when using scope
If the options :shallow_prefix and :shallow_path are not set in the
scope options then copy them from the normal :as and :path options
if they are set.
2014-03-08 19:51:06 +00:00
Andrew White
8711086f5a Pull namespace defaults out of the options hash
If a developer has specified either :path or :as in the options hash then
these should be used as the defaults for :shallow_path and :shallow_prefix.

Fixes #14241.
2014-03-08 19:51:06 +00:00
Andrew White
dcc91a04a1 Only use shallow nested scope when depth is > 1
By tracking the depth of resource nesting we can push the need for nested
shallow scoping to only those routes that are nested more than one deep.
This allows us to keep the fix for #12498 and fix the regression in #14224.

Fixes #14224.
2014-03-08 19:51:06 +00:00
Santiago Pastorino
2af7a7b19c Merge pull request #14280 from joho/make_csrf_failure_logging_optional
Make CSRF failure logging optional/configurable.
2014-03-08 15:22:42 -02:00
Prem Sichanugrist
ed88a601f7
Do note remove Content-Type when render :body
`render :body` should just not set the `Content-Type` header. By
removing the header, it breaks the compatibility with other parts.

After this commit, `render :body` will returns `text/html` content type,
sets by default from `ActionDispatch::Response`, and it will preserve
the overridden content type if you override it.

Fixes #14197, #14238

This partially reverts commit 3047376870d4a7adc7ff15c3cb4852e073c8f1da.
2014-03-05 10:33:52 -05:00
John Barton (joho)
67584c6ae3 Make CSRF failure logging optional/configurable.
Added the log_warning_on_csrf_failure option to ActionController::RequestForgeryProtection
which is on by default.
2014-03-05 11:31:57 +11:00
Piotr Chmolowski
1858cc6070 Variants in ActionView::Digestor
Take variants into account when calculating template digests in
ActionView::Digest.

Digestor#digest now takes a hash as an argument to support variants and
allow more flexibility in the future. Old-style arguments have been
deprecated.

Fixes #14242
2014-03-04 15:02:58 +01:00
Zachary Scott
11e815e938 Refactor tests from BaseRackTest into BaseRequestTest 2014-03-01 15:38:47 -08:00
Aaron Patterson
401787db4b make sure we wait for the threads to shut down before asserting closure 2014-02-28 16:35:33 -08:00
Aaron Patterson
a7b059ec7f use built-in exception handling in live controllers
when an exception happens in an action before the response has been
committed, then we should re-raise the exception in the main thread.
This lets us reuse the existing exception handling.
2014-02-28 15:39:08 -08:00
Aaron Patterson
30d21dfcb7 live controllers should have live responses
detect the type of controller we're testing and return the right type of
response based on that controller.  This allows us to stop doing the
weird sleep thing.
2014-02-28 15:22:43 -08:00
Aaron Patterson
9af4258186 set the error callback to a nice default in case nobody set an error callback and an error happens 2014-02-28 11:57:15 -08:00
Tony Wooster
a351149e80 Fix controller test not resetting @_url_options
Commit 4f2cd3e9 introduced a bug by reordering the call to
`@controller.recycle!` above the call to `build_request_uri`. The
impact of this was that the `@_url_options` cache ends up not being
reset between building a request URI (occurring within the test
controller) and the firing of the actual request.

We encountered this bug because we had the following setup:

  class MinimumReproducibleController < ActionController::Base
    before_filter { @param = 'param' }

    def index
      render text: url_for(params)
    end

    def default_url_options
      { custom_opt: @param }
    end
  end

  def test_index
    get :index # builds url, then fires actual request
  end

The first step in  `get :index` in the test suite would populate the
@_url_options cache. The subsequent call to `url_for` inside of the
controller action would then utilize the uncleared cache, thus never
calling the now-updated default_url_options.

This commit fixes this bug calling recycle! twice, and removes a call
to set response_body, which should no longer be needed since we're
recycling the request object explicitly.
2014-02-26 10:39:44 -08:00
Serj L
88cfeca16a Simple Sungularize ActionController::UnpermittedParameters error in case when only 1 parameter is unpermitted. 2014-02-24 13:25:38 +04:00
Prem Sichanugrist
3047376870 Add #no_content_type attribute to AD::Response
Setting this attribute to `true` will remove the content type header
from the request. This is use in `render :body` feature.
2014-02-18 12:11:41 -05:00
Prem Sichanugrist
920f3ba266 Introduce render :html for render HTML string
This is an option for to HTML content with a content type of
`text/html`. This rendering option calls `ERB::Util.html_escape`
internally to escape unsafe HTML string, so you will have to mark your
string as html safe if you have any HTML tag in it.

Please see #12374 for more detail.
2014-02-18 12:08:36 -05:00
Prem Sichanugrist
8cd9f6d205 Introduce render :plain for render plain text
This is as an option to render content with a content type of
`text/plain`. This is the preferred option if you are planning to render
a plain text content.

Please see #12374 for more detail.
2014-02-18 12:08:36 -05:00
Prem Sichanugrist
9e9cc66077 Update hash format for render_text_test 2014-02-18 12:08:36 -05:00
Prem Sichanugrist
103e18c87d Introduce render :body for render raw content
This is an option for sending a raw content back to browser. Note that
this rendering option will unset the default content type and does not
include "Content-Type" header back in the response.

You should only use this option if you are expecting the "Content-Type"
header to not be set. More information on "Content-Type" header can be
found on RFC 2616, section 7.2.1.

Please see #12374 for more detail.
2014-02-18 12:08:36 -05:00
Kevin Casey
8508346dd0 Correct prestreaming controller response status.
if the controller action has not yet streamed any data, actions should
process as normal, and errors should trigger the appropriate behavior
(500, or in the case of ActionController::BadRequest, a 400 Bad Request)
2014-02-15 13:05:00 -08:00
David Heinemeier Hansson
bfc34fc005 No variant should also be picked up by variant.any if variant.none is not defined (just like any other variant) 2014-02-13 20:44:10 +01:00
Łukasz Strzałkowski
00a4af9ab7 Check if variant array contains only symbols 2014-02-13 18:05:55 +01:00
Lukasz Strzalkowski
f9b6b865e6 Variant negotiation
Allow setting `request.variant` as an array - an order in which they will be
rendered.

For example:

  request.variant = [:tablet, :phone]

  respond_to do |format|
    format.html.none
    format.html.phone # this gets rendered
  end
2014-02-13 16:22:56 +01:00
Godfrey Chan
b97e087321 Fixed broken flash tests 2014-02-11 01:54:17 -08:00
Godfrey Chan
ead947a3b2 Re-write legacy (marshal) cookies on read 2014-02-11 01:54:17 -08:00
Guillermo Iguaran
a6ce984b49 Convert FlashHash in a Hash with indifferent access 2014-02-11 01:54:17 -08:00
Godfrey Chan
ba6861d032 Changed the tests to ensure HybridSerializer actually migrates the cookies (currently failing) 2014-02-11 01:54:17 -08:00
Godfrey Chan
6de4888e04 Fixed minor typo in test code 2014-02-11 01:54:17 -08:00
Rafael Mendonça França
d4b7aa735a Tests for the HybridSerializer 2014-02-11 01:54:17 -08:00
Godfrey Chan
25f68ac6a2 Removed an old test 2014-02-11 01:54:17 -08:00
Godfrey Chan
54641fa2e3 Just very so slightly better test coverage 2014-02-11 01:54:16 -08:00
Godfrey Chan
b927d67dec Renamed session_serializer option to cookies_serializer 2014-02-11 01:54:16 -08:00