From 4000f2c3524bb0f9a180b80a60c7b22e074747f4 Mon Sep 17 00:00:00 2001 From: Shinichi Maeshima Date: Thu, 1 Oct 2026 15:38:38 +0900 Subject: [PATCH] Expand CI coverage for Rails 8.1 and Ruby 4.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add Rails 8.1 coverage for Ruby 3.2–4.0 and Ruby 4.0 coverage for Rails 8.0. Rails 8.1 now normalizes timezone-aware time attributes to 2000-01-01 during conversion. The specs expected the current date, so they failed when Rails returned the fixed date. Update the expectations for Rails 8.1 and preserve the Rails 8.0 behavior. The Rails change is in: https://github.com/rails/rails/commit/8eeaa38 Update actions/checkout to the latest version. --- .github/workflows/ci.yml | 12 +++++++++++- Appraisals | 4 ++++ gemfiles/rails_8_1.gemfile | 13 +++++++++++++ .../validates_timeliness/orm/active_record_spec.rb | 14 +++++++++++--- 4 files changed, 39 insertions(+), 4 deletions(-) create mode 100644 gemfiles/rails_8_1.gemfile diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2c83e5ee..f2e48cc4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,12 +13,22 @@ jobs: ruby: 3.3 - gemfile: rails_8_0 ruby: 3.4 + - gemfile: rails_8_0 + ruby: "4.0" + - gemfile: rails_8_1 + ruby: 3.2 + - gemfile: rails_8_1 + ruby: 3.3 + - gemfile: rails_8_1 + ruby: 3.4 + - gemfile: rails_8_1 + ruby: "4.0" name: ${{ matrix.gemfile }}, ruby ${{ matrix.ruby }} env: BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/${{ matrix.gemfile }}.gemfile steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v7 - name: Set up Ruby uses: ruby/setup-ruby@v1 diff --git a/Appraisals b/Appraisals index fec3689c..710baee9 100644 --- a/Appraisals +++ b/Appraisals @@ -1,3 +1,7 @@ appraise "rails_8_0" do gem "rails", "~> 8.0.0" end + +appraise "rails_8_1" do + gem "rails", "~> 8.1.0" +end diff --git a/gemfiles/rails_8_1.gemfile b/gemfiles/rails_8_1.gemfile new file mode 100644 index 00000000..2c1eb8b9 --- /dev/null +++ b/gemfiles/rails_8_1.gemfile @@ -0,0 +1,13 @@ +# This file was generated by Appraisal + +source "https://rubygems.org" + +gem "rails", "~> 8.1.0" +gem "rspec" +gem "rspec-rails", "~> 8.0" +gem "sqlite3", "~> 2.0" +gem "debug" +gem "appraisal" +gem "nokogiri" + +gemspec path: "../" diff --git a/spec/validates_timeliness/orm/active_record_spec.rb b/spec/validates_timeliness/orm/active_record_spec.rb index 973c2435..154c68bf 100644 --- a/spec/validates_timeliness/orm/active_record_spec.rb +++ b/spec/validates_timeliness/orm/active_record_spec.rb @@ -107,6 +107,14 @@ class EmployeeWithParser < ActiveRecord::Base context 'timezone aware' do with_config(:default_timezone, 'Australia/Melbourne') + let(:expected_time) do + if ActiveRecord.gem_version >= Gem::Version.new('8.1') + Time.zone.local(2000, 1, 1, 12, 30) + else + '12:30'.in_time_zone + end + end + before do unless ActiveRecord::Base.time_zone_aware_types.include?(:time) ActiveRecord::Base.time_zone_aware_types.push(:time) @@ -116,7 +124,7 @@ class EmployeeWithParser < ActiveRecord::Base it 'should parse a string value' do record.birth_time = '12:30' - expect(record.birth_time).to eq('12:30'.in_time_zone) + expect(record.birth_time).to eq(expected_time) expect(Timeliness::Parser).to have_received(:parse) end @@ -130,8 +138,8 @@ class EmployeeWithParser < ActiveRecord::Base it 'should store a Time value after parsing string' do record.birth_time = '12:30' - expect(record.birth_time).to eq('12:30'.in_time_zone) - expect(record.birth_time.utc_offset).to eq '12:30'.in_time_zone.utc_offset + expect(record.birth_time).to eq(expected_time) + expect(record.birth_time.utc_offset).to eq expected_time.utc_offset end end