-
Notifications
You must be signed in to change notification settings - Fork 137
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix compatibility with Rack 2.x on Rails 7.0+, reinstating Rails appraisal tests #271
base: master
Are you sure you want to change the base?
Conversation
Only affects appraisals/rails tests right now it seems where the MockHttpSession is used.
281b664
to
4fa7813
Compare
appraise "rails50" do | ||
gem "rails", "~> 5.0.0" | ||
end | ||
|
||
appraise "rails40" do | ||
gem "rails", "~> 4.0.13" | ||
appraise "rails52" do | ||
gem "rails", "~> 5.2.0" | ||
end | ||
|
||
appraise "rails41" do | ||
gem "rails", "~> 4.1.16" | ||
appraise "rails60" do | ||
gem "rails", "~> 6.0.0" | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could consider dropping tests for Rails 5.0 (EOL Apr 2018), 5.2 (EOL Jun 2022) and/or 6.0 (EOL Jun 2023) as well. I kept all versions that worked with JRuby 9.3+.
One reason to be a bit more relaxed with EOLs for JRuby stuff is some of the lag for JRuby itself to catch up with required Ruby versions. Dropping 5.0 is probably pretty reasonable now though.
def current_session_id(env) | ||
env[ENV_SESSION_OPTIONS_KEY][:id] # 1.5.0: env[ENV_SESSION_KEY].id | ||
end if ::JRuby::Rack::Session::OptionsHash |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OptionsHash
is gone from Rack 1.5+ so no longer needed.
@@ -101,7 +101,7 @@ public String getId() { | |||
return this.id; | |||
} | |||
|
|||
void setId(String id) { | |||
public void setId(String id) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not visible on modern JRuby otherwise.
@@ -256,7 +256,7 @@ public String toString() { | |||
return getClass().getName() + "@" + Integer.toHexString(hashCode()) + this.attributes; | |||
} | |||
|
|||
Map<String, Object> getAttributes() { | |||
public Map<String, Object> getAttributes() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not visible on modern JRuby otherwise.
it "should raise an error if the servlet request is not present" do | ||
expect { @session_store.call({}) }.to raise_error(RuntimeError) | ||
end | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test was too problematic to get to work reliably across all versions, and seemed to be relying on a lot of other code to get to the expected result from the entry point. Seems to be trying to get into the code below when there is no existing session. I made a call that I didn't think it was sufficiently important after trying to fix it and getting lost as to why it wasn't always raising an error.
jruby-rack/src/main/ruby/jruby/rack/session_store.rb
Lines 49 to 57 in 4fa7813
def get_servlet_session(env, create = false) | |
servlet_session = env[ENV_SERVLET_SESSION_KEY] | |
invalid = false | |
begin | |
if servlet_session.nil? || | |
( create && ( invalid || servlet_session.getCreationTime.nil? ) ) | |
unless servlet_request = env['java.servlet_request'] | |
raise "JavaServletStore expects a servlet request at env['java.servlet_request']" | |
end |
277cbb4
to
3eeb902
Compare
We are only supporting Rack 2.x onwards now anyway.
3eeb902
to
f52da2e
Compare
…fore railtie Not sure if this is us, strictly speaking but we seem to need to require active_support before the railties or the issue at rails/rails#49495 (comment) occurs
638c232
to
4dcb31c
Compare
This PR makes a few important changes.
@env
is nil with Rails 7 #244 - using a Java servlet session store under Rails 7.0 was brokenenabled?
function. https://github.com/rails/rails/blob/d4acb7aed7c48c3a884cb0ee52f6de6aa3607f3c/actionpack/lib/action_dispatch/middleware/flash.rb#L71-L72@env
within@req
for sessions and changing what is passed to functions). rack/rack@c94e224NameError
handling on older JRuby/Rails versions.5.0
->7.2
for now.README
andHistory.md
to reflect 1.2.x releases (assumes this will be in1.2.3
)Commits should be logically chunked so can be reviewed independently if necessary.
This isn't as scary to review as it looks - almost all of the change chunk #s are from removing and adding appraisal
Gemfile.lock
s 😛