Commit Graph

12265 Commits

Author SHA1 Message Date
Jerry D'Antonio
284a9ba8ec Replaced ActiveSupport::Concurrency::Latch with concurrent-ruby.
The concurrent-ruby gem is a toolset containing many concurrency
utilities. Many of these utilities include runtime-specific
optimizations when possible. Rather than clutter the Rails codebase with
concurrency utilities separate from the core task, such tools can be
superseded by similar tools in the more specialized gem. This commit
replaces `ActiveSupport::Concurrency::Latch` with
`Concurrent::CountDownLatch`, which is functionally equivalent.
2015-07-13 15:44:21 -04:00
Claudio B.
e0a7e7b0ee Merge pull request #20842 from TheBlasfem/removed_usage_lines_docs
Removed usage line docs [ci skip]
2015-07-11 22:38:05 -07:00
Julio Lopez
789a2df86e added description instead of remove usage [ci skip] 2015-07-11 21:28:07 -05:00
Aaron Patterson
8f81f7a73d Merge pull request #17102 from matthewd/load-interlock
Concurrent load interlock (rm Rack::Lock)
2015-07-10 15:42:08 -07:00
Aaron Patterson
3c5bd78ddb we don't really need an extra method to set the script name 2015-07-10 14:19:11 -07:00
Aaron Patterson
85903d1b08 Remove useless conditional
PATH_INFO is already set, so this branch will never execute.
2015-07-10 14:19:11 -07:00
Aaron Patterson
e459b29fb4 default PATH_INFO to the generated path
we were already generating a path in the previous code (it was just not
returned), so lets just use the already computed path to popluate the
PATH_INFO header
2015-07-10 14:19:11 -07:00
Aaron Patterson
8b4eca09a5 always default the SCRIPT_NAME to whatever is on the controller 2015-07-10 14:19:11 -07:00
Aaron Patterson
889a4a3da0 remove useless ivar clearing
Since we only work with new instances, these ivars will not be set.
2015-07-10 14:19:11 -07:00
Aaron Patterson
314ac0cd57 call the path_parameters= setter rather than rely on mutations
We should call the setter on `path_parameters` so that we know the hash
will only contain the values that we've set.
2015-07-10 14:19:10 -07:00
Aaron Patterson
f1fcf9b526 start collecting env mutations
I'd like to put all env mutations together so we can understand how to
change this code to call `call` on the controller
2015-07-10 14:19:10 -07:00
Aaron Patterson
0adb8f8fa6 Parameters are converted to a query string
Since parameters are converted to a query string, they will
automatically be turned in to strings by the query parser
2015-07-10 14:19:10 -07:00
Aaron Patterson
11bc078928 no more HWIA
non_path_parameters is used internally (it never escapes this method) so
we should be able to safely use a regular hash.
2015-07-10 14:19:10 -07:00
Aaron Patterson
79ab812663 remove param dup'ing logic
since we are serializing parameters, we don't need to do all the dup
checks on each object.
2015-07-10 14:19:10 -07:00
Aaron Patterson
c546a2b045 encode / decode parameters before assigning them to the request
We should roundtrip the parameters through their respective encoders /
decoders so that the controller will get parameters similar to what they
actually get in a real world situation
2015-07-10 14:19:10 -07:00
Aaron Patterson
f3bae24c81 start disconnecting the parameter parser from the instance
pass in the instance variable to start decoupling the meat of the parser
from the instance of the middleware
2015-07-10 11:53:06 -07:00
Aaron Patterson
a1d7d65f0a drop a conditional by always assigning
We will always make an assignment to the env hash and eliminate a
conditional
2015-07-10 11:53:05 -07:00
Aaron Patterson
eb10496a1c drop runtime conditionals in parameter parsing
If we only deal with proc objects, then we can eliminate type checking
in the parameter parsing middleware
2015-07-09 14:56:38 -07:00
Aaron Patterson
140d5a3b2f use Rack::Test::UploadedFile when uploading files
We should use rack-test's upload file objects on the test side so that
we will be able to correctly generate mime blob posts in the future
2015-07-09 11:51:45 -07:00
Aaron Patterson
394b7be036 set parameters as a query string
We should convert request parameters to a query string, then let the
request object parse that query string.  This should give us results
that are more similar to the real-world
2015-07-09 10:12:19 -07:00
Aaron Patterson
40ed4eefe4 use JSON to communicate between the controller and the tests 2015-07-09 07:50:41 -07:00
Aaron Patterson
5ea8efecd0 build and assign parameters rather than rely on mutations
We should assign parameters to the request object rather than mutate the
hash that is returned by `query_parameters` or `request_parameters`
2015-07-08 16:43:58 -07:00
Aaron Patterson
9f09848918 assign the cookie hash on request allocation
this prevents mutations from being available globally
2015-07-08 16:27:02 -07:00
Aaron Patterson
f65fd25f04 request objects are no longer recycled
Instead of trying to manually clear out a request object, lets just
allocate a new one.  The rack ENV is reused and cleaned (still), but the
request object is not.
2015-07-08 16:23:32 -07:00
Aaron Patterson
b5a9525932 pass the variant as a parameter to more reflect real world apps 2015-07-08 16:15:50 -07:00
Aaron Patterson
78a5124bf0 add a new constructor for allocating test requests 2015-07-08 16:09:49 -07:00
Aaron Patterson
db41f33d7c make env a required parameter 2015-07-08 15:59:30 -07:00
Aaron Patterson
3cae6bc5fc pass the starting env and session to build_request 2015-07-08 15:17:50 -07:00
Aaron Patterson
4b1a0adf54 remove call to build_request 2015-07-08 15:14:41 -07:00
Aaron Patterson
3806eb70a6 pass the session and env in to the test request 2015-07-08 14:32:54 -07:00
Aaron Patterson
460079a771 let the superclass build the request and response
We should leverage the request / response objects that the superclass
has already allocated for us.
2015-07-08 14:15:53 -07:00
Aaron Patterson
ef2d7a69ec remove useless new implementation 2015-07-08 11:39:55 -07:00
Aaron Patterson
2b5d309aeb allocate new responses rather than recycling them
There is no reason to "recycle" response objects when we can just
allocate a new one.
2015-07-08 11:16:44 -07:00
Matthew Draper
48a735aff7 Fix the Interlock middleware
We can't actually lean on Rack::Lock's implementation, so we'll just
copy it instead. It's simple enough that that's not too troubling.
2015-07-09 03:31:31 +09:30
Matthew Draper
c37d47e308 Soften the lock requirements when eager_load is disabled
We don't need to fully disable concurrent requests: just ensure that
loads are performed in isolation.
2015-07-09 02:23:23 +09:30
Aaron Patterson
59a9068c3f pass variants in rather than mutating the request.
Variants are typically set in the controller based on some attribute of
the request that the browser sent.  We should make our tests more in
line with reality by doing the same and not mutating the request object.
2015-07-07 15:51:01 -07:00
eileencodes
8363b879fe pass cookies from the jar in the HTTP_COOKIE header
we should be pushing the cookies in via headers rather than maintaining
some object and "recycling" it.
2015-07-07 14:31:34 -07:00
eileencodes
ae29142142 Send cookies with request 2015-07-07 14:31:34 -07:00
Arthur Nogueira Neves
e598967548 Merge pull request #13897 from gmalette/nested-parameter-filtering-2
Allow filtering params based on parent keys
2015-07-06 16:33:01 +02:00
Matthew Draper
3046c9bbe1 Merge pull request #20782 from kaspth/fix-controller-caching-test
Fix the random caching test failure. (Take two)
2015-07-06 05:24:50 +09:30
eileencodes
a05e245ca5 Refactor cookie_jar to decouple it from request object
This change decouples `cookie_jar` allocation from the request object.
We need this for moving controller tests to integration tests so we can
access the `cookie_jar` object separately.
2015-07-05 12:59:24 -04:00
Kasper Timm Hansen
90ebba6836 Fix the random caching test failure. 2015-07-05 13:53:20 +02:00
claudiob
352c8473ef [ci skip] Don't use TrueClass, FalseClass in docs
This sort of documentation style comes from 2009, probably due to
the merging of merb (see 38b608ecab (diff-017d9bc9b1d2bdae199b938d72c15488R120)).

