| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
| |
After @kamipo CR feedback we realized `Route#build` wasn't used. As it
is also private API being able to create Routes both with `#new` and
`#build` was redundant.
|
|\
| |
| | |
mounted routes with non-word characters
|
| | |
|
|/
|
|
|
|
|
|
|
| |
This change adds a `named_captures` method to
`ActionDispatch::Journey::Path::MatchData` in order to emulate a similar
method present on `Regex`'s `MatchData` present in Ruby core.
This method can be useful for introspection of routes without the need
to use `zip` while testing or developing in Rails core.
|
| |
|
| |
|
|
|
|
| |
2. Typo fixes.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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
```
|
|
|
|
|
|
|
| |
Journey's scanner tokenizes the `|` (:OR) operator when scanning route
urls such as `"/:foo|*bar"`. However, the current scanner test does not
have any test cases for the `|` operator. This commit adds a test case
for this particular token.
|
|
|
|
|
| |
Modifies the routes simulator to allow for empty RouteSets, which are
created when secondary Engines are loaded.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This breaks up the one megatest for Journey's scanner into multiple test
cases, which also provides better output when there is a failure in the
scanner.
Before:
```
./bin/test test/journey/route/definition/scanner_test.rb
Run options: --seed 778
F
Failure:
ActionDispatch::Journey::Definition::TestScanner#test_tokens [/Users/vaidehijoshi/Code/tilde/rails/actionpack/test/journey/route/definition/scanner_test.rb:57]:
--- expected
+++ actual
@@ -1 +1 @@
-[[:SLASH, "/"], [:LITERAL, "page!!"]]
+[[:SLASH, "/"], [:LITERAL, "page!"]]
bin/test Users/vaidehijoshi/Code/tilde/rails/actionpack/test/journey/route/definition/scanner_test.rb:14
Finished in 0.090899s, 11.0012 runs/s, 44.0049 assertions/s.
1 runs, 4 assertions, 1 failures, 0 errors, 0 skips
```
After:
```
./bin/test test/journey/route/definition/scanner_test.rb
Run options: --seed 2230
....................F
Failure:
ActionDispatch::Journey::Definition::TestScanner#test_scanning_/page$ [/Users/vaidehijoshi/Code/tilde/rails/actionpack/test/journey/route/definition/scanner_test.rb:58]:
Wrong tokens for `/page$`.
--- expected
+++ actual
@@ -1 +1 @@
-[[:SLASH, "/"], [:LITERAL, "page$$"]]
+[[:SLASH, "/"], [:LITERAL, "page$"]]
bin/test Users/vaidehijoshi/Code/tilde/rails/actionpack/test/journey/route/definition/scanner_test.rb:56
F
Failure:
ActionDispatch::Journey::Definition::TestScanner#test_scanning_/page! [/Users/vaidehijoshi/Code/tilde/rails/actionpack/test/journey/route/definition/scanner_test.rb:58]:
Wrong tokens for `/page!`.
--- expected
+++ actual
@@ -1 +1 @@
-[[:SLASH, "/"], [:LITERAL, "page!!"]]
+[[:SLASH, "/"], [:LITERAL, "page!"]]
bin/test Users/vaidehijoshi/Code/tilde/rails/actionpack/test/journey/route/definition/scanner_test.rb:56
F
Failure:
ActionDispatch::Journey::Definition::TestScanner#test_scanning_/page& [/Users/vaidehijoshi/Code/tilde/rails/actionpack/test/journey/route/definition/scanner_test.rb:58]:
Wrong tokens for `/page&`.
--- expected
+++ actual
@@ -1 +1 @@
-[[:SLASH, "/"], [:LITERAL, "page&&"]]
+[[:SLASH, "/"], [:LITERAL, "page&"]]
bin/test Users/vaidehijoshi/Code/tilde/rails/actionpack/test/journey/route/definition/scanner_test.rb:56
Finished in 0.126447s, 181.8944 runs/s, 181.8944 assertions/s.
23 runs, 23 assertions, 3 failures, 0 errors, 0 skips
```
|
| |
|
| |
|
|
|
|
| |
Follow up of #31432.
|
|
|
|
| |
And enable `context_dependent` of Style/BracesAroundHashParameters cop.
|
| |
|
| |
|
|
|
|
| |
fixes a regression introduced at 8607c25ba7810573733d9b37d0015154ba059f5e
|
| |
|
| |
|
|
|
|
|
| |
This reverts commit 3420a14590c0e6915d8b6c242887f74adb4120f9, reversing
changes made to afb66a5a598ce4ac74ad84b125a5abf046dcf5aa.
|
| |
|
|
|
|
|
|
| |
This method was only used in the Rails tests and not by other methods in
the Rails simulator. Because it's a no-doc'd class it should be safe to
remove without deprecation.
|
|
|
|
|
|
|
|
|
| |
When the path info is read from the socket it's encoded as ASCII 8BIT.
The unescape method changes the encoding to UTF8 but it should maintain
the encoding of the string that's passed in.
This causes parameters to be force encoded to UTF8 when we don't
actually know what the encoding of the parameter should be.
|
|
|
|
| |
since the test names become Regexp filters, non-escaped test names cause RegexpError on isolated test via bin/test
|
|
|
|
|
|
|
|
| |
Scoring routes based on constraints repeated many type conversions that
could be performed in the outer loop. Determinations of score and
fitness also used Array operations that required allocations. Against
my benchmark with a large routeset, this reduced object allocations by
over 30x and wall time by over 3x.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
| |
Style/SpaceBeforeBlockBraces
Style/SpaceInsideBlockBraces
Style/SpaceInsideHashLiteralBraces
Fix all violations in the repository.
|
|
|
|
| |
Hash syntax auto-correcting breaks alignments. 411ccbdab2608c62aabdb320d52cb02d446bb39c
|
| |
|
| |
|
| |
|
| |
|
|
|
|
|
| |
The current code base is not uniform. After some discussion,
we have chosen to go with double quotes by default.
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
| |
Now, we use the mapper to build the routing table
related to https://github.com/rails/rails/commit/703275ba70efbefb3358052b6ba750443eff1a28
|
| |
|
| |
|
| |
|
|
|
|
|
| |
I want to change the real constructor to take a particular parameter for
matching the request method
|
|
|
|
|
| |
The string we create is almost always the same, so rather than joining
all the time, lets join once, then reuse that string everywhere.
|
|
|
|
|
|
| |
We should build the routes using the user facing API which is `Mapper`.
This frees up the library internals to change as we see fit. IOW we
shouldn't be testing internals.
|
|
|
|
|
| |
The outer router object already keeps a hash of named routes, so we
should just use that.
|
|
|
|
|
| |
refactor the tests with a backwards compatible method call so we can rm
add_route2 from the journey router
|
|
|
|
|
| |
also change the feeler to subclass AD::Request so that it has all the
methods that Request has
|
|
|
|
|
| |
This was a useless object. We can just directly construct a
Path::Pattern object without a Strexp object.
|
|
|
|
|
| |
the caller already has it, there is no reason to pack it in to an object
and just throw that object away.
|
|
|
|
|
|
|
|
| |
This reverts commit 0b3397872582f2cf1bc6960960a6393f477c55e6, reversing
changes made to 56d52e3749180e6c1dcf7166adbad967470aa78b.
As pointed out on the PR, this will hide development mistakes too, which
is not ideal.
|