aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/dispatch/routing
Commit message (Collapse)AuthorAgeFilesLines
* Use frozen string literal in actionpack/Kir Shatrov2017-07-295-0/+10
|
* Revert "Merge pull request #29540 from kirs/rubocop-frozen-string"Matthew Draper2017-07-025-5/+0
| | | | | This reverts commit 3420a14590c0e6915d8b6c242887f74adb4120f9, reversing changes made to afb66a5a598ce4ac74ad84b125a5abf046dcf5aa.
* Merge pull request #29540 from kirs/rubocop-frozen-stringMatthew Draper2017-07-025-0/+5
|\ | | | | | | Enforce frozen string in Rubocop
| * Enforce frozen string in RubocopKir Shatrov2017-07-015-0/+5
| |
* | Properly register "custom" URL helpers as named helpers.Wilson Bilkovich2017-06-301-0/+6
|/ | | | | | | | | | | | | CustomUrlHelpers were introduced in ce7d5fb2e6, closing issue #22512. They currently register themselves in an ivar that is never accessed. This change removes the @custom_helpers special-case, and registers them the way named routes are normally handled. Without this, you can get route_defined?(:example_url) == false, while still being able to call url_helpers.example_url and example_path. Various popular gems such as 'rspec-rails' make use of route_defined?() when determining how to proxy method calls or whether to define a route.
* Fix missing formats in route-set URLsJonathan del Strother2017-06-231-0/+9
| | | | | | | | | | | Before this change, handle_positional_args would end up mutating @segment_keys if inner_options included path components. Subsequent calls would then be missing the implicit path components. eg: user_path(1, :json) # => "/users/1.json" (correct) user_path(1, format: :json) # => "/users/1.json" (correct, but @segment_keys was mutated) user_path(1, :json) # => "/users/1" (oh no!)
* Reuse the Parameters#to_h check in the routing helpersRafael Mendonça França2017-04-181-4/+4
| | | | | Since this protection is now in Parameters we can use it instead of reimplementing again.
* Add support for calling nested direct routes (#28462)Andrew White2017-03-171-8/+28
| | | | | | | | | | | | | | | | | | | | Not all requirements can be expressed in terms of polymorphic url options so add a `route_for` method that allows calling another direct route (or regular named route) which a set of arguments, e.g: resources :buckets direct :recordable do |recording| route_for(:bucket, recording.bucket) end direct :threadable do |threadable| route_for(:recordable, threadable.parent) end This maintains the context of the original caller, e.g. threadable_path(threadable) # => /buckets/1 threadable_url(threadable) # => http://example.com/buckets/1
* Clarify use of params in `direct`Andrew White2017-02-221-0/+14
| | | | | | | | | Since a `direct` url helper block is evaluated using `instance_exec` then methods that are available in the instance context can be accessed, e.g. the params object in a controller action or view. This wasn't clear from the example so expand on that point and add a test case for this situation.
* Split direct method into twoAndrew White2017-02-211-35/+75
| | | | | Use a separate method called `resolve` for the custom polymorphic mapping to clarify the API.
* Removed `model_name` method to prevent warningAndrew White2017-02-211-0/+1
|
* Support mapping of non-model classesAndrew White2017-02-211-0/+23
|
* Raise an error if `direct` is inside a scope blockAndrew White2017-02-211-0/+12
|
* Add custom polymorphic mappingAndrew White2017-02-211-1/+71
| | | | | | | | | | | | | | | | Allow the use of `direct` to specify custom mappings for polymorphic_url, e.g: resource :basket direct(class: "Basket") { [:basket] } This will then generate the following: >> link_to "Basket", @basket => <a href="/basket">Basket</a> More importantly it will generate the correct url when used with `form_for`. Fixes #1769.
* Add test for calling a url helper in Mapper#directAndrew White2017-02-211-0/+7
|
* Only accept symbols and strings for Mapper#directAndrew White2017-02-211-0/+17
|
* Rename url_helper to directAndrew White2017-02-211-12/+12
|
* Add support for defining custom url helpers in routes.rbAndrew White2017-02-211-0/+121
| | | | | | | | | | | Allow the definition of custom url helpers that will be available automatically wherever standard url helpers are available. The current solution is to create helper methods in ApplicationHelper or some other helper module and this isn't a great solution since the url helper module can be called directly or included in another class which doesn't include the normal helper modules. Reference #22512.
* stop using removed `render :text`yuuji.yaginuma2016-12-031-1/+1
| | | | Follow up to 79a5ea9eadb4d43b62afacedc0706cbe88c54496
* Add three new rubocop rulesRafael Mendonça França2016-08-161-2/+2
| | | | | | | | Style/SpaceBeforeBlockBraces Style/SpaceInsideBlockBraces Style/SpaceInsideHashLiteralBraces Fix all violations in the repository.
* Add `Style/EmptyLines` in `.rubocop.yml` and remove extra empty linesRyuta Kamizono2016-08-071-1/+0
|
* applies remaining conventions across the projectXavier Noria2016-08-062-3/+1
|
* modernizes hash syntax in actionpackXavier Noria2016-08-062-13/+13
|
* applies new string literal convention in actionpack/testXavier Noria2016-08-064-84/+84
| | | | | The current code base is not uniform. After some discussion, we have chosen to go with double quotes by default.
* More Action Pack `abstract_unit` cleanup (#25211)Jon Moss2016-05-311-0/+2
| | | | | - Remove dead classes / dead code - Move class definitions to where they are used, don't define in a shared space
* Merge pull request #23103 from rails/refactor-handling-of-action-defaultJeremy Daer2016-04-241-1/+1
|\ | | | | | | Refactor handling of :action default in routing
| * Refactor handling of :action default in routingAndrew White2016-02-161-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | [ci skip] Use rails routes instead of rake routes in inspector test descriptionAbhishek Jain2016-03-021-9/+9
| |
* | Deprecate :controller and :action path parametersAndrew White2016-03-011-4/+12
| | | | | | | | | | | | | | | | 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.
* | Add `internal` attribute to routesJon Moss2016-02-221-0/+23
|/ | | | | | | | | | | | | | This is meant to provide a way for Action Cable, Sprockets, and possibly other Rack applications to mark themselves as internal, and to exclude themselves from the routing inspector, and thus `rails routes` / `rake routes`. I think this is the only way to have mounted Rack apps be marked as internal, within AD/Journey. Another option would be to create an array of regexes for internal apps, and then to iterate over that everytime a request comes through. Also, I only had the first `add_route` method set `internal`'s default to false, to avoid littering it all over the codebase.
* Add options for rake routes taskVipul A M2016-02-021-7/+27
| | | | | | | | | | Add two options: `-c` and `-g`. `-g` option returns the urls name, verb and path fields that match the pattern. `-c` option returns the urls for specific controller. Fixes #18902, and Fixes #20420 [Anton Davydov & Vipul A M]
* Better error message when running `rake routes` with CONTROLLER arg:Edouard CHIN2016-01-071-0/+38
| | | | | | | - `CONTROLLER` argument can now be supplied in different ways (Rails::WelcomeController, Rails::Welcome, rails/welcome) - If `CONTROLLER` argument was supplied but it does not exist, will warn the user that this controller does not exist - If `CONTROLLER` argument was supplied and no routes could be found matching this filter, will warn the user that no routes were found matching the supplied filter - If no routes were defined in the config/routes.rb file, will warn the user with the original message
* Remove skipped JRuby tests that are passing on 9.0.3.0.Guo Xiang Tan2015-10-271-2/+0
|
* Change `Journey::Route#verb` to return string instead of regexp.yui-knk2015-10-031-0/+11
| | | | | | | | | By [this commit](https://github.com/rails/rails/commit/0b476de445faf330c58255e2ec3eea0f3a7c1bfc) `Journey::Route#verb` need not to return verb as regexp. The returned value is used by inspector, so change it to be a string. Add inspect_with_multiple_verbs test case to keep the behavior of inspector correctly.
* Merge pull request #19788 from cmdrclueless/actionpack_http_url_ipv6Rafael Mendonça França2015-09-011-0/+45
|\ | | | | Fix broken IPv6 addresses handling
| * Fix broken IPv6 addresses handlingBrian Weaver2015-04-161-0/+45
| |
* | Get rid of mocha tests - part 2Marcin Olichwirowicz2015-08-251-9/+0
| |
* | Skip a few failing tests on JRuby with the attached ticketsRobin Dupret2015-07-171-0/+2
| |
* | Prefer assert_not over refuteRafael Mendonça França2015-05-181-1/+1
| |
* | ActionDispatch::Journey::Routes#empty? test casesValentine Valyaeff2015-05-191-0/+14
| |
* | Fix rake routes for api appsJorge Bejar2015-04-251-0/+16
|/ | | | Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
* Change filter on /rails/info/routes to use an actual path regexp from railsbrainopia2015-02-231-8/+0
| | | | | | | | Change filter on /rails/info/routes to use an actual path regexp from rails and not approximate javascript version. Oniguruma supports much more extensive list of features than javascript regexp engine. Fixes #18402.
* Remove deprecated usage of string keys in URL helpersRafael Mendonça França2015-01-041-20/+0
|
* Remove deprecated `only_path` option on `*_path` helpersRafael Mendonça França2015-01-041-44/+0
|
* allow URL helpers to work with optional scopesAlex Robbin2014-12-131-0/+12
|
* Mounted Rack apps should have default named routes based on app nameT.J. Schuck2014-12-061-11/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This fixes a regression in 4.2.0 from 4.1.8. https://github.com/rails/rails/pull/17823 fixed a similar regression regarding _explicitly_ named routes for a mounted Rack app, but there was another regression for the default value. With a route like: Rails.application.routes.draw do mount Mountable::Web, at: 'some_route' end The "Prefix" column of rake routes gives the following: - 4.1.8: mountable_web - 4.2.0.beta1-4: [nothing] - 4.2.0.rc1: [nothing] - 4.2.0.rc2: some_route <- regression This fixes the default to go back to being based off the name of the class like the docs specify: https://github.com/rails/rails/blob/785d04e3109f69d0b9b9f4732179592f0ef04e52/actionpack/lib/action_dispatch/routing/mapper.rb#L558-L560 Explicitly named routes still work correctly per https://github.com/rails/rails/pull/17823: Rails.application.routes.draw do mount Mountable::Web, at: 'some_route', as: 'named' end - 4.1.8: named - 4.2.0.beta1-4: [nothing] - 4.2.0.rc1: [nothing] - 4.2.0.rc2: named
* Pure rack apps can be mounted with a nameJean Boussier2014-11-291-1/+1
| | | | See https://github.com/rails/rails/commit/9b15828b5c347395b42066a588c88e5eb4e72279#commitcomment-8764492
* Deprecate string options in URL helpersMelanie Gilman2014-11-241-0/+20
| | | | | | Fixes https://github.com/rails/rails/issues/16958 [Byron Bischoff & Melanie Gilman]
* Deprecate the `only_path` option on `*_path` helpers.Godfrey Chan2014-10-281-0/+80
| | | | | | | | | | | | In cases where this option is set to `true`, the option is redundant and can be safely removed; otherwise, the corresponding `*_url` helper should be used instead. Fixes #17294. See also #17363. [Dan Olson, Godfrey Chan]
* Revert "Merge pull request #16966 from why-el/symbolize-path-params"Rafael Mendonça França2014-09-251-8/+0
| | | | | | | | This reverts commit 9d05d6de52871e57bfbf54a60de005e8a5f5b0e4, reversing changes made to 0863c9248fd47a15e88e05ce4fcd80966684c0e3. The change in the behaviour reported at #16958 doesn't exist since 4.0 and 4.1 works in the same way