Commit Graph

45 Commits

Author SHA1 Message Date
Aaron Patterson
8037d7eacd extract required_defaults from the conditions hash before constructing the route
this way we can remove the strange "respond_to?" conditional in the
`matches?` loop
2015-06-08 17:18:32 -07:00
Rafael Mendonça França
d4cfd54308 Prefer assert_not over refute 2015-05-18 19:33:25 -03:00
Valentine Valyaeff
bad30ed46c ActionDispatch::Journey::Routes#empty? test cases 2015-05-19 01:21:20 +03:00
Prem Sichanugrist
7cb9e20c6c Silence ambiguous first argument warning
This silences:

    actionpack/test/journey/route_test.rb:33: warning: ambiguous first
    argument; put parentheses or a space even after `/' operator
2015-05-04 10:15:50 -04:00
Arthur Nogueira Neves
86929c00c0 Merge pull request #18392 from brainopia/fix_route_requirements
Correct route requirements by overriding defaultls
2015-04-27 09:15:22 -04:00
Yang Bo
a77de09812 sort_by instead of sort
it is avoid sort errot within different and mixed keys.
used `sort_by` + `block` to list parameter by keys.
keep minimum changes
2015-04-08 22:18:56 +08:00
Aaron Patterson
12f2fc56aa Merge pull request #15806 from tgxworld/partition_routes_during_setup
Partition routes during setup.
2015-03-02 15:02:14 -08:00
Zoltan Kiss
f5b192837a Remove unneeded comment. [ci skip] 2015-03-02 11:03:33 -06:00
Guo Xiang Tan
89edfbd3a4 Partition routes during setup.
Partitioning of all the routes is currently being done during the
first request. Since there is no need to clear the cache for
`partitioned_routes` when adding a new route. We can move the
partitioning of the routes during setup time.
2015-02-26 12:18:20 +08:00
Vipul A M
6eced6a1fe Removed magic comments # encoding: utf-8 , since its default from ruby 2.0 onwards. 2015-02-03 20:51:40 +05:30
brainopia
f9e2496872 Correct route requirements by overriding defaultls (fixes #18373) 2015-01-08 02:53:57 +03:00
Konstantin Haase
0d690d75fb make OR in journey patterns compile to a valid regular expression 2014-11-29 01:26:10 +01:00
Godfrey Chan
938d130c62 Fix cases where the wrong name is passed to Formatter#generate
These are currently working "by accident" because `match_route` does not check
that the name is valid.
2014-11-23 01:08:53 -08:00
Accessd
2224bf7992 fix url generation error message 2014-10-21 12:10:48 +04:00
Nicolas Cavigneaux
3041bb2a94 Improve Journey compliance to RFC 3986
The scanner in Journey fails to recognize routes that use literals
from the sub-delims section of RFC 3986.

This commit enhance the compatibility of Journey with the RFC by
adding support of authorized delimiters to the scanner.

Fix #17212
2014-10-14 16:42:50 +02:00
Guo Xiang Tan
9212042631 Improve router test.
We should assert that routes will not be recognized if the verbs do
not match.
2014-08-21 16:35:39 +08:00
Guo Xiang Tan
d3eb92d95a Avoid duplicating routes for HEAD requests.
Follow up to rails#15321

Instead of duplicating the routes, we will first match the HEAD request to
HEAD routes. If no match is found, we will then map the HEAD request to
GET routes.
2014-08-21 16:35:39 +08:00
Karl Entwistle
8a29713134 Force encoding of US-ASCII to UTF-8 in unescape_uri.
Because URI paths may contain non US-ASCII characters we need to force
the encoding of any unescaped URIs to UTF-8 if they are US-ASCII.
This essentially replicates the functionality of the monkey patch to
URI.parser.unescape in active_support/core_ext/uri.rb.

Fixes #16104.
2014-07-10 10:02:11 +01:00
Kuldeep Aggarwal
fca73eeb87 remove warnings
warning: assigned but unused variable - scope_called, path and strexp
2014-06-12 00:27:58 +05:30
Aaron Patterson
da2cf937aa no more is_a checks on instantiation 2014-05-29 15:45:42 -07:00
Aaron Patterson
bb207ea7b6 Path::Pattern is instantiated internally, so make the contructor require a strexp object 2014-05-29 15:44:54 -07:00
Aaron Patterson
5682596db7 Strexp#names is only used in a test, so rm 2014-05-29 15:31:45 -07:00
Aaron Patterson
15ffbedf3b add an alternate constructor to Strexp that takes a string 2014-05-29 15:23:30 -07:00
Guo Xiang Tan
b1bc553385 Remove TODO. 2014-05-28 20:06:08 -07:00
Aaron Patterson
b18f22d15c pass the request object to the application 2014-05-25 14:26:48 -07:00
Aaron Patterson
633589c140 push is_a?(Dispatcher) check in to one place 2014-05-24 19:03:12 -07:00
Aaron Patterson
6d48d97947 glob_param is never used, so rm
this also changes the constructor.  We don't need to pass more options
than "defaults" (whatever defaults are, ugh. probably another hash of
stupid stuff).
2014-05-23 15:25:46 -07:00
Aaron Patterson
0f5e3a9f6b decouple the router object from the request class 2014-05-23 10:57:25 -07:00
Aaron Patterson
6fd8346400 pass the correct custom request to the recognize method 2014-05-23 10:57:25 -07:00
Aaron Patterson
6ed5b01f97 switch to the serve method so we can remove the request class (eventually) 2014-05-23 10:57:25 -07:00
Aaron Patterson
890e0a97fb remove NullRequest and just always pass a request class 2014-05-23 10:09:24 -07:00
Aaron Patterson
a6e94547e8 use the request object since we have it
stop hardcoding hash keys and use the accessors provided on the request
object.
2014-05-23 09:56:33 -07:00
Aaron Patterson
dd1f23df7b middle variable is never used, so rm 2014-05-21 16:12:49 -07:00
Aaron Patterson
089d9baa33 we don't use this parameter for anything, so rm 2014-05-20 16:06:59 -07:00
Andrew White
5460591f02 Make URL escaping more consistent
1. Escape '%' characters in URLs - only unescaped data
   should be passed to URL helpers

2. Add an `escape_segment` helper to `Router::Utils`
   that escapes '/' characters

3. Use `escape_segment` rather than `escape_fragment`
   in optimized URL generation

4. Use `escape_segment` rather than `escape_path`
   in URL generation

For point 4 there are two exceptions. Firstly, when a route uses wildcard
segments (e.g. *foo) then we use `escape_path` as the value may contain '/'
characters. This means that wildcard routes can't be optimized. Secondly,
if a `:controller` segment is used in the path then this uses `escape_path`
as the controller may be namespaced.

Fixes #14629, #14636 and #14070.
2014-04-20 10:11:38 +01:00
edogawaconan
e2ef83f838 Always escape string passed to url helper.
Makes it clear that anything passed with the helper must not be percent encoded.

Fixes previous behavior which tricks people into believing passing
non-percent-encoded will generate a proper percent-encoded path while in
reality it doesn't ('%' isn't escaped).

The intention is nice but the heuristic is broken.
2014-04-20 10:11:37 +01:00
Godfrey Chan
ff1192fea4 Eliminate JSON.{parse,load,generate,dump} and def to_json
JSON.{dump,generate} offered by the JSON gem is not compatiable with
Rails at the moment and can cause a lot of subtle bugs when passed
certain data structures. This changed all direct usage of the JSON gem
in internal Rails code to always go through AS::JSON.{decode,encode}.

We also shouldn't be implementing `to_json` most of the time, and
these occurances are replaced with an equivilent `as_json`
implementation to avoid problems down the road.

See [1] for all the juicy details.

[1]: intridea/multi_json#138 (comment)
2013-11-05 22:26:45 -08:00
Josh Symonds
cb81a535e0 Correct error in Utils.normalize_path that changed paths improperly 2013-10-23 16:44:23 -05:00
Andrew White
1555a1800e Skip Rack applications and redirects when generating urls
When generating an unnamed url (i.e. using `url_for` with an options
hash) we should skip anything other than standard Rails routes otherwise
it will match the first mounted application or redirect and generate a
url with query parameters rather than raising an error if the options
hash doesn't match any defined routes.

Fixes #8018
2013-07-16 13:39:17 +01:00
zires
35f38b71df Make ActionDispatch::Journey::Path::Pattern#new raise more meaningful exception message. 2013-02-27 08:26:51 +08:00
Andrew White
f1d8f2af72 Change the behavior of route defaults
This commit changes route defaults so that explicit defaults are no
longer required where the key is not part of the path. For example:

  resources :posts, bucket_type: 'posts'

will be required whenever constructing the url from a hash such as a
functional test or using url_for directly. However using the explicit
form alters the behavior so it's not required:

  resources :projects, defaults: { bucket_type: 'projects' }

This changes existing behavior slightly in that any routes which
only differ in their defaults will match the first route rather
than the closest match.

Closes #8814
2013-01-15 17:22:25 +00:00
Andrew White
db06d12826 Raise correct exception now Journey is integrated.
Now that Journey has been integrated into ActionDispatch we can raise
the exception ActionController::UrlGenerationError directly rather than
raising the internal Journey::Router::RoutingError and then have
ActionDispatch::Routing::RouteSet#generate re-raise the exception.
2013-01-15 17:21:33 +00:00
Rafael Mendonça França
dc8091b88f Use ActiveSupport::TestCase in the journey tests 2012-12-31 14:40:43 -03:00
Rafael Mendonça França
5294ad82c6 Alias refute methods to assert_not and perfer assert_not on tests 2012-12-31 13:58:52 -03:00
Andrew White
56fee39c39 Integrate Journey into Action Dispatch
Move the Journey code underneath the ActionDispatch namespace so
that we don't pollute the global namespace with names that may
be used for models.

Fixes rails/journey#49.
2012-12-19 22:13:08 +00:00