diff --git a/.github/workflows/rspec.yml b/.github/workflows/rspec.yml index 45d9bfc..7a985f8 100644 --- a/.github/workflows/rspec.yml +++ b/.github/workflows/rspec.yml @@ -33,6 +33,9 @@ jobs: - ruby: "3.2" gemfile: "gemfiles/rails7.gemfile" db: "postgres" + - ruby: "3.2" + gemfile: "gemfiles/rails70.gemfile" + db: "postgres" - ruby: "3.2" gemfile: "gemfiles/rails7.gemfile" db: "mysql" diff --git a/CHANGELOG.md b/CHANGELOG.md index aef5aa4..6e59cff 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## master +- Fix Rails 7.0 support. ([@palkan][]) + ## 1.0.0 (2023-11-30) - Add ability to track concurrent transactions to with a thread (e.g., to multiple databases). ([@palkan][]) diff --git a/gemfiles/rails70.gemfile b/gemfiles/rails70.gemfile new file mode 100644 index 0000000..fffa7ad --- /dev/null +++ b/gemfiles/rails70.gemfile @@ -0,0 +1,8 @@ +source "https://rubygems.org" + +gem "rails", "~> 7.0.0" +gem "sqlite3" +gem "pg" +gem "mysql2" + +gemspec path: ".." diff --git a/lib/isolator/railtie.rb b/lib/isolator/railtie.rb index b5a862a..25b8ddd 100644 --- a/lib/isolator/railtie.rb +++ b/lib/isolator/railtie.rb @@ -51,8 +51,8 @@ def teardown_fixtures(*) ::ActiveRecord::TestFixtures.prepend(TestFixtures) end - # Rails 6 doesn't support this load hook, so we can emulate it - if ActiveRecord::VERSION::MAJOR < 7 && defined?(::ActiveRecord::TestFixtures) + # Rails <7.1 doesn't support this load hook, so we we fallback to the prev behaviour + if (ActiveRecord::VERSION::MAJOR < 7 || ActiveRecord::VERSION::MINOR < 1) && defined? ::ActiveRecord::TestFixtures.prepend(TestFixtures) end end