Skip to content

Commit

Permalink
Merge pull request #61 from substancelab/rails7.1
Browse files Browse the repository at this point in the history
Bring rails test matrix up to date
  • Loading branch information
koppen authored Dec 1, 2023
2 parents ae3c37a + cfaceb8 commit bb59cef
Show file tree
Hide file tree
Showing 4 changed files with 106 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ruby.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
rails-version: ['5.2.5', '6.0.3.6', '6.1.3.1', '7.0.5', 'main']
rails-version: ['5.2.8.1', '6.0.3.7', '6.1.7.6', '7.0.8', '7.1.2', 'main']
ruby-version: ['2.7', '3.0', '3.1', '3.2']
exclude:
- rails-version: '5.2.5'
Expand Down
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

* Added Ruby 3.0, 3.1, 3.2 to the test matrix.

* Added Rails 6.1.x and 7.0.x to the build matrix.
* Added Rails 6.1.x, 7.0.x, 7.1.x to the build matrix.

* Dropped support for Rails 4. Going forward we're targetting Rails 5.x (and 6.x). Rails 5 deprecates a few configuration options that we need access to. If you still need support for Rails 4.x, version 1.2.2 of route_downcaser should work just fine.

Expand Down
2 changes: 1 addition & 1 deletion README.rdoc
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ This gem hooks into the Rack middleware of Rails. This way all paths are downcas

== Requirements

This gem is tested with 5.2.x, 6.0.x, 6.1.x. It reportedly also works with Sinatra, although I do not use Sinatra myself. Sinatra test-cases will be most welcome.
This gem is tested with 5.2.x, 6.0.x, 6.1.x., 7.x. It reportedly also works with Sinatra, although I do not use Sinatra myself. Sinatra test-cases will be most welcome.

It has previously worked - and I presume still works - in Rails 5.0.x and 5.1.x.

Expand Down
103 changes: 103 additions & 0 deletions test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
# frozen_string_literal: true

gem "activesupport"
# require 'active_support/all'
require "route_downcaser"
require "route_downcaser/downcase_route_middleware"
require "route_downcaser/original_downcase_route_middleware"

require "benchmark"

class FakeApp
def call(env)
end
end

ITERATIONS = 1_000_000

app = FakeApp.new
original_downcaser = RouteDowncaser::OriginalDowncaseRouteMiddleware.new(app)
optimized_downcaser = RouteDowncaser::DowncaseRouteMiddleware.new(app)

Benchmark.bmbm do |bm|
# bm.report("Original with small env") do
# ITERATIONS.times do
# env = {
# "PATH_INFO" => "/Here/Or/There",
# "REQUEST_URI" => "/Here/Or/There",
# "REQUEST_METHOD" => "GET",
# }
# original_downcaser.call(env)
# end
# end
bm.report("Original") do
ITERATIONS.times do
env = {
"PATH_INFO" => "/Here/Or/There",
"REQUEST_URI" => "/Here/Or/There",
"REQUEST_METHOD" => "GET",
"GATEWAY_INTERFACE" => "GATEWAY_INTERFACE",
"HTTP_ACCEPT" => "HTTP_ACCEPT",
"HTTP_ACCEPT_CHARSET" => "HTTP_ACCEPT_CHARSET",
"HTTP_ACCEPT_ENCODING" => "HTTP_ACCEPT_ENCODING",
"HTTP_ACCEPT_LANGUAGE" => "HTTP_ACCEPT_LANGUAGE",
"HTTP_CACHE_CONTROL" => "HTTP_CACHE_CONTROL",
"HTTP_CONNECTION" => "HTTP_CONNECTION",
"HTTP_COOKIE" => "HTTP_COOKIE",
"HTTP_HOST" => "HTTP_HOST",
"HTTP_KEEP_ALIVE" => "HTTP_KEEP_ALIVE",
"HTTP_REFERER" => "HTTP_REFERER",
"HTTP_USER_AGENT" => "HTTP_USER_AGENT",
"QUERY_STRING" => "QUERY_STRING",
"REMOTE_ADDR" => "REMOTE_ADDR",
"REMOTE_HOST" => "REMOTE_HOST",
"REMOTE_USER" => "REMOTE_USER",
"SERVER_NAME" => "SERVER_NAME",
"SERVER_PORT" => "SERVER_PORT",
"SERVER_PROTOCOL" => "SERVER_PROTOCOL",
"SERVER_SOFTWARE" => "SERVER_SOFTWARE"
}
original_downcaser.call(env)
end
end
# bm.report("Optimized with small env") do
# ITERATIONS.times do
# env = {
# "PATH_INFO" => "/Here/Or/There",
# "REQUEST_URI" => "/Here/Or/There",
# "REQUEST_METHOD" => "GET",
# }
# optimized_downcaser.call(env)
# end
# end
bm.report("Optimized") do
ITERATIONS.times do
env = {
"PATH_INFO" => "/Here/Or/There",
"REQUEST_URI" => "/Here/Or/There",
"REQUEST_METHOD" => "GET",
"GATEWAY_INTERFACE" => "GATEWAY_INTERFACE",
"HTTP_ACCEPT" => "HTTP_ACCEPT",
"HTTP_ACCEPT_CHARSET" => "HTTP_ACCEPT_CHARSET",
"HTTP_ACCEPT_ENCODING" => "HTTP_ACCEPT_ENCODING",
"HTTP_ACCEPT_LANGUAGE" => "HTTP_ACCEPT_LANGUAGE",
"HTTP_CACHE_CONTROL" => "HTTP_CACHE_CONTROL",
"HTTP_CONNECTION" => "HTTP_CONNECTION",
"HTTP_COOKIE" => "HTTP_COOKIE",
"HTTP_HOST" => "HTTP_HOST",
"HTTP_KEEP_ALIVE" => "HTTP_KEEP_ALIVE",
"HTTP_REFERER" => "HTTP_REFERER",
"HTTP_USER_AGENT" => "HTTP_USER_AGENT",
"QUERY_STRING" => "QUERY_STRING",
"REMOTE_ADDR" => "REMOTE_ADDR",
"REMOTE_HOST" => "REMOTE_HOST",
"REMOTE_USER" => "REMOTE_USER",
"SERVER_NAME" => "SERVER_NAME",
"SERVER_PORT" => "SERVER_PORT",
"SERVER_PROTOCOL" => "SERVER_PROTOCOL",
"SERVER_SOFTWARE" => "SERVER_SOFTWARE"
}
optimized_downcaser.call(env)
end
end
end

0 comments on commit bb59cef

Please sign in to comment.