aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/dispatch/routing_test.rb
Commit message (Collapse)AuthorAgeFilesLines
* fix small typo in routing testAccessd2014-10-211-1/+1
|
* Don't ignore constraints in redirect routesAgis-2014-08-251-0/+24
| | | | | | | | https://github.com/rails/rails/commit/402c2af55053c2f29319091ad21fd6fa6b90ee89 introduced a regression that caused any constraints added to redirect routes to be ignored. Fixes #16605
* Remove unnecessary call to #tapCarlos Antonio da Silva2014-07-311-5/+3
| | | | | This is not storying the RouteSet instance anywhere as the other examples in the file, so no need to use #tap.
* always test against a routed rack app so there are always url_helpersAaron Patterson2014-07-071-32/+58
|
* Generate shallow paths for all children of shallow resources.Seb Jacobs2014-07-061-0/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Prior to this commit shallow resources would only generate paths for non-direct children (with a nested depth greater than 1). Take the following routes file. resources :blogs do resources :posts, shallow: true do resources :comments do resources :tags end end end This would generate shallow paths for `tags` nested under `posts`, e.g `/posts/:id/tags/`, however it would not generate shallow paths for `comments` nested under `posts`, e.g `/posts/:id/comments/new`. This commit changes the behaviour of the route mapper so that it generate paths for direct children of shallow resources, for example if you take the previous routes file, this will now generate shallow paths for `comments` nested under `posts`, .e.g `posts/:id/comments/new`. This was the behaviour in Rails `4.0.4` however this was broken in @jcoglan's fix for another routes related issue[1]. This also fixes an issue[2] reported by @smdern. [1] https://github.com/rails/rails/commit/d0e5963 [2] https://github.com/rails/rails/issues/15783
* Remove symbolized_path_parameters.Guo Xiang Tan2014-07-021-2/+2
| | | | This pull request is a continuation of https://github.com/rails/rails/commit/925bd975 and https://github.com/rails/rails/commit/8d8ebe3d.
* Routes specifying 'to:' must be a string that contains a "#" or a rackAaron Patterson2014-06-031-22/+30
| | | | | application. Use of a symbol should be replaced with `action: symbol`. Use of a string without a "#" should be replaced with `controller: string`.
* add tests for mixing :to and controller / actionAaron Patterson2014-06-031-0/+48
|
* test with an empty viaAaron Patterson2014-06-031-0/+8
|
* add a test for missing "via" parameterAaron Patterson2014-06-031-0/+8
|
* "controllers" should be a valid path nameAaron Patterson2014-05-291-0/+10
|
* add a test for controllers without colonsAaron Patterson2014-05-281-0/+10
|
* add a test for existing mapper functionalityAaron Patterson2014-05-281-0/+12
| | | | | I'm not sure if this is actually used, but I'm adding a test to define the behavior
* add tests for argument error casesAaron Patterson2014-05-281-0/+27
|
* extract request allocation from the main app serving routineAaron Patterson2014-05-231-0/+1
|
* use the request object since we have itAaron Patterson2014-05-231-5/+3
| | | | | stop hardcoding hash keys and use the accessors provided on the request object.
* stop using PARAMETERS_KEY, and use the accessor on the request objectAaron Patterson2014-05-221-0/+3
| | | | this decouples our code from the env hash a bit.
* Form full URI as string to be parsed in Rack::Test.Guo Xiang Tan2014-05-211-6/+6
| | | | There are performance gains to be made by avoiding URI setter methods.
* Add RFC4791 MKCALENDAR methodkasper2014-05-151-2/+3
|
* Use assert_raisesRafael Mendonça França2014-05-041-3/+1
|
* Merge pull request #11166 from xavier/callable_constraint_verificationRafael Mendonça França2014-05-041-0/+15
|\ | | | | | | | | | | | | Callable route constraint verification Conflicts: actionpack/CHANGELOG.md
| * Verify that route constraints respond to the expected messages instead of ↵Xavier Defrang2013-06-281-0/+15
| | | | | | | | silently failing to enforce the constraint
* | Make URL escaping more consistentAndrew White2014-04-201-3/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | Add a failing test for a URL helper that was broken by a6b9ea2.James Coglan2014-04-101-0/+18
| |
* | Use nested_scope? not shallow? to determine whether to copy optionsAndrew White2014-03-161-0/+36
| | | | | | | | | | | | | | | | 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.
* | Copy shallow options from normal options when using scopeAndrew White2014-03-081-0/+48
| | | | | | | | | | | | 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.
* | Pull namespace defaults out of the options hashAndrew White2014-03-081-0/+130
| | | | | | | | | | | | | | 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.
* | Only use shallow nested scope when depth is > 1Andrew White2014-03-081-0/+60
| | | | | | | | | | | | | | | | 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.
* | Set the :shallow_path as each scope is generatedAndrew White2014-02-091-0/+75
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If we set :shallow_path when shallow is called it can result in incorrect paths if the resource is inside a namespace because namespace itself sets the :shallow_path option to the namespace path. We fix this by removing the :shallow_path option from shallow as that should only be turning shallow routes on and not otherwise affecting the scope. To do this we need to treat the :shallow option to resources differently to other scope options and move it to before the nested block is called. This change also has the positive side effect of making the behavior of the :shallow option consistent with the shallow method. Fixes #12498.
* | Add additional tests for #13824Andrew White2014-01-251-0/+26
| |
* | Tidy up tests and CHANGELOG for #12598Andrew White2014-01-201-0/+10
| |
* | Automatically convert dashes to underscores in shorthand routesMikko Johansson2014-01-201-0/+10
| |
* | Add failing test for #13369Piotr Sarnacki2014-01-161-0/+18
| | | | | | | | | | | | After introducing 50311f1 a regression was introduced: routes with trailing slash are no longer recognized properly. This commit provides a failing test for this situation.
* | Allow an absolute controller path inside a module scopeAndrew White2014-01-051-0/+12
| | | | | | | | Fixes #12777
* | Unique the segment keys array for non-optimized url helpersAndrew White2014-01-051-0/+18
| | | | | | | | | | | | | | | | | | | | In Rails 3.2 you only needed pass an argument for dynamic segment once so unique the segment keys array to match the number of args. Since the number of args is less than required parts the non-optimized code path is selected. This means to benefit from optimized url generation the arg needs to be specified as many times as it appears in the path. Fixes #12808
* | Show full route constraints in error messageAndrew White2014-01-051-0/+25
| | | | | | | | | | | | | | | | When an optimized helper fails to generate, show the full route constraints in the error message. Previously it would only show the contraints that were required as part of the path. Fixes #13592
* | Use a custom route vistor for optimized route generationAndrew White2014-01-051-0/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Using a Regexp to replace dynamic segments in a path string is fraught with difficulty and can lead to odd edge cases like #13349. Since we already have a parsed representation of the path it makes sense to use that to generate an array of segments that can be used to build an optimized route's path quickly. Tests on a simple route (e.g. /posts/:id) show a speedup of 35%: https://gist.github.com/pixeltrix/8261932 Calculating ------------------------------------- Current Helper: 5274 i/100ms New Helper: 8050 i/100ms ------------------------------------------------- Current Helper: 79263.6 (±3.7%) i/s - 395550 in 4.997252s New Helper: 153464.5 (±4.9%) i/s - 772800 in 5.047834s Tests on a more complex route show even an greater performance boost: https://gist.github.com/pixeltrix/8261957 Calculating ------------------------------------- Current Helper: 2367 i/100ms New Helper: 5382 i/100ms ------------------------------------------------- Current Helper: 29506.0 (±3.2%) i/s - 149121 in 5.059294s New Helper: 78815.5 (±4.1%) i/s - 398268 in 5.062161s It also has the added benefit of fixing the edge cases described above. Fixes #13349
* | Try to escape each part of a path redirect route correctlyAndrew White2013-12-021-0/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | A path redirect may contain any and all parts of a url which have different escaping rules for each part. This commit tries to escape each part correctly by splitting the string into three chunks - path (which may also include a host), query and fragment; then it applies the correct escape pattern to each part. Whilst using `URI.parse` would be better, unfortunately the possible presence of %{name} parameters in the path redirect string prevents us from using it so we have to use a regular expression instead. Fixes #13110.
* | add test_scoped_root_as_nameSam Ruby2013-09-241-0/+13
| | | | | | | | test for regression introduced by https://github.com/rails/rails/pull/9155
* | Skip Rack applications and redirects when generating urlsAndrew White2013-07-161-0/+53
|/ | | | | | | | | | 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
* test-case => failingYves Senn2013-06-251-0/+13
|
* Add has_named_route? to the mapper APIJosé Valim2013-05-201-0/+13
|
* Add test for `format: false` with resources - closes #10323Andrew White2013-04-241-0/+29
|
* Add url generation tests for #10185Andrew White2013-04-181-0/+2
|
* Passing subdomain: '' to url_for removes the subdomain (instead of adding a ↵Derek Watson2013-04-181-0/+20
| | | | | | leading .) Adding a boolean route constraint checks for presence/absence of request property
* Merge pull request #9932 from senny/9913_routing_problemAndrew White2013-04-031-0/+29
|\ | | | | routing bugfixes when matching multiple paths
| * routing shorthand syntax works with multiple pathsYves Senn2013-03-261-0/+14
| | | | | | | | | | | | Closes #9913. We need to expand the match shorthand syntax for every path.
| * bugfix, when matching multiple paths with `get`, `post`, ...Yves Senn2013-03-261-0/+15
| | | | | | | | | | | | This problem was introduced with: https://github.com/rails/rails/commit/d03aa104e069be4e301efa8cefb90a2a785a7bff
* | fix regression in Mapper when `format:` was used in a `scope`.Yves Senn2013-04-031-0/+22
|/ | | | | | | Closes #10071 `#normalize_path!` depends on the options so we need to call `#normalize_options!` first to make sure everything is set correctly.
* Raise an ArgumentError when a clashing named route is definedTrevor Turk2013-03-191-19/+18
|