Skip to content

Commit

Permalink
test against latest rack v2 as well
Browse files Browse the repository at this point in the history
  • Loading branch information
Stanislav Katkov committed Sep 19, 2024
1 parent d8cc3ff commit aed365d
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 9 deletions.
17 changes: 13 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
strategy:
matrix:
ruby:
- '2.7'
- "2.7"
steps:
- name: Checkout
uses: actions/checkout@v4
Expand All @@ -40,8 +40,8 @@ jobs:
strategy:
matrix:
ruby:
- '2.7'
- '3.2'
- "2.7"
- "3.2"
services:
mysql:
image: mysql:5.7
Expand Down Expand Up @@ -70,11 +70,20 @@ jobs:
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true
- name: RSpec
- name: RSpec with rack v3
run: bundle exec rspec
env:
MYSQL_HOST: 127.0.0.1
MYSQL_PORT: 3306
PGHOST: localhost
PGUSER: postgres
PGPASSWORD: postgres
- name: RSpec with rack v2
run: bundle exec rspec
env:
IDEMPO_RACK_VERSION: "2.0"
MYSQL_HOST: 127.0.0.1
MYSQL_PORT: 3306
PGHOST: localhost
PGUSER: postgres
PGPASSWORD: postgres
4 changes: 2 additions & 2 deletions idempo.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Gem::Specification.new do |spec|
spec.require_paths = ["lib"]

# Uncomment to register a new dependency of your gem
spec.add_dependency "rack"
spec.add_dependency "rack", "~> #{ENV.fetch('IDEMPO_RACK_VERSION', '3.0')}"
spec.add_dependency "msgpack"
spec.add_dependency "measurometer", "~> 1.3"

Expand All @@ -45,7 +45,7 @@ Gem::Specification.new do |spec|
spec.add_development_dependency "redis", "~> 4"
spec.add_development_dependency "rack-test"
spec.add_development_dependency "activerecord"
spec.add_development_dependency "mysql2"
#spec.add_development_dependency "mysql2"
spec.add_development_dependency "pg"
spec.add_development_dependency "standard"

Expand Down
9 changes: 6 additions & 3 deletions lib/idempo.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
require "msgpack"
require "zlib"
require "set"
require 'rack'

require "idempo/version"

Expand Down Expand Up @@ -55,9 +56,11 @@ def call(env)
end

status, headers, body = @app.call(env)
# `body` could be of type `ActionDispatch::Response::RackBody` and idempo will not even attempt to store it,
# we're converting ActionDispatch::Response::RackBody to a storable array format.
body = body.try(:to_ary) || body
if Gem::Version.new(Rack.release) >= Gem::Version.new('3.0')
# `body` could be of type `ActionDispatch::Response::RackBody` and idempo will not even attempt to store it,
# we're converting ActionDispatch::Response::RackBody to a storable array format.
body = body.try(:to_ary) if body.respond_to?(:to_ary)
end

expires_in_seconds = (headers.delete("X-Idempo-Persist-For-Seconds") || @persist_for_seconds).to_i
if response_may_be_persisted?(status, headers, body)
Expand Down

0 comments on commit aed365d

Please sign in to comment.