Skip to content

Commit b3c0086

Browse files
authored
Merge pull request #207 from activeadmin-plugins/v6.0.0
Drop EOL versions, switch to Cuprite, modernize CI
2 parents 160a796 + d5c0524 commit b3c0086

File tree

9 files changed

+82
-94
lines changed

9 files changed

+82
-94
lines changed

.github/workflows/test.yml

Lines changed: 32 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,42 @@
1-
name: Test
2-
1+
name: CI
32
on:
4-
- push
5-
- pull_request
6-
3+
pull_request:
4+
push:
5+
branches: [master]
76
jobs:
8-
build:
7+
test:
8+
name: Ruby ${{ matrix.ruby }} / Rails ${{ matrix.rails }} / AA ${{ matrix.activeadmin }}
99
runs-on: ubuntu-latest
10-
1110
strategy:
11+
fail-fast: false
1212
matrix:
13-
ruby_version:
14-
- '2.6'
15-
- '2.7'
16-
- '3.0'
17-
rails_version:
18-
- '5.2.6'
19-
- '6.0.4'
20-
- '6.1.4'
21-
- '7.0.0'
22-
exclude:
23-
- ruby_version: '3.0'
24-
rails_version: '5.2.6'
25-
- ruby_version: '2.6'
26-
rails_version: '7.0.0'
27-
28-
name: Ruby ${{ matrix.ruby_version }} / Rails ${{ matrix.rails_version }}
29-
13+
ruby: ['3.2', '3.3', '3.4']
14+
rails: ['7.1.0', '7.2.0']
15+
activeadmin: ['3.2.0', '3.3.0']
3016
env:
31-
RAILS: ${{ matrix.rails_version }}
32-
17+
RAILS: ${{ matrix.rails }}
18+
AA: ${{ matrix.activeadmin }}
3319
steps:
34-
- uses: actions/checkout@v2
35-
36-
- name: Setup Ruby
37-
uses: ruby/setup-ruby@v1
20+
- uses: actions/checkout@v4
21+
- uses: ruby/setup-ruby@v1
3822
with:
39-
ruby-version: ${{ matrix.ruby_version }}
23+
ruby-version: ${{ matrix.ruby }}
4024
bundler-cache: true
41-
42-
- name: Test
25+
- name: Run tests
4326
run: bundle exec rspec spec
27+
coverage:
28+
name: Coverage
29+
runs-on: ubuntu-latest
30+
steps:
31+
- uses: actions/checkout@v4
32+
- uses: ruby/setup-ruby@v1
33+
with:
34+
ruby-version: '3.4'
35+
bundler-cache: true
36+
- name: Run tests with coverage
37+
run: bundle exec rspec spec
38+
- name: Upload coverage
39+
uses: actions/upload-artifact@v4
40+
with:
41+
name: coverage
42+
path: coverage/

Gemfile

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,20 @@
1-
# frozen_string_literal: true
21
source 'https://rubygems.org'
3-
4-
# Specify your gem's dependencies in active_admin_importable.gemspec
52
gemspec
63

4+
default_rails_version = '7.1.0'
5+
default_activeadmin_version = '3.2.0'
6+
7+
gem 'rails', "~> #{ENV['RAILS'] || default_rails_version}"
8+
gem 'activeadmin', "~> #{ENV['AA'] || default_activeadmin_version}"
9+
gem 'sprockets-rails'
10+
gem 'sass-rails'
711

812
group :test do
9-
default_rails_version = "~> 5.2.4"
10-
rails_version = ENV['RAILS'] || default_rails_version
11-
gem 'sassc-rails'
12-
gem 'rails', rails_version
13+
gem 'simplecov', require: false
1314
gem 'rspec-rails'
14-
gem 'coveralls', require: false # Test coverage website. Go to https://coveralls.io
15-
gem "sqlite3", "~> 1.4.0"
16-
gem 'launchy'
15+
gem 'sqlite3', '~> 2.0'
1716
gem 'database_cleaner'
1817
gem 'capybara'
19-
gem 'poltergeist'
20-
gem 'jquery-ui-rails', '~> 5.0'
18+
gem 'cuprite'
19+
gem 'webrick', require: false
2120
end

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
[![License ][license_badge]][license_link]
88

99

