aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/dispatch/routing_test.rb
Commit message (Collapse)AuthorAgeFilesLines
* Use match? where we don't need MatchDataAkira Matsuda2019-07-291-5/+5
|
* Enable `Layout/EmptyLinesAroundAccessModifier` copRyuta Kamizono2019-06-131-3/+0
| | | | | | | | | | | We sometimes say "✂️ newline after `private`" in a code review (e.g. https://github.com/rails/rails/pull/18546#discussion_r23188776, https://github.com/rails/rails/pull/34832#discussion_r244847195). Now `Layout/EmptyLinesAroundAccessModifier` cop have new enforced style `EnforcedStyle: only_before` (https://github.com/rubocop-hq/rubocop/pull/7059). That cop and enforced style will reduce the our code review cost.
* Keep part when scope option has valueAlberto Almagro2019-05-221-0/+41
| | | | | | | | | When a route was defined within an optional scope, if that route didn't take parameters the scope was lost when using path helpers. This patch ensures scope is kept both when the route takes parameters or when it doesn't. Fixes #33219
* Deduplicate strings held by the routerJean Boussier2019-04-031-2/+2
|
* Auto-correct rubocop offencesRyuta Kamizono2019-04-031-15/+15
|
* Merge pull request #24405 from waits/shallow-falseRafael França2019-04-021-0/+31
|\ | | | | Honor shallow: false on nested resources
| * Honor shallow: false on nested resourcesDylan Waits2016-04-031-0/+31
| | | | | | | | | | | | | | | | Previously there was no way to place a non-shallow resource inside a parent with `shallow: true` set. Now you can set `shallow: false` on a nested child resource to generate normal (non-shallow) routes for it. Fixes #23890.
* | url -> URL where apt inside actionpack/Sharang Dashputre2019-04-011-6/+6
| |
* | Fix typo in the value of ENCRYPTED_SIGNED_COOKIE_SALT constant (#35619)Emil Shakirov2019-04-011-1/+1
| | | | | | | | | | | | | | | | * Fix typo in the value of ENCRYPTED_SIGNED_COOKIE_SALT constant * Fix value of cookie in with authenticated encryption flag off in tests [Emil Shakirov + Ryuta Kamizono]
* | Raise if resource custom params contain colonsJosua Schmid2019-03-261-0/+10
| | | | | | | | | | | | | | | | | | | | | | After this change it's not possible anymore to configure routes like this: routes.draw do resources :users, param: "name/:sneaky" end Fixes #30467.
* | Remove secret_token rack env and cookie upgrade codeRafael Mendonça França2019-01-171-2/+8
| | | | | | | | Now that secret_token was removed all this code is now dead.
* | Raise an error on root route naming conflicts.Gannon McGibbon2018-11-201-3/+13
| | | | | | | | | | Raises an ArgumentError when multiple root routes are defined in the same context instead of assigning nil names to subsequent roots.
* | Merge pull request #34002 from gmcgibbon/fix_deeply_nested_scoped_rootRafael França2018-09-271-0/+16
|\ \ | | | | | | Fix optionally scoped root route unscoped access
| * | Fix optionally scoped root route unscoped accessGannon McGibbon2018-09-271-0/+16
| | |
* | | Fixing an edge case when using objects as constraintsSimon Courtois2018-09-271-0/+15
|/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This PR fixes an issue when the following situation occurs. If you define a class like this class MyConstraint def call(*args) # for some reason this is defined end def matches?(*args) # checking the args end end and try to use it as a constraint get "/", to: "home#show", constraints: MyConstraint.new if its `matches?` method returns `false` there will be an error for the mapper will ask for the constraint arity, thinking it is a proc, lambda or method. This PR checks for the presence of the `arity` method on the constraint calling it only if present, preventing the error while keeping the basic behavior.
* | Fix `CustomCops/AssertNot` to allow it to have failure messageRyuta Kamizono2018-05-131-1/+1
| | | | | | | | Follow up of #32605.
* | Replace `assert !` with `assert_not`Daniel Colson2018-04-191-1/+1
| | | | | | | | | | This autocorrects the violations after adding a custom cop in 3305c78dcd.
* | Fix array routing constraintsfatkodima2018-02-171-2/+5
| |
* | Use assert_predicate and assert_not_predicateDaniel Colson2018-01-251-2/+2
| |
* | Enable `Layout/LeadingCommentSpace` to not allow cosmetic changes in the futureRyuta Kamizono2017-12-141-1/+1
| | | | | | | | Follow up of #31432.
* | Fix optimized url helpers when using relative url rootAndrew White2017-11-281-0/+37
| | | | | | | | Fixes #31220.
* | Add key rotation cookies middlewareMichael Coyne2017-09-241-0/+4
| | | | | | | | | | | | Using the action_dispatch.cookies_rotations interface, key rotation is now possible with cookies. Thus the secret_key_base as well as salts, ciphers, and digests, can be rotated without expiring sessions.
* | Clarify route encoding testeileencodes2017-08-011-6/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Since this test changed in 9220935 I noticed that it really doesn't make sense anymore. I split the tests into 2 groups to explain what each one does. First these routes should throw a `bad_request` when the encoding isn't valid. We're expecting UTF8 encoding and passing binary, that should be a bad request. For the second test we are setting the `show` route to set `self.binary_params_for?` for that route which will convert the parameters and return a `:ok` instead of a `:bad_request`.
* | Path parameters should default to UTF8eileencodes2017-08-011-4/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit changes the behavior such the path_params now default to UTF8 just like regular parameters. This also changes the behavior such that if a path parameter contains invalid UTF8 it returns a 400 bad request. Previously the behavior was to encode the path params as binary but that's not the same as query params. So this commit makes path params behave the same as query params. It's important to test with a path that's encoded as binary because that's how paths are encoded from the socket. The test that was altered was changed to make the behavior for bad encoding the same as query params. We want to treat path params the same as query params. The params in the test are invalid UTF8 so they should return a bad request. Fixes #29669 *Eileen M. Uchitelle, Aaron Patterson, & Tsukuru Tanimichi*
* | Use frozen string literal in actionpack/Kir Shatrov2017-07-291-0/+2
| |
* | Revert "Merge pull request #29540 from kirs/rubocop-frozen-string"Matthew Draper2017-07-021-1/+0
| | | | | | | | | | This reverts commit 3420a14590c0e6915d8b6c242887f74adb4120f9, reversing changes made to afb66a5a598ce4ac74ad84b125a5abf046dcf5aa.
* | Enforce frozen string in RubocopKir Shatrov2017-07-011-0/+1
| |
* | Fix `TestInvalidUrls` with rack 2.0.3yuuji.yaginuma2017-05-161-6/+6
| | | | | | | | | | | | | | | | | | | | | | Currently, raise `BadRequest` if params encoding is invalid. https://github.com/rails/rails/blob/5-1-stable/actionpack/lib/action_dispatch/http/parameters.rb#L64..L74 https://github.com/rails/rails/blob/5-1-stable/actionpack/lib/action_dispatch/request/utils.rb#L26..L39 However, env values are ensure encoded in ASCII 8 BIT at rack 2.0.3. https://github.com/rack/rack/commit/68db9aa99e3e2775a58621f658b2a7a0f67db459 Therefore, even if specify an invalid urls, it will not cause an error.
* | Reuse the Parameters#to_h check in the routing helpersRafael Mendonça França2017-04-181-1/+1
| | | | | | | | | | Since this protection is now in Parameters we can use it instead of reimplementing again.
* | Use more specific check for :format in route pathAndrew White2017-04-181-0/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The current check for whether to add an optional format to the path is very lax and will match things like `:format_id` where there are nested resources, e.g: resources :formats do resources :items end Fix this by using a more restrictive regex pattern that looks for the patterns `(.:format)`, `.:format` or `/` at the end of the path. Note that we need to allow for multiple closing parenthesis since the route may be of this form: get "/books(/:action(.:format))", controller: "books" This probably isn't what's intended since it means that the default index action route doesn't support a format but we have a test for it so we need to allow it. Fixes #28517.
* | Remove unnecessary params mungingAndrew White2017-03-151-0/+61
| | | | | | | | | | | | | | | | | | | | In 9b654d4 some params munging was added to ensure that they were set whenever `recognize_path` would call either a proc or callable constraint. Since we no longer mutate the environment hash within the method it's now unnecessary and actually causes params to leak between route matches before checking constraints. Fixes #28398.
* | Commit flash changes when using a redirect route.Andrew White2017-02-251-0/+49
| | | | | | | | | | | | | | | | | | | | | | | | | | In ca324a0 the flash middleware was effectively removed by its constructor returning the app it was passed and the `commit_flash` call was moved to the `ActionController::Metal#dispatch` method. This broke any redirect routes that modified the flash because the redirect happens before `dispatch` gets called. To fix it, this commit adds a `commit_flash` call in the `serve` method of `ActionDispatch::Routing::Redirect`. Fixes #27992.
* | `self.` is not needed when calling its own instance methodAkira Matsuda2017-01-051-1/+1
| | | | | | | | Actually, private methods cannot be called with `self.`, so it's not just redundant, it's a bad habit in Ruby
* | "Use assert_nil if expecting nil. This will fail in minitest 6."Akira Matsuda2016-12-251-1/+1
| |
* | Add more rubocop rules about whitespacesRafael Mendonça França2016-10-291-6/+6
| |
* | Remove deprecated support for passing `:path` and route path as stings in ↵Rafael Mendonça França2016-10-101-4/+1
| | | | | | | | `ActionDispatch::Routing::Mapper#match`
* | Remove deprecated support passing path as `nil` in ↵Rafael Mendonça França2016-10-101-3/+1
| | | | | | | | `ActionDispatch::Routing::Mapper#match`
* | Show an "unmatched constraints" error for mismatching and present paramsChris Carter2016-10-031-6/+9
| | | | | | | | | | | | | | | | | | | | | | | | Currently a misleading "missing required keys" error is thrown when a param fails to match the constraints of a particular route. This commit ensures that these params are recognised as unmatching rather than missing. Note: this means that a different error message will be provided between optimized and non-optimized path helpers, due to the fact that the former does not check constraints when matching routes. Fixes #26470.
* | rename test method to avoid overridingyuuji.yaginuma2016-09-031-1/+1
| | | | | | | | | | | | | | | | | | This removes the following warning. ``` ./test/dispatch/routing_test.rb:3696: warning: method redefined; discarding old test_namespaced_roots ./test/dispatch/routing_test.rb:1632: warning: previous definition of test_namespaced_roots was here ```
* | fixes remaining RuboCop issues [Vipul A M, Xavier Noria]Xavier Noria2016-09-011-4/+4
| |
* | Fix nested multiple rootsRyo Hashimoto2016-08-291-0/+42
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The PR #20940 enabled the use of multiple roots with different constraints at the top level but unfortunately didn't work when those roots were inside a namespace and also broke the use of root inside a namespace after a top level root was defined because the check for the existence of the named route used the global :root name and not the namespaced name. This is fixed by using the name_for_action method to expand the :root name to the full namespaced name. We can pass nil for the second argument as we're not dealing with resource definitions so don't need to handle the cases for edit and new routes. Fixes #26148.
* | Push :defaults extraction down one levelRafael Mendonça França2016-08-171-0/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | Since e852daa6976cc6b6b28ad0c80a188c06e226df3c only the verb methods where extracting the defaults options. It was merged a fix for the `root` method in 31fbbb7faccba25b2e3b5e10b8fca1468579d629 but `match` was still broken since `:defaults` where not extracted. This was causing routes defined using `match` and having the `:defaults` keys to not be recognized. To fix this it was extracted a new private method with the actual content of `match` and the `:defaults` extracting was moved to `match`.
* | Add three new rubocop rulesRafael Mendonça França2016-08-161-26/+26
| | | | | | | | | | | | | | | | Style/SpaceBeforeBlockBraces Style/SpaceInsideBlockBraces Style/SpaceInsideHashLiteralBraces Fix all violations in the repository.
* | applies remaining conventions across the projectXavier Noria2016-08-061-1/+0
| |
* | normalizes indentation and whitespace across the projectXavier Noria2016-08-061-3/+3
| |
* | modernizes hash syntax in actionpackXavier Noria2016-08-061-408/+408
| |
* | applies new string literal convention in actionpack/testXavier Noria2016-08-061-1627/+1627
| | | | | | | | | | The current code base is not uniform. After some discussion, we have chosen to go with double quotes by default.
* | Merge pull request #25913 from chrisarcand/fix-keyed-defaults-with-rootRafael Mendonça França2016-07-271-0/+18
|\ \ | | | | | | | | | Fix keyed defaults with root
| * | Fix 'defaults' option for root routeChris Arcand2016-07-211-0/+18
|/ / | | | | | | | | | | | | | | | | The merging of the 'defaults' option was moved up the stack in e852daa This allows us to see where these options originate from the standard HttpHelpers (get, post, patch, put, delete) Unfortunately this move didn't incorporate the 'root' method, which has always allowed the same 'defaults' option before.
* | Check `request.path_parameters` encoding at the point they're setGrey Baker2016-07-141-9/+15
| | | | | | | | | | | | | | | | Check for any non-UTF8 characters in path parameters at the point they're set in `env`. Previously they were checked for when used to get a controller class, but this meant routes that went directly to a Rack app, or skipped controller instantiation for some other reason, had to defend against non-UTF8 characters themselves.