From be103a81483576f52d3268fa8790eaee037bdb4a Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Thu, 26 Sep 2024 18:33:37 -0700 Subject: [PATCH] Test with Rails 8.0.0.beta1 on CI --- .github/workflows/build.yml | 2 ++ gemfiles/activerecord80.gemfile | 11 +++++++++++ lib/groupdate/magic.rb | 2 +- test/test_helper.rb | 8 +++++++- 4 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 gemfiles/activerecord80.gemfile diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9efee349c..be623161e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -6,6 +6,8 @@ jobs: fail-fast: false matrix: include: + - ruby: 3.3 + gemfile: gemfiles/activerecord80.gemfile - ruby: 3.3 gemfile: Gemfile - ruby: 3.2 diff --git a/gemfiles/activerecord80.gemfile b/gemfiles/activerecord80.gemfile new file mode 100644 index 000000000..100c3ac6f --- /dev/null +++ b/gemfiles/activerecord80.gemfile @@ -0,0 +1,11 @@ +source "https://rubygems.org" + +gemspec path: ".." + +gem "rake" +gem "minitest" +gem "activerecord", "~> 8.0.0.beta1" +gem "pg" +gem "mysql2" +gem "trilogy" +gem "sqlite3" diff --git a/lib/groupdate/magic.rb b/lib/groupdate/magic.rb index 5bd207c57..5f63fe750 100644 --- a/lib/groupdate/magic.rb +++ b/lib/groupdate/magic.rb @@ -183,7 +183,7 @@ def time_zone_support?(relation) if relation.connection.adapter_name.match?(/mysql/i) # need to call klass for Rails < 5.2 sql = relation.klass.send(:sanitize_sql_array, ["SELECT CONVERT_TZ(NOW(), '+00:00', ?)", time_zone.tzinfo.name]) - !relation.connection.select_all(sql).first.values.first.nil? + !relation.connection.select_all(sql).to_a.first.values.first.nil? else true end diff --git a/test/test_helper.rb b/test/test_helper.rb index 806cb5f8b..2646d5a97 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -13,6 +13,10 @@ if adapter != "enumerable" && ActiveRecord::VERSION::STRING.to_f >= 7.1 # must come before ActiveRecord::Base.establish_connection ActiveRecord.async_query_executor = :global_thread_pool + + if ActiveRecord::VERSION::MAJOR >= 8 + ActiveRecord::Base.asynchronous_queries_tracker.start_session + end end puts "Using #{adapter}" @@ -33,7 +37,9 @@ formats: {special: "%b %e, %Y"} } -if ActiveSupport::VERSION::STRING.to_f == 7.2 +if ActiveSupport::VERSION::STRING.to_f == 8.0 + ActiveSupport.to_time_preserves_timezone = :zone +elsif ActiveSupport::VERSION::STRING.to_f == 7.2 ActiveSupport.to_time_preserves_timezone = true end