Skip to content

Fix test suite with Rails 7.2+ #220

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

Merged
merged 4 commits into from
Mar 26, 2025
Merged

Fix test suite with Rails 7.2+ #220

merged 4 commits into from
Mar 26, 2025

Conversation

byroot
Copy link
Member

@byroot byroot commented Mar 25, 2025

Fix: #219

Starting from rails/rails#49819 most of the test suite is broken.

I'm trying to figure out how to fix it, but I'm really struggling to make sense of it.

@gmcgibbon would you have a bit of time to look at this? I think I managed to fix the build_app and with_routing things, but now it seems like cookies aren't set.

FYI: @stevenharman

@byroot
Copy link
Member Author

byroot commented Mar 25, 2025

NB: I'm fine with dropping 7.1 and older on CI if it's too annoying to support both the new and old API.

@stevenharman
Copy link
Contributor

I'm fine with dropping 7.1 and older on CI if it's too annoying to support both the new and old API.

This was something I was thinking about as I worked to update the test matrix in #219 - the API for ActionDispatch::Assertions::RoutingAssertions seems to have changed so much that it might be really ugly to have to support both. But I didn't want to propose dropping anything until we'd figured out who to get things working in 7.2+. 👍

byroot and others added 3 commits March 26, 2025 08:28
As of rails/rails#49819 the internals of
`ActionDispatch::Assertions::RoutingAssertions` changed and the way we
were building our app instance was no compatible with it. This gets us
back to passing tests for Rails 7.2+. I hope 🤞
@byroot byroot force-pushed the fix-integration-2 branch from 1d5a5ee to e277341 Compare March 26, 2025 07:28
@byroot
Copy link
Member Author

byroot commented Mar 26, 2025

Ok, I found the leak (or one of?) by bisecting the test suite, and fixed it in e77bcc3

@byroot byroot merged commit b606449 into master Mar 26, 2025
34 checks passed
stevenharman added a commit to docsend/activerecord-session_store that referenced this pull request Mar 26, 2025
I took another look at the changes we had to make in rails#220 and compared
that to how things work in the actiondispatch's Cookie Store tests and
realized we were close, but just missing how we were setting the options
for our store. So I've revamped the setup to be in line with what's in
Rails' own tests. This should make it easier to keep things in line and
working, going forward.

See the following two files for how Cookie Store tests (and their base
`ActionDispatch::IntegrationTest`) work today (as of Rails 8.0):
   * https://github.com/rails/rails/blob/8-0-stable/actionpack/test/dispatch/session/cookie_store_test.rb
   * https://github.com/rails/rails/blob/8-0-stable/actionpack/test/abstract_unit.rb

NOTE:
stevenharman added a commit to docsend/activerecord-session_store that referenced this pull request Mar 26, 2025
I took another look at the changes we had to make in rails#220 and compared
that to how things work in `actiondispatch`'s Cookie Store tests and
realized we were close, but missing how we were setting the options for
our store. So I've revamped the setup to be in line with what's in
Rails' own tests. This should make it easier to keep things in line and
working, going forward.

See the following two files for how Cookie Store tests (and their base
`ActionDispatch::IntegrationTest`) work today (as of Rails 8.0):
   * https://github.com/rails/rails/blob/8-0-stable/actionpack/test/dispatch/session/cookie_store_test.rb
   * https://github.com/rails/rails/blob/8-0-stable/actionpack/test/abstract_unit.rb

NOTE: The big downside to this is… it depends on some changes to how
`#with_routing`, provided by Rails, works. Meaning it only works with
Rails 7.2+. ☹️
stevenharman added a commit to docsend/activerecord-session_store that referenced this pull request Apr 2, 2025
I took another look at the changes we had to make in rails#220 and compared
that to how things work in `actiondispatch`'s Cookie Store tests and
realized we were close, but missing how we were setting the options for
our store. So I've revamped the setup to be in line with what's in
Rails' own tests. This should make it easier to keep things in line and
working, going forward.

We also need to patch in support for with_routing for integration tests
which was added in Rails 7.2. So we do that, only when necessary. We can
drop that patch when we drop Rails 7.1 support.

See the following two files for how Cookie Store tests (and their base
`ActionDispatch::IntegrationTest`) work today (as of Rails 8.0):
   * https://github.com/rails/rails/blob/8-0-stable/actionpack/test/dispatch/session/cookie_store_test.rb
   * https://github.com/rails/rails/blob/8-0-stable/actionpack/test/abstract_unit.rb
stevenharman added a commit to docsend/activerecord-session_store that referenced this pull request Apr 2, 2025
I took another look at the changes we had to make in rails#220 and compared
that to how things work in `actiondispatch`'s Cookie Store tests and
realized we were close, but missing how we were setting the options for
our store. So I've revamped the setup to be in line with what's in
Rails' own tests. This should make it easier to keep things in line and
working, going forward.

We also need to patch in support for with_routing for integration tests
which was added in Rails 7.2. So we do that, only when necessary. We can
drop that patch when we drop Rails 7.1 support.

See the following two files for how Cookie Store tests (and their base
`ActionDispatch::IntegrationTest`) work today (as of Rails 8.0):
   * https://github.com/rails/rails/blob/8-0-stable/actionpack/test/dispatch/session/cookie_store_test.rb
   * https://github.com/rails/rails/blob/8-0-stable/actionpack/test/abstract_unit.rb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants