From 8e6e5f34d14d46622e26fbf5311e4cd4ab1d26d4 Mon Sep 17 00:00:00 2001 From: Igor Fedoronchuk Date: Mon, 30 Mar 2026 13:50:57 +0200 Subject: [PATCH 1/7] Drop EOL versions, switch to Cuprite, modernize CI - Drop Ruby < 3.1, Rails < 7.1, ActiveAdmin < 3.0 - Replace selenium-webdriver/webdrivers with Cuprite - Replace coveralls with direct test runs - Update sqlite3 ~> 1.4 to ~> 2.0 - Move sprockets-rails/sass-rails out of test group - Fix rails_template.rb for Rails 7.1+ (require_relative, Gemfile removal order) - Add ActiveRecord::Migration.maintain_test_schema! - Update CI matrix: Ruby 3.2-3.4, Rails 7.1-7.2, AA 3.2-3.3 - Use bundler-cache in CI, remove bundler < 2 constraint --- .github/workflows/ci.yml | 23 ++++------- Gemfile | 22 +++++------ ...ve_admin_scoped_collection_actions.gemspec | 4 +- spec/spec_helper.rb | 3 +- spec/support/capybara.rb | 20 +++------- spec/support/rails_template.rb | 39 +++++++------------ 6 files changed, 41 insertions(+), 70 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 69677f6..cfcfe07 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,22 +2,17 @@ name: CI on: pull_request: push: - branches: - - master + branches: [master] jobs: test: - name: Tests with Ruby ${{ matrix.ruby }} Rails ${{ matrix.rails }} Active Admin ${{ matrix.activeadmin }} + name: Ruby ${{ matrix.ruby }} / Rails ${{ matrix.rails }} / AA ${{ matrix.activeadmin }} runs-on: ubuntu-latest strategy: + fail-fast: false matrix: - ruby: - - '3.2.0' - - '3.3.0' - rails: - - '7.1.0' - - '7.2.0' - activeadmin: - - '3.3.0' + ruby: ['3.2.0', '3.3.0', '3.4.0'] + rails: ['7.1.0', '7.2.0'] + activeadmin: ['3.2.0', '3.3.0'] env: RAILS: ${{ matrix.rails }} AA: ${{ matrix.activeadmin }} @@ -26,8 +21,6 @@ jobs: - uses: ruby/setup-ruby@v1 with: ruby-version: ${{ matrix.ruby }} + bundler-cache: true - name: Run tests - run: | - gem install bundler -v '< 2' - bundle install - bundle exec rspec spec + run: bundle exec rspec spec diff --git a/Gemfile b/Gemfile index 01c54cf..8a36f97 100644 --- a/Gemfile +++ b/Gemfile @@ -1,24 +1,20 @@ source 'https://rubygems.org' - gemspec -group :test do - default_rails_version = '7.1.0' - default_activeadmin_version = '3.2.0' +default_rails_version = '7.1.0' +default_activeadmin_version = '3.2.0' - gem 'rails', "~> #{ENV['RAILS'] || default_rails_version}" - gem 'activeadmin', "~> #{ENV['AA'] || default_activeadmin_version}" +gem 'rails', "~> #{ENV['RAILS'] || default_rails_version}" +gem 'activeadmin', "~> #{ENV['AA'] || default_activeadmin_version}" +gem 'sprockets-rails' +gem 'sass-rails' - gem 'sprockets-rails' +group :test do gem 'rspec-rails' - gem 'coveralls_reborn', require: false - gem 'sass-rails' - gem 'sqlite3', '~> 1.4.0' - gem 'launchy' + gem 'sqlite3', '~> 2.0' gem 'database_cleaner' gem 'capybara' - gem 'webdrivers' - gem 'byebug' + gem 'cuprite' gem 'draper' gem 'webrick', require: false end diff --git a/active_admin_scoped_collection_actions.gemspec b/active_admin_scoped_collection_actions.gemspec index a7a785b..3101124 100644 --- a/active_admin_scoped_collection_actions.gemspec +++ b/active_admin_scoped_collection_actions.gemspec @@ -12,10 +12,12 @@ Gem::Specification.new do |spec| spec.homepage = "https://github.com/activeadmin-plugins/active_admin_scoped_collection_actions" spec.license = "MIT" + spec.required_ruby_version = '>= 3.1.0' + spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) } spec.bindir = "exe" spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) } spec.require_paths = ["lib"] - spec.add_dependency "activeadmin", ">= 1.1", "< 4.0" + spec.add_dependency "activeadmin", ">= 3.0", "< 4.0" end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 64e4eea..14f5a1e 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -29,8 +29,6 @@ require 'rspec/rails' require 'capybara/rails' require 'capybara/rspec' -require 'selenium-webdriver' - require 'support/admin' require 'support/capybara' @@ -38,6 +36,7 @@ config.use_transactional_fixtures = false config.before(:suite) do + ActiveRecord::Migration.maintain_test_schema! DatabaseCleaner.strategy = :truncation DatabaseCleaner.clean_with(:truncation) end diff --git a/spec/support/capybara.rb b/spec/support/capybara.rb index 9e644a4..e09d7e9 100644 --- a/spec/support/capybara.rb +++ b/spec/support/capybara.rb @@ -1,16 +1,8 @@ -Capybara.server = :webrick - -Capybara.configure do |config| - config.match = :prefer_exact -end +require 'capybara/cuprite' -Webdrivers::Chromedriver.update - -Capybara.register_driver :selenium_chrome do |app| - options = Selenium::WebDriver::Chrome::Options.new( - args: %w[headless disable-gpu no-sandbox] - ) - Capybara::Selenium::Driver.new(app, browser: :chrome, options: options) +Capybara.server = :webrick +Capybara.register_driver :cuprite do |app| + Capybara::Cuprite::Driver.new(app, headless: true, window_size: [1280, 800]) end - -Capybara.javascript_driver = :selenium_chrome +Capybara.javascript_driver = :cuprite +Capybara.default_max_wait_time = 5 diff --git a/spec/support/rails_template.rb b/spec/support/rails_template.rb index ecaa23e..a67827f 100644 --- a/spec/support/rails_template.rb +++ b/spec/support/rails_template.rb @@ -1,7 +1,7 @@ # Rails template to build the sample app for specs -generate :model, 'author name:string{10}:uniq last_name:string birthday:date' -generate :model, 'post title:string:uniq body:text author:references' +generate :model, 'author name:string{10}:uniq last_name:string birthday:date --force' +generate :model, 'post title:string:uniq body:text author:references --force' #Add validation inject_into_file "app/models/author.rb", " validates_presence_of :name\n validates_uniqueness_of :last_name\n", after: "ApplicationRecord\n" @@ -23,15 +23,10 @@ " end\n", after: "ApplicationRecord\n" -# Configure default_url_options in test environment -inject_into_file "config/environments/test.rb", " config.action_mailer.default_url_options = { :host => 'example.com' }\n", after: "config.cache_classes = true\n" - -# Add our local Active Admin to the load path -inject_into_file "config/environment.rb", - "\n$LOAD_PATH.unshift('#{File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'lib'))}')\nrequire \"active_admin\"\n", - after: "require File.expand_path('../application', __FILE__)" - -run "rm Gemfile" +# Add our local Active Admin to the load path (Rails 7.1+) +gsub_file "config/environment.rb", + 'require_relative "application"', + "require_relative \"application\"\n$LOAD_PATH.unshift('#{File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'lib'))}')\nrequire \"active_admin\"\n" $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib')) @@ -39,24 +34,18 @@ generate :'formtastic:install' generate :'decorator Author' -# Install active_admin_date_time_datetimepicker assets +# Install active_admin_scoped_collection_actions assets inject_into_file "app/assets/stylesheets/active_admin.scss", "@import \"active_admin_scoped_collection_actions\";\n", after: "@import \"active_admin/base\";\n" -if File.file?("app/assets/javascripts/active_admin.js.coffee") - inject_into_file "app/assets/javascripts/active_admin.js.coffee", - "#= require active_admin_scoped_collection_actions\n", - after: "#= require active_admin/base\n" -else - inject_into_file "app/assets/javascripts/active_admin.js", - "//= require active_admin_scoped_collection_actions\n", - after: "//= require active_admin/base\n" -end - -run "rm -r test" -run "rm -r spec" +inject_into_file "app/assets/javascripts/active_admin.js", + "//= require active_admin_scoped_collection_actions\n", + after: "//= require active_admin/base\n" +run "rm -rf test" route "root :to => 'admin/dashboard#index'" - rake "db:migrate" + +# Remove Gemfile last so rake/route/generate work during template +run "rm -f Gemfile Gemfile.lock" From 2607cc41024a1766c74447af387bff580c14b995 Mon Sep 17 00:00:00 2001 From: Igor Fedoronchuk Date: Tue, 7 Apr 2026 13:41:52 +0200 Subject: [PATCH 2/7] Add ActiveAdmin 3.5+ support, fix jQuery UI dialog compatibility jQuery UI 1.14 (bundled with AA 3.5.1) replaced the deprecated `dialogClass` option with `classes`. Add the new `classes` option alongside the existing `dialogClass` for backward compatibility with older AA versions. Include `ui-corner-all` to preserve default dialog styling. Expand CI matrix to cover AA 3.4/3.5 and Rails 8.0. --- .github/workflows/ci.yml | 7 +++++-- Gemfile | 2 +- vendor/assets/javascripts/lib/dialog_mass_fields_update.js | 1 + 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cfcfe07..52c9cc1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,8 +11,11 @@ jobs: fail-fast: false matrix: ruby: ['3.2.0', '3.3.0', '3.4.0'] - rails: ['7.1.0', '7.2.0'] - activeadmin: ['3.2.0', '3.3.0'] + rails: ['7.1.0', '7.2.0', '8.0.0'] + activeadmin: ['3.2.0', '3.3.0', '3.4.0', '3.5.0'] + exclude: + - rails: '8.0.0' + activeadmin: '3.2.0' env: RAILS: ${{ matrix.rails }} AA: ${{ matrix.activeadmin }} diff --git a/Gemfile b/Gemfile index 8a36f97..e7b86ac 100644 --- a/Gemfile +++ b/Gemfile @@ -2,7 +2,7 @@ source 'https://rubygems.org' gemspec default_rails_version = '7.1.0' -default_activeadmin_version = '3.2.0' +default_activeadmin_version = '3.5.0' gem 'rails', "~> #{ENV['RAILS'] || default_rails_version}" gem 'activeadmin', "~> #{ENV['AA'] || default_activeadmin_version}" diff --git a/vendor/assets/javascripts/lib/dialog_mass_fields_update.js b/vendor/assets/javascripts/lib/dialog_mass_fields_update.js index 53fcbda..9f28e80 100644 --- a/vendor/assets/javascripts/lib/dialog_mass_fields_update.js +++ b/vendor/assets/javascripts/lib/dialog_mass_fields_update.js @@ -47,6 +47,7 @@ ActiveAdmin.dialogMassFieldsUpdate = function(message, inputs, callback){ return form.dialog({ modal: true, + classes: { 'ui-dialog': 'ui-corner-all active_admin_dialog active_admin_dialog_mass_update_by_filter' }, dialogClass: 'active_admin_dialog active_admin_dialog_mass_update_by_filter', maxHeight: window.innerHeight - (window.innerHeight * 0.1), open() { From 3d2200e0ed3610c2c652c14f55bcbc2b84d7618a Mon Sep 17 00:00:00 2001 From: Igor Fedoronchuk Date: Tue, 7 Apr 2026 13:48:19 +0200 Subject: [PATCH 3/7] Add coverage badge via SimpleCov and GitHub Pages Add SimpleCov for test coverage reporting. CI generates a shields.io endpoint badge JSON and deploys it to GitHub Pages on master pushes. Coverage badge added to README. --- .github/workflows/ci.yml | 58 ++++++++++++++++++++++++++++++++++++++++ Gemfile | 1 + README.md | 1 + spec/spec_helper.rb | 3 +++ 4 files changed, 63 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 52c9cc1..e1f4f76 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -3,6 +3,12 @@ on: pull_request: push: branches: [master] + +permissions: + contents: read + pages: write + id-token: write + jobs: test: name: Ruby ${{ matrix.ruby }} / Rails ${{ matrix.rails }} / AA ${{ matrix.activeadmin }} @@ -27,3 +33,55 @@ jobs: bundler-cache: true - name: Run tests run: bundle exec rspec spec + + - name: Generate badge.json + if: matrix.ruby == '3.4.0' && matrix.rails == '8.0.0' && matrix.activeadmin == '3.5.0' + run: | + LAST_RUN="coverage/.last_run.json" + if [ ! -f "$LAST_RUN" ]; then + mkdir -p badge + echo '{"schemaVersion":1,"label":"coverage","message":"unknown","color":"lightgrey"}' > badge/badge.json + exit 0 + fi + PERCENT=$(ruby -rjson -e "puts JSON.parse(File.read('$LAST_RUN')).dig('result','line').round(1)") + PERCENT_NUM=$(ruby -rjson -e "puts JSON.parse(File.read('$LAST_RUN')).dig('result','line')") + if ruby -e "exit(($PERCENT_NUM >= 90) ? 0 : 1)"; then COLOR="brightgreen" + elif ruby -e "exit(($PERCENT_NUM >= 75) ? 0 : 1)"; then COLOR="green" + elif ruby -e "exit(($PERCENT_NUM >= 60) ? 0 : 1)"; then COLOR="yellow" + else COLOR="red"; fi + mkdir -p badge + echo "{\"schemaVersion\":1,\"label\":\"coverage\",\"message\":\"${PERCENT}%\",\"color\":\"${COLOR}\"}" > badge/badge.json + + - name: Upload badge artifact + if: matrix.ruby == '3.4.0' && matrix.rails == '8.0.0' && matrix.activeadmin == '3.5.0' + uses: actions/upload-artifact@v4 + with: + name: coverage-badge + path: badge + + deploy-coverage: + needs: test + if: github.ref == 'refs/heads/master' && github.event_name == 'push' + runs-on: ubuntu-latest + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + + steps: + - name: Download coverage badge + uses: actions/download-artifact@v4 + with: + name: coverage-badge + path: coverage + + - name: Setup Pages + uses: actions/configure-pages@v5 + + - name: Upload Pages artifact + uses: actions/upload-pages-artifact@v3 + with: + path: coverage + + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v4 diff --git a/Gemfile b/Gemfile index e7b86ac..a54dcbc 100644 --- a/Gemfile +++ b/Gemfile @@ -10,6 +10,7 @@ gem 'sprockets-rails' gem 'sass-rails' group :test do + gem 'simplecov', require: false gem 'rspec-rails' gem 'sqlite3', '~> 2.0' gem 'database_cleaner' diff --git a/README.md b/README.md index 1facfb2..22bc15e 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,5 @@ [![Build Status](https://github.com/activeadmin-plugins/active_admin_scoped_collection_actions/actions/workflows/ci.yml/badge.svg)](https://github.com/activeadmin-plugins/active_admin_scoped_collection_actions/actions/workflows/ci.yml) +![Coverage](https://img.shields.io/endpoint?url=https://activeadmin-plugins.github.io/active_admin_scoped_collection_actions/badge.json) # ActiveAdmin Scoped Collection Actions diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 14f5a1e..5663c2f 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,3 +1,6 @@ +require 'simplecov' +SimpleCov.start + $LOAD_PATH.unshift(File.dirname(__FILE__)) $LOAD_PATH << File.expand_path('../support', __FILE__) From 44cc85c784a5cf82768660ba9d61b786d783d567 Mon Sep 17 00:00:00 2001 From: Igor Fedoronchuk Date: Tue, 7 Apr 2026 13:50:19 +0200 Subject: [PATCH 4/7] Bump version to 2.0.0 --- lib/active_admin_scoped_collection_actions/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/active_admin_scoped_collection_actions/version.rb b/lib/active_admin_scoped_collection_actions/version.rb index 3d83a1a..bf65707 100644 --- a/lib/active_admin_scoped_collection_actions/version.rb +++ b/lib/active_admin_scoped_collection_actions/version.rb @@ -1,3 +1,3 @@ module ActiveAdminScopedCollectionActions - VERSION = '1.0.1'.freeze + VERSION = '2.0.0'.freeze end From 1c2b7ca1382c0c4b3816a62cc200f939dbc56667 Mon Sep 17 00:00:00 2001 From: Igor Fedoronchuk Date: Tue, 7 Apr 2026 13:58:01 +0200 Subject: [PATCH 5/7] Fix Sprockets manifest error on Rails 8.0+ --- spec/support/rails_template.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/spec/support/rails_template.rb b/spec/support/rails_template.rb index a67827f..02fe183 100644 --- a/spec/support/rails_template.rb +++ b/spec/support/rails_template.rb @@ -1,5 +1,9 @@ # Rails template to build the sample app for specs +# Ensure Sprockets manifest exists (Rails 8.0+ no longer generates it) +FileUtils.mkdir_p("app/assets/config") +File.write("app/assets/config/manifest.js", "//= link_tree ../images\n") + generate :model, 'author name:string{10}:uniq last_name:string birthday:date --force' generate :model, 'post title:string:uniq body:text author:references --force' From 441c9f2b02575997fc02b6ea49ff6edfde7c036c Mon Sep 17 00:00:00 2001 From: Igor Fedoronchuk Date: Tue, 7 Apr 2026 13:59:59 +0200 Subject: [PATCH 6/7] Fix Ruby 3.4 nokogiri ABI mismatch in CI --- .github/workflows/ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e1f4f76..c084b8b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,7 +16,7 @@ jobs: strategy: fail-fast: false matrix: - ruby: ['3.2.0', '3.3.0', '3.4.0'] + ruby: ['3.2', '3.3', '3.4'] rails: ['7.1.0', '7.2.0', '8.0.0'] activeadmin: ['3.2.0', '3.3.0', '3.4.0', '3.5.0'] exclude: @@ -35,7 +35,7 @@ jobs: run: bundle exec rspec spec - name: Generate badge.json - if: matrix.ruby == '3.4.0' && matrix.rails == '8.0.0' && matrix.activeadmin == '3.5.0' + if: matrix.ruby == '3.4' && matrix.rails == '8.0.0' && matrix.activeadmin == '3.5.0' run: | LAST_RUN="coverage/.last_run.json" if [ ! -f "$LAST_RUN" ]; then @@ -53,7 +53,7 @@ jobs: echo "{\"schemaVersion\":1,\"label\":\"coverage\",\"message\":\"${PERCENT}%\",\"color\":\"${COLOR}\"}" > badge/badge.json - name: Upload badge artifact - if: matrix.ruby == '3.4.0' && matrix.rails == '8.0.0' && matrix.activeadmin == '3.5.0' + if: matrix.ruby == '3.4' && matrix.rails == '8.0.0' && matrix.activeadmin == '3.5.0' uses: actions/upload-artifact@v4 with: name: coverage-badge From 150c927b4a0b6e3887db94ffee5efbb3ab372148 Mon Sep 17 00:00:00 2001 From: Igor Fedoronchuk Date: Tue, 7 Apr 2026 14:05:30 +0200 Subject: [PATCH 7/7] Exclude spec/ from SimpleCov coverage statistics --- spec/spec_helper.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 5663c2f..1e1713d 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,5 +1,7 @@ require 'simplecov' -SimpleCov.start +SimpleCov.start do + add_filter '/spec/' +end $LOAD_PATH.unshift(File.dirname(__FILE__)) $LOAD_PATH << File.expand_path('../support', __FILE__)