Rails follows Ruby's convention to define which values are "truthy" or
"falsey", so there is no need to specify that the returned value must
strictly be a TrueClass or FalseClass. /cc @fxn
2015-07-02 08:08:46 -07:00
Roque Pinel
48dc8261e3 [ci skip] Improve the url_for documentation
Clarify the `url_for` usage in mailers.

Re-add the documentation about `url_for` and Route's path parameters,
first introduced by 5c4f1859970d06228a0b67cad6d4486c1526ef2a.
This was reported on #15097 and until it is decided to deprecate it
or not, I believe the documentation should exist.
2015-07-01 10:18:13 -05:00
eileencodes
4d7b507073 Improve error messages in cookies_test
Using `assert_predicate` and `assert_match` instead of just `assert` is
preferrable because better error messages are output.

In the case of `assert response.cookies.empty?` the error message was
`Failed assertion, no message given.` but now with `assert_predicate` it
will be `Expected {"user_name"=>"david"} to be empty?.`

For `assert_match(/user_name=david/,
response.headers["Set-Cookie"])` as well, the message returned was
unhelpful - `Failed assertion, no message given.` but now will tell what
was expected and what was returned with `Expected /user_name=david/ to
match "user_name=nope; path=/".`
2015-06-27 16:48:20 -04:00
Kasper Timm Hansen
991e98f564 Merge pull request #20276 from davetron5000/revert-head-on-no-template
Allow default_render to take a block to customize behavior when there's no template
2015-06-27 22:18:17 +02:00
Claudio B.
7814d80897 Merge pull request #20664 from vngrs/remove_mistaken_end_from_doc
Remove mistaken end from controller_path doc [ci skip]
2015-06-22 15:46:28 -07:00
Rafael Mendonça França
75b63de5ed Merge pull request #19431 from hmarr/head-routing
Respect routing precedence for HEAD requests
2015-06-22 19:34:37 -03:00
Mehmet Emin İNAÇ
b835c72bc9 Remove mistaken end from controller_path doc [ci skip] 2015-06-22 19:36:01 +03:00
Guillaume Malette
33b93174f0 Allow filtering params based on parent keys
Add the possibility to only filter parameters based on
their full path instead of relying on the immediate key.

    config.filter_parameters += ['credit_card.code']

    { 'credit_card' => { 'code' => '[FILTERED]' },
      'source' => { 'code' => '<%= puts 5 %>' } }
2015-06-22 10:04:11 -04:00