Skip to content

Commit 85ee22b

Browse files
committed
Drop EOL versions, switch to Cuprite, modernize CI
- Require Ruby >= 3.1, Rails >= 7.1, ActiveAdmin >= 3.0 - Replace chromedriver-helper with Cuprite - Replace Travis CI with GitHub Actions - Add ransackable_attributes for Ransack 4+ - Fix Rails 7.1 config/environment.rb template
1 parent 18b38b0 commit 85ee22b

10 files changed

Lines changed: 83 additions & 86 deletions

File tree

.github/workflows/ci.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: CI
2+
on:
3+
pull_request:
4+
push:
5+
branches: [master]
6+
jobs:
7+
test:
8+
name: Ruby ${{ matrix.ruby }} / Rails ${{ matrix.rails }} / AA ${{ matrix.activeadmin }}
9+
runs-on: ubuntu-latest
10+
strategy:
11+
fail-fast: false
12+
matrix:
13+
ruby: ['3.2.0', '3.3.0', '3.4.0']
14+
rails: ['7.1.0', '7.2.0']
15+
activeadmin: ['3.2.0', '3.3.0']
16+
env:
17+
RAILS: ${{ matrix.rails }}
18+
AA: ${{ matrix.activeadmin }}
19+
steps:
20+
- uses: actions/checkout@v4
21+
- uses: ruby/setup-ruby@v1
22+
with:
23+
ruby-version: ${{ matrix.ruby }}
24+
bundler-cache: true
25+
- name: Run tests
26+
run: bundle exec rspec spec

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/.bundle/
2+
/Gemfile.lock
3+
/pkg/
4+
/tmp/
5+
spec/rails/rails-*

.travis.yml

Lines changed: 0 additions & 23 deletions
This file was deleted.

Gemfile

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
11
source 'https://rubygems.org'
2-
3-
# Specify your gem's dependencies in activeadmin_scoped_collection_actions.gemspec
42
gemspec
53

6-
group :test do
7-
gem 'rails', "~> #{ENV['RAILS'] || '5.2.1'}"
8-
gem 'activeadmin', "~> #{ENV['AA'] || '1.3.1'}"
4+
default_rails_version = '7.1.0'
5+
default_activeadmin_version = '3.2.0'
96

7+
gem 'rails', "~> #{ENV['RAILS'] || default_rails_version}"
8+
gem 'activeadmin', "~> #{ENV['AA'] || default_activeadmin_version}"
9+
gem 'sprockets-rails'
10+
gem 'sass-rails'
11+
12+
group :test do
1013
gem 'rspec-rails'
11-
gem 'sqlite3'
14+
gem 'sqlite3', '~> 2.0'
1215
gem 'database_cleaner'
1316
gem 'capybara'
14-
gem 'selenium-webdriver'
15-
gem 'chromedriver-helper'
16-
gem 'byebug'
17-
gem 'sassc-rails'
17+
gem 'cuprite'
18+
gem 'webrick', require: false
1819
end

Rakefile

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,4 @@ require "bundler"
22
require 'rake'
33
Bundler.setup
44
Bundler::GemHelper.install_tasks
5-
6-
# Import all our rake tasks
75
FileList['tasks/**/*.rake'].each { |task| import task }

active_admin_sidebar.gemspec

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- encoding: utf-8 -*-
21
$:.push File.expand_path("../lib", __FILE__)
32
require "active_admin_sidebar/version"
43

@@ -7,15 +6,17 @@ Gem::Specification.new do |s|
76
s.version = ActiveAdminSidebar::VERSION
87
s.authors = ["Igor"]
98
s.email = ["fedoronchuk@gmail.com"]
10-
s.homepage = "https://github.com/Fivell/active_admin_sidebar"
9+
s.homepage = "https://github.com/activeadmin-plugins/active_admin_sidebar"
1110
s.summary = %q{active_admin_sidebar gem}
1211
s.description = %q{extension for activeadmin gem to manage sidebar}
12+
s.license = "MIT"
1313

14-
s.add_dependency "activeadmin"
14+
s.required_ruby_version = '>= 3.1.0'
1515

1616
s.files = `git ls-files`.split("\n")
1717
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
1818
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
1919
s.require_paths = ["lib"]
2020

21+
s.add_dependency "activeadmin", ">= 3.0", "< 4.0"
2122
end

spec/spec_helper.rb

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,28 +6,23 @@
66
Bundler.setup
77

88
ENV['RAILS_ENV'] = 'test'
9-
# Ensure the Active Admin load path is happy
109
require 'rails'
1110
ENV['RAILS'] = Rails.version
1211
ENV['RAILS_ROOT'] = File.expand_path("../rails/rails-#{ENV['RAILS']}", __FILE__)
13-
# Create the test app if it doesn't exists
14-
unless File.exists?(ENV['RAILS_ROOT'])
12+
unless File.exist?(ENV['RAILS_ROOT'])
1513
system 'rake setup'
1614
end
1715

1816
require 'rails/all'
1917
require 'active_admin'
2018
ActiveAdmin.application.load_paths = [ENV['RAILS_ROOT'] + "/app/admin"]
2119
require ENV['RAILS_ROOT'] + '/config/environment.rb'
22-
# Disabling authentication in specs so that we don't have to worry about
23-
# it allover the place
2420
ActiveAdmin.application.authentication_method = false
2521
ActiveAdmin.application.current_user_method = false
2622

