aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/dispatch/routing_test.rb
Commit message (Collapse)AuthorAgeFilesLines
* Prevent `{ internal: true }` from being stored in the routerJon Moss2016-06-071-0/+30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Forgotten followup to #23669 :grimacing: If you went to an internal route (e.g. `/rails/info/routes`), you would previously see the following in your logger: ```bash Processing by Rails::InfoController#routes as HTML Parameters: {"internal"=>true} Rendering /Users/jon/code/rails/rails/railties/lib/rails/templates/rails/info/routes.html.erb within layouts/application Rendered collection of /Users/jon/code/rails/rails/actionpack/lib/action_dispatch/middleware/templates/routes/_route.html.erb [2 times] (10.5ms) Rendered /Users/jon/code/rails/rails/actionpack/lib/action_dispatch/middleware/templates/routes/_table.html.erb (2.5ms) Rendered /Users/jon/code/rails/rails/railties/lib/rails/templates/rails/info/routes.html.erb within layouts/application (23.5ms) Completed 200 OK in 50ms (Views: 35.1ms | ActiveRecord: 0.0ms) ``` Now, with this change, you would see: ```bash Processing by Rails::InfoController#routes as HTML Rendering /Users/jon/code/rails/rails/railties/lib/rails/templates/rails/info/routes.html.erb within layouts/application Rendered collection of /Users/jon/code/rails/rails/actionpack/lib/action_dispatch/middleware/templates/routes/_route.html.erb [2 times] (1.6ms) Rendered /Users/jon/code/rails/rails/actionpack/lib/action_dispatch/middleware/templates/routes/_table.html.erb (10.2ms) Rendered /Users/jon/code/rails/rails/railties/lib/rails/templates/rails/info/routes.html.erb within layouts/application (17.4ms) Completed 200 OK in 44ms (Views: 28.0ms | ActiveRecord: 0.0ms) ```
* Merge pull request #23103 from rails/refactor-handling-of-action-defaultJeremy Daer2016-04-241-11/+51
|\ | | | | | | Refactor handling of :action default in routing
| * Refactor handling of :action default in routingAndrew White2016-02-161-11/+51
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The longstanding convention in Rails is that if the :action parameter is missing or nil then it defaults to 'index'. Up until Rails 5.0.0.beta1 this was handled slightly differently than other routing defaults by deleting it from the route options and adding it to the recall parameters. With the recent focus of removing unnecessary duplications this has exposed a problem in this strategy - we are now mutating the request's path parameters and causing problems for later url generation. This will typically affect url_for rather a named url helper since the latter explicitly pass :controller, :action, etc. The fix is to add a default for :action in the route class if the path contains an :action segment and no default is passed. This change also revealed an issue with the parameterized part expiry in that it doesn't follow a right to left order - as soon as a dynamic segment is required then all other segments become required. Fixes #23019.
* | Deprecate :controller and :action path parametersAndrew White2016-03-011-21/+59
|/ | | | | | | | Allowing :controller and :action values to be specified via the path in config/routes.rb has been an underlying cause of a number of issues in Rails that have resulted in security releases. In light of this it's better that controllers and actions are explicitly whitelisted rather than trying to blacklist or sanitize 'bad' values.
* Fix marking of custom routes for JourneyAndrew White2016-01-201-0/+63
| | | | | | | | | | | | The Mapper build_path method marks routes where path parameters are part of a path segment as custom routes by altering the regular expression, e.g: get '/foo-:bar', to: 'foo#bar' There were some edge cases where certain constructs weren't being picked up and this commit fixes those. Fixes #23069.
* Allow AC::Parameters as an argument to url_helpersPrathamesh Sonpatki2016-01-071-0/+21
| | | | | | | | - Earlier only Hash was allowed as params argument to url_helpers. - Now ActionController::Parameters instances will also be allowed. - If the params are not secured then it will raise an ArgumentError to indicate that constructing URLs with non-secure params is not recommended. - Fixes #22832.
* Don't catch all NameError to reraise as ActionController::RoutingError #22368Maxime Garcia2015-12-121-0/+41
|
* Get rid of mocha tests - part 1Marcin Olichwirowicz2015-08-241-6/+5
|
* deprecate passing a string for both the beginning path and :path optionAaron Patterson2015-08-141-1/+4
|
* use predicate methods instead of hard coding verb stringsAaron Patterson2015-08-141-1/+2
| | | | | also change the feeler to subclass AD::Request so that it has all the methods that Request has
* Allow a custom dispatcher to be provided to routing.Xavier Shay2015-08-071-9/+6
|
* Stop using deprecated `render :text` in testPrem Sichanugrist2015-07-171-6/+6
| | | | | | | | | This will silence deprecation warnings. Most of the test can be changed from `render :text` to render `:plain` or `render :body` right away. However, there are some tests that needed to be fixed by hand as they actually assert the default Content-Type returned from `render :body`.
* Merge pull request #19431 from hmarr/head-routingRafael Mendonça França2015-06-221-3/+2
|\ | | | | Respect routing precedence for HEAD requests
| * Respect routing precedence for HEAD requestsHarry Marr2015-03-201-3/+2
| | | | | | | | | | | | | | Fixes the issue described in #18764 - prevents Rack middleware from swallowing up HEAD requests that should have been matched by a higher-precedence `get` route, but still allows Rack middleware to respond to HEAD requests.
* | Routes resources avoid :new and :edit endpoints if api_only is enabledJorge Bejar2015-06-111-0/+75
| |
* | sort_by instead of sortYang Bo2015-04-081-0/+13
|/ | | | | | it is avoid sort errot within different and mixed keys. used `sort_by` + `block` to list parameter by keys. keep minimum changes
* Drop request class from RouteSet constructor.Aaron Patterson2015-03-041-1/+5
| | | | | If you would like to use a custom request class, please subclass and implemet the `request_class` method.
* Revert "Merge pull request #18764 from tsun1215/master"Jeremy Kemper2015-02-261-4/+5
| | | | | This reverts commit b6dd0c4ddebf5e7aab0a669915cb349ec65e5b88, reversing changes made to de9a3748c436f849dd1877851115cd94663c2725.
* Add a failing test demonstrating regression with HEAD requests to Rack apps, ↵Jeremy Kemper2015-02-241-3/+9
| | | | re #18764
* Merge pull request #18218 from brainopia/fix_match_shorthand_in_routesRafael Mendonça França2015-02-201-0/+9
|\ | | | | Don't use shorthand match on routes with inappropriate symbols
| * Improve shorthand matching for routesbrainopia2015-01-251-0/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Shorthand route match is when controller and action are taken literally from path. E.g. get '/foo/bar' # => will use 'foo#bar' as endpoint get '/foo/bar/baz' # => will use 'foo/bar#baz' as endpoint Not any path with level two or more of nesting can be used as shortcut. If path contains any characters outside of /[\w-]/ then it can't be used as such. This commit ensures that invalid shortcuts aren't used. ':controller/:action/postfix' - is an example of invalid shortcut that was previosly matched and led to exception: "ArgumentError - ':controller/:action' is not a supported controller name"
* | Explicitly ignored wildcard verbs from head_routesTerence Sun2015-02-081-0/+12
| | | | | | | | | | | | In match_head_routes, deleted the routes in which request.request_method was empty (matches all HTTP verbs) when responding to a HEAD request. This prevents catch-all routes (such as Racks) from intercepting the HEAD request. Fixes #18698
* | Consistent usage of spaces in hashes across our codebaseRafael Mendonça França2015-01-291-11/+11
| |
* | Switch to kwargs in ActionController::TestCase and ActionDispatch::IntegrationKir Shatrov2015-01-291-11/+11
|/ | | | | | | | Non-kwargs requests are deprecated now. Guides are updated as well. `post url, nil, nil, { a: 'b' }` doesn't make sense. `post url, params: { y: x }, session: { a: 'b' }` would be an explicit way to do the same
* Fix name_for_action in routingrono232015-01-191-0/+38
|
* Remove deprecated support to define routes with `:to` option thatRafael Mendonça França2015-01-041-30/+4
| | | | doesn't contain `#`
* Fix handling of positional url helper arguments when format is falseTatiana Soukiassian2014-12-131-0/+28
| | | | | | | There is no need to subtract one from the path_params size when there is no format parameter because it is not present in the path_params array. Fixes #17819.
* 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.