diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index a1227fc..2732da1 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -9,6 +9,11 @@ jobs: strategy: matrix: ruby-version: ['3.0', '3.3'] + gemfile: ['Gemfile', 'Gemfile_rails71'] + exclude: + # Rails 7.2 requires Ruby 3.1+ + - ruby-version: '3.0' + gemfile: 'Gemfile' steps: - uses: actions/checkout@v4 @@ -18,4 +23,4 @@ jobs: bundler-cache: true - name: Run tests - run: ./script/test + run: ./script/test ${{matrix.gemfile}} diff --git a/CHANGELOG.md b/CHANGELOG.md index 286116c..31f71ce 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # CHANGELOG +## 0.8.0.rc1 +* Add compatibility with Rails 7.2 + ## 0.7.1 * Add Rack 3.1 support [#163](https://github.com/testdouble/cypress-rails/pull/163) diff --git a/Gemfile.lock b/Gemfile.lock index e3d95e2..eb56460 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - cypress-rails (0.7.1) + cypress-rails (0.8.0.rc1) puma (>= 3.8.0) railties (>= 5.2.0) diff --git a/example/Gemfile b/example/Gemfile index 8646dbe..388c16d 100644 --- a/example/Gemfile +++ b/example/Gemfile @@ -1,6 +1,15 @@ source "https://rubygems.org" -gem "rails" +def rails_version + current_gemfile = File.basename(__FILE__) + + { + "Gemfile" => nil, + "Gemfile_rails71" => "~> 7.1.3" + }.fetch(current_gemfile) +end + +gem "rails", rails_version gem "sqlite3" gem "puma" gem "webpacker" diff --git a/example/Gemfile.lock b/example/Gemfile.lock index 0e8e2b7..1d8f417 100644 --- a/example/Gemfile.lock +++ b/example/Gemfile.lock @@ -1,107 +1,103 @@ PATH remote: .. specs: - cypress-rails (0.7.1) + cypress-rails (0.8.0.rc1) puma (>= 3.8.0) railties (>= 5.2.0) GEM remote: https://rubygems.org/ specs: - actioncable (7.1.3) - actionpack (= 7.1.3) - activesupport (= 7.1.3) + actioncable (7.2.1) + actionpack (= 7.2.1) + activesupport (= 7.2.1) nio4r (~> 2.0) websocket-driver (>= 0.6.1) zeitwerk (~> 2.6) - actionmailbox (7.1.3) - actionpack (= 7.1.3) - activejob (= 7.1.3) - activerecord (= 7.1.3) - activestorage (= 7.1.3) - activesupport (= 7.1.3) - mail (>= 2.7.1) - net-imap - net-pop - net-smtp - actionmailer (7.1.3) - actionpack (= 7.1.3) - actionview (= 7.1.3) - activejob (= 7.1.3) - activesupport (= 7.1.3) - mail (~> 2.5, >= 2.5.4) - net-imap - net-pop - net-smtp + actionmailbox (7.2.1) + actionpack (= 7.2.1) + activejob (= 7.2.1) + activerecord (= 7.2.1) + activestorage (= 7.2.1) + activesupport (= 7.2.1) + mail (>= 2.8.0) + actionmailer (7.2.1) + actionpack (= 7.2.1) + actionview (= 7.2.1) + activejob (= 7.2.1) + activesupport (= 7.2.1) + mail (>= 2.8.0) rails-dom-testing (~> 2.2) - actionpack (7.1.3) - actionview (= 7.1.3) - activesupport (= 7.1.3) + actionpack (7.2.1) + actionview (= 7.2.1) + activesupport (= 7.2.1) nokogiri (>= 1.8.5) racc - rack (>= 2.2.4) + rack (>= 2.2.4, < 3.2) rack-session (>= 1.0.1) rack-test (>= 0.6.3) rails-dom-testing (~> 2.2) rails-html-sanitizer (~> 1.6) - actiontext (7.1.3) - actionpack (= 7.1.3) - activerecord (= 7.1.3) - activestorage (= 7.1.3) - activesupport (= 7.1.3) + useragent (~> 0.16) + actiontext (7.2.1) + actionpack (= 7.2.1) + activerecord (= 7.2.1) + activestorage (= 7.2.1) + activesupport (= 7.2.1) globalid (>= 0.6.0) nokogiri (>= 1.8.5) - actionview (7.1.3) - activesupport (= 7.1.3) + actionview (7.2.1) + activesupport (= 7.2.1) builder (~> 3.1) erubi (~> 1.11) rails-dom-testing (~> 2.2) rails-html-sanitizer (~> 1.6) - activejob (7.1.3) - activesupport (= 7.1.3) + activejob (7.2.1) + activesupport (= 7.2.1) globalid (>= 0.3.6) - activemodel (7.1.3) - activesupport (= 7.1.3) - activerecord (7.1.3) - activemodel (= 7.1.3) - activesupport (= 7.1.3) + activemodel (7.2.1) + activesupport (= 7.2.1) + activerecord (7.2.1) + activemodel (= 7.2.1) + activesupport (= 7.2.1) timeout (>= 0.4.0) - activestorage (7.1.3) - actionpack (= 7.1.3) - activejob (= 7.1.3) - activerecord (= 7.1.3) - activesupport (= 7.1.3) + activestorage (7.2.1) + actionpack (= 7.2.1) + activejob (= 7.2.1) + activerecord (= 7.2.1) + activesupport (= 7.2.1) marcel (~> 1.0) - activesupport (7.1.3) + activesupport (7.2.1) base64 bigdecimal - concurrent-ruby (~> 1.0, >= 1.0.2) + concurrent-ruby (~> 1.0, >= 1.3.1) connection_pool (>= 2.2.5) drb i18n (>= 1.6, < 2) + logger (>= 1.4.2) minitest (>= 5.1) - mutex_m - tzinfo (~> 2.0) + securerandom (>= 0.3) + tzinfo (~> 2.0, >= 2.0.5) base64 (0.2.0) - bigdecimal (3.1.6) + bigdecimal (3.1.8) bootsnap (1.18.3) msgpack (~> 1.2) - builder (3.2.4) - concurrent-ruby (1.2.3) + builder (3.3.0) + concurrent-ruby (1.3.4) connection_pool (2.4.1) crass (1.0.6) date (3.3.4) - drb (2.2.0) - ruby2_keywords - erubi (1.12.0) + drb (2.2.1) + erubi (1.13.0) globalid (1.2.1) activesupport (>= 6.1) - i18n (1.14.1) + i18n (1.14.6) concurrent-ruby (~> 1.0) io-console (0.7.2) - irb (1.11.2) - rdoc + irb (1.14.0) + rdoc (>= 4.0.0) reline (>= 0.4.2) + logger (1.6.1) loofah (2.22.0) crass (~> 1.0.2) nokogiri (>= 1.12.0) @@ -110,30 +106,29 @@ GEM net-imap net-pop net-smtp - marcel (1.0.2) + marcel (1.0.4) mini_mime (1.1.5) - mini_portile2 (2.8.5) - minitest (5.22.2) + mini_portile2 (2.8.7) + minitest (5.25.1) msgpack (1.7.2) - mutex_m (0.2.0) - net-imap (0.4.10) + net-imap (0.4.16) date net-protocol net-pop (0.1.2) net-protocol net-protocol (0.2.2) timeout - net-smtp (0.4.0.1) + net-smtp (0.5.0) net-protocol - nio4r (2.7.0) - nokogiri (1.16.2) + nio4r (2.7.3) + nokogiri (1.16.7) mini_portile2 (~> 2.8.2) racc (~> 1.4) psych (5.1.2) stringio puma (6.4.2) nio4r (~> 2.0) - racc (1.7.3) + racc (1.8.1) rack (3.1.7) rack-proxy (0.7.7) rack @@ -144,20 +139,20 @@ GEM rackup (2.1.0) rack (>= 3) webrick (~> 1.8) - rails (7.1.3) - actioncable (= 7.1.3) - actionmailbox (= 7.1.3) - actionmailer (= 7.1.3) - actionpack (= 7.1.3) - actiontext (= 7.1.3) - actionview (= 7.1.3) - activejob (= 7.1.3) - activemodel (= 7.1.3) - activerecord (= 7.1.3) - activestorage (= 7.1.3) - activesupport (= 7.1.3) + rails (7.2.1) + actioncable (= 7.2.1) + actionmailbox (= 7.2.1) + actionmailer (= 7.2.1) + actionpack (= 7.2.1) + actiontext (= 7.2.1) + actionview (= 7.2.1) + activejob (= 7.2.1) + activemodel (= 7.2.1) + activerecord (= 7.2.1) + activestorage (= 7.2.1) + activesupport (= 7.2.1) bundler (>= 1.15.0) - railties (= 7.1.3) + railties (= 7.2.1) rails-dom-testing (2.2.0) activesupport (>= 5.0.0) minitest @@ -165,28 +160,29 @@ GEM rails-html-sanitizer (1.6.0) loofah (~> 2.21) nokogiri (~> 1.14) - railties (7.1.3) - actionpack (= 7.1.3) - activesupport (= 7.1.3) - irb + railties (7.2.1) + actionpack (= 7.2.1) + activesupport (= 7.2.1) + irb (~> 1.13) rackup (>= 1.0.0) rake (>= 12.2) thor (~> 1.0, >= 1.2.2) zeitwerk (~> 2.6) - rake (13.1.0) - rdoc (6.6.2) + rake (13.2.1) + rdoc (6.7.0) psych (>= 4.0.0) - reline (0.4.2) + reline (0.5.10) io-console (~> 0.5) - ruby2_keywords (0.0.5) + securerandom (0.3.1) semantic_range (3.0.0) sqlite3 (1.7.2) mini_portile2 (~> 2.8.0) - stringio (3.1.0) - thor (1.3.0) + stringio (3.1.1) + thor (1.3.2) timeout (0.4.1) tzinfo (2.0.6) concurrent-ruby (~> 1.0) + useragent (0.16.10) webpacker (5.4.4) activesupport (>= 5.2) rack-proxy (>= 0.6.1) @@ -196,7 +192,7 @@ GEM websocket-driver (0.7.6) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.5) - zeitwerk (2.6.13) + zeitwerk (2.6.18) PLATFORMS ruby diff --git a/example/Gemfile_rails71 b/example/Gemfile_rails71 new file mode 120000 index 0000000..6ab7900 --- /dev/null +++ b/example/Gemfile_rails71 @@ -0,0 +1 @@ +Gemfile \ No newline at end of file diff --git a/example/Gemfile_rails71.lock b/example/Gemfile_rails71.lock new file mode 100644 index 0000000..275a55d --- /dev/null +++ b/example/Gemfile_rails71.lock @@ -0,0 +1,213 @@ +PATH + remote: .. + specs: + cypress-rails (0.8.0.rc1) + puma (>= 3.8.0) + railties (>= 5.2.0) + +GEM + remote: https://rubygems.org/ + specs: + actioncable (7.1.3) + actionpack (= 7.1.3) + activesupport (= 7.1.3) + nio4r (~> 2.0) + websocket-driver (>= 0.6.1) + zeitwerk (~> 2.6) + actionmailbox (7.1.3) + actionpack (= 7.1.3) + activejob (= 7.1.3) + activerecord (= 7.1.3) + activestorage (= 7.1.3) + activesupport (= 7.1.3) + mail (>= 2.7.1) + net-imap + net-pop + net-smtp + actionmailer (7.1.3) + actionpack (= 7.1.3) + actionview (= 7.1.3) + activejob (= 7.1.3) + activesupport (= 7.1.3) + mail (~> 2.5, >= 2.5.4) + net-imap + net-pop + net-smtp + rails-dom-testing (~> 2.2) + actionpack (7.1.3) + actionview (= 7.1.3) + activesupport (= 7.1.3) + nokogiri (>= 1.8.5) + racc + rack (>= 2.2.4) + rack-session (>= 1.0.1) + rack-test (>= 0.6.3) + rails-dom-testing (~> 2.2) + rails-html-sanitizer (~> 1.6) + actiontext (7.1.3) + actionpack (= 7.1.3) + activerecord (= 7.1.3) + activestorage (= 7.1.3) + activesupport (= 7.1.3) + globalid (>= 0.6.0) + nokogiri (>= 1.8.5) + actionview (7.1.3) + activesupport (= 7.1.3) + builder (~> 3.1) + erubi (~> 1.11) + rails-dom-testing (~> 2.2) + rails-html-sanitizer (~> 1.6) + activejob (7.1.3) + activesupport (= 7.1.3) + globalid (>= 0.3.6) + activemodel (7.1.3) + activesupport (= 7.1.3) + activerecord (7.1.3) + activemodel (= 7.1.3) + activesupport (= 7.1.3) + timeout (>= 0.4.0) + activestorage (7.1.3) + actionpack (= 7.1.3) + activejob (= 7.1.3) + activerecord (= 7.1.3) + activesupport (= 7.1.3) + marcel (~> 1.0) + activesupport (7.1.3) + base64 + bigdecimal + concurrent-ruby (~> 1.0, >= 1.0.2) + connection_pool (>= 2.2.5) + drb + i18n (>= 1.6, < 2) + minitest (>= 5.1) + mutex_m + tzinfo (~> 2.0) + base64 (0.2.0) + bigdecimal (3.1.6) + bootsnap (1.18.3) + msgpack (~> 1.2) + builder (3.2.4) + concurrent-ruby (1.2.3) + connection_pool (2.4.1) + crass (1.0.6) + date (3.3.4) + drb (2.2.0) + ruby2_keywords + erubi (1.12.0) + globalid (1.2.1) + activesupport (>= 6.1) + i18n (1.14.1) + concurrent-ruby (~> 1.0) + io-console (0.7.2) + irb (1.11.2) + rdoc + reline (>= 0.4.2) + loofah (2.22.0) + crass (~> 1.0.2) + nokogiri (>= 1.12.0) + mail (2.8.1) + mini_mime (>= 0.1.1) + net-imap + net-pop + net-smtp + marcel (1.0.2) + mini_mime (1.1.5) + mini_portile2 (2.8.5) + minitest (5.22.2) + msgpack (1.7.2) + mutex_m (0.2.0) + net-imap (0.4.10) + date + net-protocol + net-pop (0.1.2) + net-protocol + net-protocol (0.2.2) + timeout + net-smtp (0.4.0.1) + net-protocol + nio4r (2.7.0) + nokogiri (1.16.2) + mini_portile2 (~> 2.8.2) + racc (~> 1.4) + psych (5.1.2) + stringio + puma (6.4.2) + nio4r (~> 2.0) + racc (1.7.3) + rack (3.1.7) + rack-proxy (0.7.7) + rack + rack-session (2.0.0) + rack (>= 3.0.0) + rack-test (2.1.0) + rack (>= 1.3) + rackup (2.1.0) + rack (>= 3) + webrick (~> 1.8) + rails (7.1.3) + actioncable (= 7.1.3) + actionmailbox (= 7.1.3) + actionmailer (= 7.1.3) + actionpack (= 7.1.3) + actiontext (= 7.1.3) + actionview (= 7.1.3) + activejob (= 7.1.3) + activemodel (= 7.1.3) + activerecord (= 7.1.3) + activestorage (= 7.1.3) + activesupport (= 7.1.3) + bundler (>= 1.15.0) + railties (= 7.1.3) + rails-dom-testing (2.2.0) + activesupport (>= 5.0.0) + minitest + nokogiri (>= 1.6) + rails-html-sanitizer (1.6.0) + loofah (~> 2.21) + nokogiri (~> 1.14) + railties (7.1.3) + actionpack (= 7.1.3) + activesupport (= 7.1.3) + irb + rackup (>= 1.0.0) + rake (>= 12.2) + thor (~> 1.0, >= 1.2.2) + zeitwerk (~> 2.6) + rake (13.1.0) + rdoc (6.6.2) + psych (>= 4.0.0) + reline (0.4.2) + io-console (~> 0.5) + ruby2_keywords (0.0.5) + semantic_range (3.0.0) + sqlite3 (1.7.2) + mini_portile2 (~> 2.8.0) + stringio (3.1.0) + thor (1.3.0) + timeout (0.4.1) + tzinfo (2.0.6) + concurrent-ruby (~> 1.0) + webpacker (5.4.4) + activesupport (>= 5.2) + rack-proxy (>= 0.6.1) + railties (>= 5.2) + semantic_range (>= 2.3.0) + webrick (1.8.1) + websocket-driver (0.7.6) + websocket-extensions (>= 0.1.0) + websocket-extensions (0.1.5) + zeitwerk (2.6.13) + +PLATFORMS + ruby + +DEPENDENCIES + bootsnap + cypress-rails! + puma + rails (~> 7.1.3) + sqlite3 + webpacker + +BUNDLED WITH + 2.3.13 diff --git a/example/README.md b/example/README.md index 7db80e4..c0738ef 100644 --- a/example/README.md +++ b/example/README.md @@ -1,24 +1,19 @@ # README -This README would normally document whatever steps are necessary to get the -application up and running. - -Things you may want to cover: - -* Ruby version - -* System dependencies - -* Configuration - -* Database creation - -* Database initialization - -* How to run the test suite - -* Services (job queues, cache servers, search engines, etc.) - -* Deployment instructions - -* ... +The example app has multiple, symlinked Gemfiles to be able to test against +different dependency versions (so far just Rails). + +For the latest version of Rails, you can just use all the default `bundle` +commands: +``` +bundle +bundle exec rake cypress:run +``` + +For previous version(s) of Rails, you need to specify the Gemfile to use. So +for `Gemfile_rails71` (which uses Rails 7.1), you'll need to include an env var +when you use `bundle` commands: +``` +BUNDLE_GEMFILE=Gemfile_rails71 bundle +BUNDLE_GEMFILE=Gemfile_rails71 bundle exec rake cypress:run +``` diff --git a/lib/cypress-rails/manages_transactions.rb b/lib/cypress-rails/manages_transactions.rb index 484c434..a09341d 100644 --- a/lib/cypress-rails/manages_transactions.rb +++ b/lib/cypress-rails/manages_transactions.rb @@ -10,7 +10,6 @@ def begin_transaction @connections = gather_connections @connections.each do |connection| connection.begin_transaction joinable: false, _lazy: false - connection.pool.lock_thread = true end # When connections are established in the future, begin a transaction too @@ -26,7 +25,6 @@ def begin_transaction if connection && !@connections.include?(connection) connection.begin_transaction joinable: false, _lazy: false - connection.pool.lock_thread = true @connections << connection end end @@ -42,7 +40,6 @@ def rollback_transaction @connections.each do |connection| connection.rollback_transaction if connection.transaction_open? - connection.pool.lock_thread = false end @connections.clear @@ -58,7 +55,14 @@ def initialize def gather_connections setup_shared_connection_pool - ActiveRecord::Base.connection_handler.connection_pool_list.map(&:connection) + ActiveRecord::Base.connection_handler.connection_pool_list.map do |pool| + # Rails 7.2+ + if pool.respond_to?(:lease_connection) + pool.lease_connection + else + pool.connection + end + end end # Shares the writing connection pool with connections on diff --git a/lib/cypress-rails/version.rb b/lib/cypress-rails/version.rb index 06e5bc8..3d64fd0 100644 --- a/lib/cypress-rails/version.rb +++ b/lib/cypress-rails/version.rb @@ -1,3 +1,3 @@ module CypressRails - VERSION = "0.7.1" + VERSION = "0.8.0.rc1" end diff --git a/script/test b/script/test index cc27cf4..ec1db5d 100755 --- a/script/test +++ b/script/test @@ -6,14 +6,10 @@ set -x echo "---> Installing dependencies" bundle -cd example -bundle -yarn -cd .. echo "---> Running tests" bundle exec rake -./script/test_example_app +BUNDLE_GEMFILE="${1-Gemfile}" ./script/test_example_app bundle exec rake test diff --git a/script/test_example_app b/script/test_example_app index 730914e..eebbf21 100755 --- a/script/test_example_app +++ b/script/test_example_app @@ -2,8 +2,6 @@ set -e -directory=$1 - cd example bundle yarn install @@ -18,4 +16,3 @@ if ! bundle exec rake cypress:run CYPRESS_RAILS_CYPRESS_OPTS="-h" | grep -q "Usa echo "Failed to pass options to cypress run" exit 1 fi -