Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 68 additions & 14 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,26 @@ name: CI
on:
pull_request:
push:
branches:
- master
branches: [master]

permissions:
contents: read
pages: write
id-token: write

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', '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:
- rails: '8.0.0'
activeadmin: '3.2.0'
env:
RAILS: ${{ matrix.rails }}
AA: ${{ matrix.activeadmin }}
Expand All @@ -26,8 +30,58 @@ jobs:
- uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true
- name: Run tests
run: bundle exec rspec spec

- name: Generate badge.json
if: matrix.ruby == '3.4' && matrix.rails == '8.0.0' && matrix.activeadmin == '3.5.0'
run: |
gem install bundler -v '< 2'
bundle install
bundle exec rspec spec
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' && 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
23 changes: 10 additions & 13 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,24 +1,21 @@
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.5.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 'simplecov', require: false
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 3 additions & 1 deletion active_admin_scoped_collection_actions.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion lib/active_admin_scoped_collection_actions/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module ActiveAdminScopedCollectionActions
VERSION = '1.0.1'.freeze
VERSION = '2.0.0'.freeze
end
8 changes: 6 additions & 2 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
require 'simplecov'
SimpleCov.start do
add_filter '/spec/'
end

$LOAD_PATH.unshift(File.dirname(__FILE__))
$LOAD_PATH << File.expand_path('../support', __FILE__)

Expand Down Expand Up @@ -29,15 +34,14 @@
require 'rspec/rails'
require 'capybara/rails'
require 'capybara/rspec'
require 'selenium-webdriver'

require 'support/admin'
require 'support/capybara'

RSpec.configure do |config|
config.use_transactional_fixtures = false

config.before(:suite) do
ActiveRecord::Migration.maintain_test_schema!
DatabaseCleaner.strategy = :truncation
DatabaseCleaner.clean_with(:truncation)
end
Expand Down
20 changes: 6 additions & 14 deletions spec/support/capybara.rb
Original file line number Diff line number Diff line change
@@ -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
43 changes: 18 additions & 25 deletions spec/support/rails_template.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
# 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'
# 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'

#Add validation
inject_into_file "app/models/author.rb", " validates_presence_of :name\n validates_uniqueness_of :last_name\n", after: "ApplicationRecord\n"
Expand All @@ -23,40 +27,29 @@
" 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'))

generate :'active_admin:install --skip-users'
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"
1 change: 1 addition & 0 deletions vendor/assets/javascripts/lib/dialog_mass_fields_update.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
Loading