2723
require 'rspec/rails'
2824
require 'capybara/rails'
2925
require 'capybara/rspec'
30-
require 'selenium-webdriver'
3126

3227
require 'support/admin'
3328
require 'support/capybara'
@@ -36,6 +31,7 @@
3631
config.use_transactional_fixtures = false
3732

3833
config.before(:suite) do
34+
ActiveRecord::Migration.maintain_test_schema!
3935
DatabaseCleaner.strategy = :truncation
4036
DatabaseCleaner.clean_with(:truncation)
4137
end
@@ -46,5 +42,4 @@
4642
config.after(:each) do
4743
DatabaseCleaner.clean
4844
end
49-
5045
end

spec/support/capybara.rb

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,8 @@
1-
Capybara.configure do |config|
2-
config.match = :prefer_exact
3-
end
4-
5-
Capybara.register_driver :selenium_chrome do |app|
6-
options = Selenium::WebDriver::Chrome::Options.new(
7-
args: %w[headless disable-gpu no-sandbox]
8-
)
9-
Capybara::Selenium::Driver.new(app, browser: :chrome, options: options)
10-
end
1+
require 'capybara/cuprite'
112

123
Capybara.server = :webrick
13-
Capybara.javascript_driver = :selenium_chrome
4+
Capybara.register_driver :cuprite do |app|
5+
Capybara::Cuprite::Driver.new(app, headless: true, window_size: [1280, 800])
6+
end
7+
Capybara.javascript_driver = :cuprite
8+
Capybara.default_max_wait_time = 5

spec/support/rails_template.rb

Lines changed: 29 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,29 @@
1-
# Rails template to build the sample app for specs
1+
generate :model, 'author name:string{10}:uniq last_name:string birthday:date --force'
2+
generate :model, 'post title:string:uniq body:text author:references --force'
23

3-
generate :model, 'author name:string{10}:uniq last_name:string birthday:date'
4-
generate :model, 'post title:string:uniq body:text author:references'
5-
6-
#Add validation
7-
inject_into_file "app/models/author.rb", " validates_presence_of :name\n validates_uniqueness_of :last_name\n", after: "Base\n"
4+
inject_into_file "app/models/author.rb", " validates_presence_of :name\n validates_uniqueness_of :last_name\n", after: "ApplicationRecord\n"
85
inject_into_file "app/models/post.rb", " validates_presence_of :author\n", after: ":author\n"
96

10-
# Configure default_url_options in test environment
11-
inject_into_file "config/environments/test.rb", " config.action_mailer.default_url_options = { :host => 'example.com' }\n", after: "config.cache_classes = true\n"
12-
13-
# Add our local Active Admin to the load path
14-
inject_into_file "config/environment.rb",
15-
"\n$LOAD_PATH.unshift('#{File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'lib'))}')\nrequire \"active_admin\"\n",
16-
after: "require File.expand_path('../application', __FILE__)"
17-
18-
run "rm Gemfile"
7+
# Add ransackable_attributes for Ransack 4+
8+
inject_into_file "app/models/author.rb",
9+
" def self.ransackable_attributes(auth_object = nil)\n" \
10+
" [\"name\", \"last_name\", \"birthday\", \"created_at\", \"updated_at\"]\n" \
11+
" end\n",
12+
after: "ApplicationRecord\n"
13+
14+
inject_into_file "app/models/post.rb",
15+
" def self.ransackable_attributes(auth_object = nil)\n" \
16+
" [\"title\", \"body\", \"author_id\"]\n" \
17+
" end\n" \
18+
" def self.ransackable_associations(auth_object = nil)\n" \
19+
" [\"author\"]\n" \
20+
" end\n",
21+
after: "ApplicationRecord\n"
22+
23+
# Add our local Active Admin to the load path (Rails 7.1+)
24+
gsub_file "config/environment.rb",
25+
'require_relative "application"',
26+
"require_relative \"application\"\n$LOAD_PATH.unshift('#{File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'lib'))}')\nrequire \"active_admin\"\n"
1927

2028
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2129

@@ -31,19 +39,12 @@
3139
"@import \"active_admin_sidebar\";\n",
3240
after: "@import \"active_admin/base\";\n"
3341

34-
if File.file?("app/assets/javascripts/active_admin.js")
35-
inject_into_file "app/assets/javascripts/active_admin.js",
36-
"//= require active_admin_sidebar\n",
37-
after: "//= require active_admin/base\n"
38-
else
39-
inject_into_file "app/assets/javascripts/active_admin.js.coffee",
40-
"#= require active_admin_sidebar\n",
41-
after: "#= require active_admin/base\n"
42-
end
43-
44-
run "rm -r test"
45-
run "rm -r spec"
42+
inject_into_file "app/assets/javascripts/active_admin.js",
43+
"//= require active_admin_sidebar\n",
44+
after: "//= require active_admin/base\n"
4645

46+
run "rm -rf test"
4747
route "root :to => 'admin/dashboard#index'"
48-
4948
rake "db:migrate"
49+
50+
run "rm -f Gemfile Gemfile.lock"

tasks/test.rake

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
desc "Creates a test rails app for the specs to run against"
22
task :setup do
33
require 'rails/version'
4-
system("mkdir spec/rails") unless File.exists?("spec/rails")
54

65
rails_new_opts = %w(
76
--skip-turbolinks
87
--skip-spring
98
--skip-bootsnap
10-
--skip-webpack-install
119
-m
1210
spec/support/rails_template.rb
1311
)

0 commit comments

Comments
 (0)