aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/controller/routing_test.rb
Commit message (Collapse)AuthorAgeFilesLines
* Make Rails Facebook-freeSasha Koss2018-12-241-2/+2
| | | If Basecamp is a Facebook-free business, then Rails should be Facebook-free framework.
* Add `Style/RedundantFreeze` to remove redudant `.freeze`Yasuo Honda2018-09-291-2/+2
| | | | | | | | | | | | | | | | | | | | | Since Rails 6.0 will support Ruby 2.4.1 or higher `# frozen_string_literal: true` magic comment is enough to make string object frozen. This magic comment is enabled by `Style/FrozenStringLiteralComment` cop. * Exclude these files not to auto correct false positive `Regexp#freeze` - 'actionpack/lib/action_dispatch/journey/router/utils.rb' - 'activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb' It has been fixed by https://github.com/rubocop-hq/rubocop/pull/6333 Once the newer version of RuboCop released and available at Code Climate these exclude entries should be removed. * Replace `String#freeze` with `String#-@` manually if explicit frozen string objects are required - 'actionpack/test/controller/test_case_test.rb' - 'activemodel/test/cases/type/string_test.rb' - 'activesupport/lib/active_support/core_ext/string/strip.rb' - 'activesupport/test/core_ext/string_ext_test.rb' - 'railties/test/generators/actions_test.rb'
* Change the empty block style to have space inside of the blockRafael Mendonça França2018-09-251-1/+1
|
* Enable `Performance/UnfreezeString` copyuuji.yaginuma2018-09-231-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In Ruby 2.3 or later, `String#+@` is available and `+@` is faster than `dup`. ```ruby # frozen_string_literal: true require "bundler/inline" gemfile(true) do source "https://rubygems.org" gem "benchmark-ips" end Benchmark.ips do |x| x.report('+@') { +"" } x.report('dup') { "".dup } x.compare! end ``` ``` $ ruby -v benchmark.rb ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-linux] Warming up -------------------------------------- +@ 282.289k i/100ms dup 187.638k i/100ms Calculating ------------------------------------- +@ 6.775M (± 3.6%) i/s - 33.875M in 5.006253s dup 3.320M (± 2.2%) i/s - 16.700M in 5.032125s Comparison: +@: 6775299.3 i/s dup: 3320400.7 i/s - 2.04x slower ```
* Enable `Layout/EmptyLinesAroundBlockBody` to reduce review cost in the futureRyuta Kamizono2018-07-121-3/+0
| | | | | | | We sometimes ask "✂️ extra blank lines" to a contributor in reviews like https://github.com/rails/rails/pull/33337#discussion_r201509738. It is preferable to deal automatically without depending on manpower.
* Fix `CustomCops/AssertNot` to allow it to have failure messageRyuta Kamizono2018-05-131-2/+2
| | | | Follow up of #32605.
* Ruby 2.4: take advantage of String#unpack1Jeremy Daer2018-03-011-1/+1
| | | | | https://bugs.ruby-lang.org/issues/12752 https://ruby-doc.org/core-2.4.0/String.html#method-i-unpack1
* We should call methods with `.method_name` not `::method_name`.utilum2018-02-221-1/+1
| | | | | | Found several instances. Follow up on 63d530c5e68a8cf53603744789f53ccbc7ac1a0e
* Enable `Layout/SpaceBeforeComma` rubocop rule, and fixed moreRyuta Kamizono2017-12-121-2/+2
| | | | Follow up of #31390.
* Correct routing test spelling mistake.Philip Tolton2017-12-061-1/+1
|
* Path parameters should default to UTF8eileencodes2017-08-011-0/+16
| | | | | | | | | | | | | | | | | | | | 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*
* [Action Pack] `rubocop -a --only Layout/EmptyLineAfterMagicComment`Koichi ITO2017-07-111-0/+1
|
* Prepare AP and AR to be frozen string friendlyKir Shatrov2017-07-061-1/+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
|
* Add more rubocop rules about whitespacesRafael Mendonça França2016-10-291-6/+6
|
* fixes remaining RuboCop issues [Vipul A M, Xavier Noria]Xavier Noria2016-09-011-2/+2
|
* Add three new rubocop rulesRafael Mendonça França2016-08-161-140/+140
| | | | | | | | Style/SpaceBeforeBlockBraces Style/SpaceInsideBlockBraces Style/SpaceInsideHashLiteralBraces Fix all violations in the repository.
* Fix broken alignments caused by auto-correct commit 411ccbdRyuta Kamizono2016-08-101-3/+6
| | | | Hash syntax auto-correcting breaks alignments. 411ccbdab2608c62aabdb320d52cb02d446bb39c
* applies remaining conventions across the projectXavier Noria2016-08-061-1/+1
|
* normalizes indentation and whitespace across the projectXavier Noria2016-08-061-1/+1
|
* remove redundant curlies from hash argumentsXavier Noria2016-08-061-96/+90
|
* modernizes hash syntax in actionpackXavier Noria2016-08-061-406/+406
|
* applies new string literal convention in actionpack/testXavier Noria2016-08-061-499/+499
| | | | | The current code base is not uniform. After some discussion, we have chosen to go with double quotes by default.
* Support for unified Integer class in Ruby 2.4+Jeremy Daer2016-05-181-1/+1
| | | | | | | | Ruby 2.4 unifies Fixnum and Bignum into Integer: https://bugs.ruby-lang.org/issues/12005 * Forward compat with new unified Integer class in Ruby 2.4+. * Backward compat with separate Fixnum/Bignum in Ruby 2.2 & 2.3. * Drops needless Fixnum distinction in docs, preferring Integer.
* Merge pull request #23103 from rails/refactor-handling-of-action-defaultJeremy Daer2016-04-241-2/+2
|\ | | | | | | Refactor handling of :action default in routing
| * Refactor handling of :action default in routingAndrew White2016-02-161-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-71/+171
|/ | | | | | | | 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.
* Revert "Remove literal? check to fix issue with prefixed optionals"eileencodes2016-01-201-12/+0
| | | | | | | | | This reverts commit 5d1b7c3b441654e8008dcd303f5367883ec660a6. The change here didn't actually fix the issue it was trying to fix, and this isn't the correct way to fix either issue. The problem is switching from the builder to grouping with find_all/regex is now very dependent on how you structure your path pattern.
* Remove literal? check to fix issue with prefixed optionalseileencodes2016-01-161-0/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In commit d993cb3 `build_path` was changed from using `grep` to `find_all` to save array allocations. This change was a little too aggressive in that when the dash comes before the symbol like `/omg-:song` the symbol is skipped. Removing the check for `n.right.left.literal?` fixes this issue, but does add back some allocations. The number of allocations are still well less than before. I've added a regression test to test this behavior for the future. Fixes #23069. Array allocations as of d993cb3: ``` {:T_SYMBOL=>11} {:T_REGEXP=>17} {:T_STRUCT=>6500} {:T_MATCH=>12004} {:T_OBJECT=>91009} {:T_DATA=>100088} {:T_HASH=>114013} {:T_STRING=>159637} {:T_ARRAY=>321056} {:T_IMEMO=>351133} ``` Array allocations after this change: ``` {:T_SYMBOL=>11} {:T_REGEXP=>1017} {:T_STRUCT=>6500} {:T_MATCH=>12004} {:T_DATA=>84092} {:T_OBJECT=>87009} {:T_HASH=>110015} {:T_STRING=>166152} {:T_ARRAY=>322056} {:T_NODE=>343558} ```
* Remove arity check for `RouteSet#draw`yui-knk2015-11-211-6/+0
| | | | | This code was added for migration from Rails 3.1 to upper, now we are developing Rails 5.
* Merge pull request #21094 from aditya-kapoor/add-missing-ap-testsRafael Mendonça França2015-08-251-0/+10
|\ | | | | add missing test for action regexp for routing
| * add missing tests for action regexpAditya Kapoor2015-08-021-0/+10
| |
* | use `make_set` helper method to generate route setsAaron Patterson2015-08-241-31/+1
| | | | | | | | We should keep the route set generation logic in one place
* | Merge pull request #21106 from amitsuroliya/fix_routing_testAndrew White2015-08-211-6/+0
|\ \ | | | | | | Remove duplicity in tests
| * | Remove duplicity in testsamitkumarsuroliya2015-08-031-6/+0
| |/
* / Add missing assertion for test_route_with_colon_firstAditya Kapoor2015-08-031-2/+4
|/
* Why do we add a top-level constant here?Akira Matsuda2015-04-251-5/+3
|
* Removed magic comments # encoding: utf-8 , since its default from ruby 2.0 ↵Vipul A M2015-02-031-1/+0
| | | | onwards.
* Pass symbol as an argument instead of a blockErik Michaels-Ober2014-11-291-4/+4
|
* Fix cases where the wrong name is passed to `Formatter#generate`Godfrey Chan2014-11-231-1/+1
| | | | | These are currently working "by accident" because `match_route` does not check that the name is valid.
* Anchor should not be appended when set to nil/false.Guo Xiang Tan2014-11-231-0/+3
| | | | Fixes https://github.com/rails/rails/issues/17714.
* stop calling url_for with recall parameters and actually use a requestAaron Patterson2014-07-151-82/+123
|
* execute a request and check the path_parametersAaron Patterson2014-07-151-17/+59
| | | | | | | | This actually runs a request through the system, using the actual routing methods as we would use in production, then tests the path_parameters set on the request object. The `recognize_path` method isn't actually used in production, so testing what it returns isn't useful.
* set `set` in the setup methodAaron Patterson2014-07-151-2/+5
|
* remove useless ivar setAaron Patterson2014-07-151-1/+0
|
* remove warningsKuldeep Aggarwal2014-06-121-1/+0
| | | | warning: assigned but unused variable - scope_called, path and strexp
* add tests for nested lambda constraintsAaron Patterson2014-06-031-0/+27
|
* PARAMETERS_KEY is only used in the request, so move the constant thereAaron Patterson2014-05-271-5/+5
|
* just call the method and assert the return valueAaron Patterson2014-05-091-8/+1
| | | | do not test internals