From 2df647af85489805a8963afa1b88ab6d0fd80842 Mon Sep 17 00:00:00 2001 From: Igor Fedoronchuk Date: Mon, 15 Jun 2026 10:56:57 +0200 Subject: [PATCH 1/3] test: keep generated test app booting on Rails 8.1 Rails 8.1's generated ApplicationController calls stale_when_importmap_changes, a macro from importmap-rails. The Active Admin 3 asset setup uses Sprockets, not importmap, so the macro is undefined and the controller raised NameError at boot, failing every feature spec on Rails 8.1. Strip the line from the generated controller. No-op on Rails < 8.1 and harmless on the AA 4 path. --- spec/support/rails_template.rb | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/spec/support/rails_template.rb b/spec/support/rails_template.rb index 4a1e8a6..79a4bed 100644 --- a/spec/support/rails_template.rb +++ b/spec/support/rails_template.rb @@ -43,6 +43,14 @@ inject_into_file 'app/models/author.rb', " validates_presence_of :name\n validates_uniqueness_of :last_name\n", before: 'end' inject_into_file 'app/models/post.rb', " validates_presence_of :author\n has_many :post_comments\n", before: 'end' +# Rails 8.1's generated ApplicationController calls `stale_when_importmap_changes`, +# a macro provided by importmap-rails. The AA 3 asset setup uses Sprockets rather +# than importmap, so the macro is undefined and the controller raises NameError at +# boot — strip the line. No-op on Rails < 8.1 (line absent) and harmless on AA 4 +# (importmap present), where it only skips an HTTP-caching optimization in specs. +gsub_file 'app/controllers/application_controller.rb', + /^\s*stale_when_importmap_changes.*\n/, '' + # Add our local Active Admin to the load path (Rails 7.1+) gsub_file "config/environment.rb", 'require_relative "application"', From 098481b954ae65331c881d71d001a86476f2b95a Mon Sep 17 00:00:00 2001 From: Igor Fedoronchuk Date: Mon, 15 Jun 2026 10:56:57 +0200 Subject: [PATCH 2/3] ci: drop EOL Ruby 3.2 / Rails 7.1, cover Ruby 4.0 and Rails 8.1 Ruby 3.2 reached EOL on 2026-03-31 and Rails 7.1 on 2025-10-01, so remove them from the matrix. Add the current stable releases Ruby 4.0 and Rails 8.1 (8.1.x via the existing ~> pin), keeping Rails 7.2/8.0 which are still in security support. Exclude Active Admin 3.2.0 on Rails 8.1 as well, since it predates Rails 8 support, and add a Rails 8.1 cell to the Active Admin 4 set. Bump the gemspec required_ruby_version to >= 3.3.0 and move the Gemfile dev defaults to Rails 8.0.0 + Active Admin 3.5.1 (the previous 7.1.0 default is EOL; 3.2.0 cannot run on Rails 8). --- .github/workflows/test.yml | 12 ++++++++++-- Gemfile | 4 ++-- active_admin_import.gemspec | 2 +- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a4a70c8..cf3b044 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -16,19 +16,27 @@ jobs: strategy: fail-fast: false matrix: - ruby: ['3.2', '3.3', '3.4'] - rails: ['7.1.0', '7.2.0', '8.0.0'] + ruby: ['3.3', '3.4', '4.0'] + rails: ['7.2.0', '8.0.0', '8.1.0'] activeadmin: ['3.2.0', '3.3.0', '3.4.0', '3.5.1'] exclude: + # ActiveAdmin 3.2.0 predates Rails 8 support. - rails: '8.0.0' activeadmin: '3.2.0' + - rails: '8.1.0' + activeadmin: '3.2.0' include: + # ActiveAdmin 4 requires railties >= 7.2, so cover its floor and the + # newest supported Rails releases. - ruby: '3.4' rails: '7.2.0' activeadmin: '4.0.0.beta22' - ruby: '3.4' rails: '8.0.0' activeadmin: '4.0.0.beta22' + - ruby: '3.4' + rails: '8.1.0' + activeadmin: '4.0.0.beta22' env: RAILS: ${{ matrix.rails }} AA: ${{ matrix.activeadmin }} diff --git a/Gemfile b/Gemfile index c80ec8a..f9bdef1 100644 --- a/Gemfile +++ b/Gemfile @@ -1,8 +1,8 @@ source 'https://rubygems.org' gemspec -default_rails_version = '7.1.0' -default_activeadmin_version = '3.2.0' +default_rails_version = '8.0.0' +default_activeadmin_version = '3.5.1' # `~> 4.0.0.beta22` would admit 4.0.0 GA — pin prereleases exactly so the # CI cell tests the AA build it claims to test. diff --git a/active_admin_import.gemspec b/active_admin_import.gemspec index 196cc63..2e694cb 100644 --- a/active_admin_import.gemspec +++ b/active_admin_import.gemspec @@ -9,7 +9,7 @@ Gem::Specification.new do |gem| gem.summary = 'ActiveAdmin import based on activerecord-import gem.' gem.homepage = 'https://github.com/activeadmin-plugins/active_admin_import' gem.license = 'MIT' - gem.required_ruby_version = '>= 3.1.0' + gem.required_ruby_version = '>= 3.3.0' gem.files = `git ls-files`.split($OUTPUT_RECORD_SEPARATOR) gem.executables = gem.files.grep(%r{^bin/}).map { |f| File.basename(f) } gem.name = 'active_admin_import' From e90d807e8c0a78720c9885de849022ebc8c6d7ed Mon Sep 17 00:00:00 2001 From: Igor Fedoronchuk Date: Mon, 15 Jun 2026 11:08:42 +0200 Subject: [PATCH 3/3] test: skip JavaScript instead of patching the controller on Rails 8.1 The earlier gsub_file approach could not work: on Rails 8.1 rake setup boots the app during `rails generate model` (the gem's bundle has no importmap-rails), so the generated ApplicationController's stale_when_importmap_changes macro raised NameError and aborted setup before the gsub ran. Drop the gsub and pass --skip-javascript on the non-v4 path so the macro is never generated. Verified: fresh rake setup + full suite on Ruby 3.3 / Rails 8.1.3 / AA 3.5.1 / SQLite is green (58 examples, 0 failures). --- spec/support/rails_template.rb | 8 -------- tasks/test.rake | 11 ++++++++++- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/spec/support/rails_template.rb b/spec/support/rails_template.rb index 79a4bed..4a1e8a6 100644 --- a/spec/support/rails_template.rb +++ b/spec/support/rails_template.rb @@ -43,14 +43,6 @@ inject_into_file 'app/models/author.rb', " validates_presence_of :name\n validates_uniqueness_of :last_name\n", before: 'end' inject_into_file 'app/models/post.rb', " validates_presence_of :author\n has_many :post_comments\n", before: 'end' -# Rails 8.1's generated ApplicationController calls `stale_when_importmap_changes`, -# a macro provided by importmap-rails. The AA 3 asset setup uses Sprockets rather -# than importmap, so the macro is undefined and the controller raises NameError at -# boot — strip the line. No-op on Rails < 8.1 (line absent) and harmless on AA 4 -# (importmap present), where it only skips an HTTP-caching optimization in specs. -gsub_file 'app/controllers/application_controller.rb', - /^\s*stale_when_importmap_changes.*\n/, '' - # Add our local Active Admin to the load path (Rails 7.1+) gsub_file "config/environment.rb", 'require_relative "application"', diff --git a/tasks/test.rake b/tasks/test.rake index 8c74714..e07f606 100644 --- a/tasks/test.rake +++ b/tasks/test.rake @@ -24,7 +24,16 @@ task :setup do ) # v4 drops sprockets-rails (see Gemfile), so skip the asset pipeline to # avoid the auto-generated `config/initializers/assets.rb` crashing at boot. - rails_new_opts.unshift('--skip-asset-pipeline') if aa_v4 + if aa_v4 + rails_new_opts.unshift('--skip-asset-pipeline') + else + # Rails 8.1 wires importmap-rails into the generated ApplicationController + # (`stale_when_importmap_changes`). The AA 3 app uses Sprockets, not + # importmap, so that gem is absent and the controller raises NameError at + # boot. Skip JavaScript so the macro is never generated — the specs run on + # rack_test and never execute JS anyway. + rails_new_opts.unshift('--skip-javascript') + end system "bundle exec rails new spec/rails/#{TestAppPaths.app_dir_name} #{rails_new_opts.join(' ')}" end