10-
The most fastest and efficient CSV import for Active Admin with support of validations, bulk inserts and encodings handling.
10+
The fastest and most efficient CSV import for Active Admin with support for validations, bulk inserts, and encoding handling.
1111

1212
For more about ActiveAdminImport installation and usage, check [Documentation website](http://activeadmin-plugins.github.io/active_admin_import/) and [Wiki pages](https://github.com/activeadmin-plugins/active_admin_import/wiki) for some specific cases and caveats.
1313

@@ -44,7 +44,7 @@ And then execute:
4444
#### Basic usage
4545

4646
```ruby
47-
ActiveAdmin.register Post
47+
ActiveAdmin.register Post do
4848
active_admin_import options
4949
end
5050
```
@@ -99,8 +99,8 @@ Tool | Description
9999
[codeclimate_link]: https://codeclimate.com/github/activeadmin-plugins/active_admin_import
100100
[rubygems_badge]: https://badge.fury.io/rb/active_admin_import.svg
101101
[rubygems_link]: https://rubygems.org/gems/active_admin_import
102-
[license_badge]: http://img.shields.io/:license-mit-blue.svg
103-
[license_link]: http://Fivell.mit-license.org
102+
[license_badge]: https://img.shields.io/:license-mit-blue.svg
103+
[license_link]: https://Fivell.mit-license.org
104104

105105

106106
## Contributing

Rakefile

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
1-
# frozen_string_literal: true
2-
require 'bundler'
1+
require "bundler"
32
require 'rake'
43
Bundler.setup
54
Bundler::GemHelper.install_tasks
6-
7-
# Import all our rake tasks
85
FileList['tasks/**/*.rake'].each { |task| import task }

active_admin_import.gemspec

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,16 @@ Gem::Specification.new do |gem|
77
gem.email = ['fedoronchuk@gmail.com']
88
gem.description = 'The most efficient way to import for Active Admin'
99
gem.summary = 'ActiveAdmin import based on activerecord-import gem.'
10-
gem.homepage = 'http://github.com/Fivell/active_admin_import'
10+
gem.homepage = 'https://github.com/activeadmin-plugins/active_admin_import'
1111
gem.license = 'MIT'
12+
gem.required_ruby_version = '>= 3.1.0'
1213
gem.files = `git ls-files`.split($OUTPUT_RECORD_SEPARATOR)
1314
gem.executables = gem.files.grep(%r{^bin/}).map { |f| File.basename(f) }
14-
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
1515
gem.name = 'active_admin_import'
1616
gem.require_paths = ['lib']
1717
gem.version = ActiveAdminImport::VERSION
1818
gem.add_runtime_dependency 'activerecord-import', '>= 0.27'
1919
gem.add_runtime_dependency 'rchardet', '>= 1.6'
2020
gem.add_runtime_dependency 'rubyzip', '>= 1.2'
21-
gem.add_dependency 'activeadmin', '>= 1.0.0'
21+
gem.add_dependency 'activeadmin', '>= 3.0', '< 4.0'
2222
end

spec/import_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def with_zipped_csv(name, &block)
2727
zip_file = File.expand_path("./spec/fixtures/files/#{name}.zip")
2828

2929
begin
30-
Zip::File.open(zip_file, Zip::File::CREATE) do |z|
30+
Zip::File.open(zip_file, create: true) do |z|
3131
z.add "#{name}.csv", File.expand_path("./spec/fixtures/files/#{name}.csv")
3232
end
3333
instance_eval &block

spec/spec_helper.rb

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
# frozen_string_literal: true
2-
require 'coveralls'
3-
Coveralls.wear!
1+
require 'simplecov'
2+
SimpleCov.start do
3+
add_filter '/spec/'
4+
end
45

56
$LOAD_PATH.unshift(File.dirname(__FILE__))
67
$LOAD_PATH << File.expand_path('../support', __FILE__)
@@ -10,44 +11,38 @@
1011
Bundler.setup
1112

1213
ENV['RAILS_ENV'] = 'test'
13-
# Ensure the Active Admin load path is happy
1414
require 'rails'
1515
ENV['RAILS'] = Rails.version
1616
ENV['RAILS_ROOT'] = File.expand_path("../rails/rails-#{ENV['RAILS']}", __FILE__)
17-
# Create the test app if it doesn't exists
1817
system 'rake setup' unless File.exist?(ENV['RAILS_ROOT'])
1918

2019
require 'active_model'
21-
# require ActiveRecord to ensure that Ransack loads correctly
2220
require 'active_record'
2321
require 'action_view'
2422
require 'active_admin'
2523
ActiveAdmin.application.load_paths = [ENV['RAILS_ROOT'] + '/app/admin']
2624
require ENV['RAILS_ROOT'] + '/config/environment.rb'
27-
# Disabling authentication in specs so that we don't have to worry about
28-
# it allover the place
2925
ActiveAdmin.application.authentication_method = false
3026
ActiveAdmin.application.current_user_method = false
3127

3228
require 'rspec/rails'
3329
require 'support/admin'
3430
require 'capybara/rails'
3531
require 'capybara/rspec'
36-
require 'capybara/poltergeist'
32+
require 'capybara/cuprite'
3733

38-
Capybara.register_driver :poltergeist do |app|
39-
Capybara::Poltergeist::Driver.new(app, js_errors: true,
40-
timeout: 80,
41-
debug: true,
42-
phantomjs_options: ['--debug=no', '--load-images=no'])
34+
Capybara.server = :webrick
35+
Capybara.register_driver :cuprite do |app|
36+
Capybara::Cuprite::Driver.new(app, headless: true, window_size: [1280, 800])
4337
end
44-
45-
Capybara.javascript_driver = :poltergeist
38+
Capybara.javascript_driver = :cuprite
39+
Capybara.default_max_wait_time = 5
4640

4741
RSpec.configure do |config|
4842
config.use_transactional_fixtures = false
4943

5044
config.before(:suite) do
45+
ActiveRecord::Migration.maintain_test_schema!
5146
DatabaseCleaner.strategy = :truncation
5247
DatabaseCleaner.clean_with(:truncation)
5348
end

spec/support/rails_template.rb

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,21 @@
1-
# frozen_string_literal: true
2-
# 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'
33

4-
generate :model, 'author name:string{10}:uniq last_name:string birthday:date'
5-
generate :model, 'post title:string:uniq body:text author:references'
6-
7-
# Add validation
84
inject_into_file 'app/models/author.rb', " validates_presence_of :name\n validates_uniqueness_of :last_name\n", before: 'end'
95
inject_into_file 'app/models/post.rb', " validates_presence_of :author\n", before: 'end'
106

11-
# Configure default_url_options in test environment
12-
inject_into_file 'config/environments/test.rb', " config.action_mailer.default_url_options = { :host => 'example.com' }\n", after: "config.cache_classes = true\n"
13-
14-
# Add our local Active Admin to the load path
15-
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__)"
16-
17-
run 'rm Gemfile'
7+
# Add our local Active Admin to the load path (Rails 7.1+)
8+
gsub_file "config/environment.rb",
9+
'require_relative "application"',
10+
"require_relative \"application\"\n$LOAD_PATH.unshift('#{File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'lib'))}')\nrequire \"active_admin\"\n"
1811

1912
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2013

2114
generate :'active_admin:install --skip-users'
2215
generate :'formtastic:install'
2316

24-
run 'rm -r test'
25-
run 'rm -r spec'
26-
17+
run 'rm -rf test'
2718
route "root :to => 'admin/dashboard#index'"
28-
2919
rake 'db:migrate'
20+
21+
run 'rm -f Gemfile Gemfile.lock'

tasks/test.rake

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
1-
# frozen_string_literal: true
2-
desc 'Creates a test rails app for the specs to run against'
1+
desc "Creates a test rails app for the specs to run against"
32
task :setup do
43
require 'rails/version'
5-
system('mkdir spec/rails') unless File.exist?('spec/rails')
6-
system "bundle exec rails new spec/rails/rails-#{Rails::VERSION::STRING} -m spec/support/rails_template.rb --skip-spring --skip-turbolinks --skip-bootsnap"
4+
5+
rails_new_opts = %w(
6+
--skip-turbolinks
7+
--skip-spring
8+
--skip-bootsnap
9+
-m
10+
spec/support/rails_template.rb
11+
)
12+
system "bundle exec rails new spec/rails/rails-#{Rails::VERSION::STRING} #{rails_new_opts.join(' ')}"
713
end

0 commit comments

Comments
 (0)