Skip to content

Commit

Permalink
Rack 3 compatibility.
Browse files Browse the repository at this point in the history
  • Loading branch information
ioquatix committed Jan 4, 2025
1 parent 1a10ce8 commit 77c56db
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions test/spec_session_cookie.rb
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ def decode(str); @calls << :decode; JSON.parse(str); end

it "passes through same_site option to session cookie" do
response = response_for(app: [incrementor, same_site: :none])
response["Set-Cookie"].must_include "SameSite=None"
response["Set-Cookie"].must_match /SameSite=None/i
end

it "allows using a lambda to specify same_site option, because some browsers require different settings" do
Expand All @@ -233,10 +233,10 @@ def decode(str); @calls << :decode; JSON.parse(str); end
# https://gist.github.com/bnorton/7dee72023787f367c48b3f5c2d71540f

response = response_for(app: [incrementor, same_site: lambda { |req, res| :none }])
response["Set-Cookie"].must_include "SameSite=None"
response["Set-Cookie"].must_match /SameSite=None/i

response = response_for(app: [incrementor, same_site: lambda { |req, res| :lax }])
response["Set-Cookie"].must_include "SameSite=Lax"
response["Set-Cookie"].must_match /SameSite=Lax/i
end

it "loads from a cookie" do
Expand Down
6 changes: 3 additions & 3 deletions test/spec_session_pool.rb
Original file line number Diff line number Diff line change
Expand Up @@ -209,19 +209,19 @@
pool.same_site.must_equal :none
req = Rack::MockRequest.new(pool)
res = req.get("/")
res["Set-Cookie"].must_include "SameSite=None"
res["Set-Cookie"].must_match /SameSite=None/i
end

it "allows using a lambda to specify same_site option, because some browsers require different settings" do
pool = Rack::Session::Pool.new(incrementor, same_site: lambda { |req, res| :none })
req = Rack::MockRequest.new(pool)
res = req.get("/")
res["Set-Cookie"].must_include "SameSite=None"
res["Set-Cookie"].must_match /SameSite=None/i

pool = Rack::Session::Pool.new(incrementor, same_site: lambda { |req, res| :lax })
req = Rack::MockRequest.new(pool)
res = req.get("/")
res["Set-Cookie"].must_include "SameSite=Lax"
res["Set-Cookie"].must_match /SameSite=Lax/i
end

# anyone know how to do this better?
Expand Down

0 comments on commit 77c56db

Please sign in to comment.