Skip to content

Commit

Permalink
Merge pull request #43 from oskarpearson/replace-travis-with-github-a…
Browse files Browse the repository at this point in the history
…ctions

Replace travis with github actions, add ActiveAdmin 3 support
  • Loading branch information
workgena authored Mar 2, 2024
2 parents 090d4e5 + 4afdb04 commit 73a489d
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 29 deletions.
44 changes: 44 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: CI
on:
pull_request:
push:
branches:
- master
jobs:
test:
name: Tests with Ruby ${{ matrix.ruby }} Rails ${{ matrix.rails }} Active Admin ${{ matrix.activeadmin }}
runs-on: ubuntu-latest
strategy:
matrix:
ruby:
- '3.0.0'
- '3.1.0'
- '3.2.0'
- '3.3.0'
rails:
- '6.1.0'
- '7.0.0'
- '7.1.0'
activeadmin:
- '2.14.0'
- '3.0.0'
- '3.1.0'
- '3.2.0'
exclude:
- rails: '7.1.0'
activeadmin: '2.14.0'
- rails: '7.1.0'
activeadmin: '3.0.0'
env:
RAILS: ${{ matrix.rails }}
AA: ${{ matrix.activeadmin }}
steps:
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
- name: Run tests
run: |
gem install bundler -v '< 2'
bundle install
bundle exec rspec spec
22 changes: 0 additions & 22 deletions .travis.yml

This file was deleted.

12 changes: 8 additions & 4 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,15 @@ source 'https://rubygems.org'
gemspec

group :test do
gem 'rails', "~> #{ENV['RAILS'] || '6.0.0'}"
gem 'activeadmin', "~> #{ENV['AA'] || '2.6.0'}"
default_rails_version = '7.1.0'
default_activeadmin_version = '3.2.0'

gem 'sprockets-rails', '3.0.4'
gem 'rails', "~> #{ENV['RAILS'] || default_rails_version}"
gem 'activeadmin', "~> #{ENV['AA'] || default_activeadmin_version}"

gem 'sprockets-rails'
gem 'rspec-rails'
gem 'coveralls', require: false # Test coverage website. Go to https://coveralls.io
gem 'coveralls_reborn', require: false
gem 'sass-rails'
gem 'sqlite3', '~> 1.4.0'
gem 'launchy'
Expand All @@ -17,4 +20,5 @@ group :test do
gem 'webdrivers'
gem 'byebug'
gem 'draper'
gem 'webrick', require: false
end
2 changes: 1 addition & 1 deletion active_admin_scoped_collection_actions.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ Gem::Specification.new do |spec|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
spec.require_paths = ["lib"]

spec.add_dependency "activeadmin", ">= 1.1", "< 3.a"
spec.add_dependency "activeadmin", ">= 1.1", "< 4.0"
end
2 changes: 2 additions & 0 deletions spec/support/capybara.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
config.match = :prefer_exact
end

Webdrivers::Chromedriver.update

Capybara.register_driver :selenium_chrome do |app|
options = Selenium::WebDriver::Chrome::Options.new(
args: %w[headless disable-gpu no-sandbox]
Expand Down
20 changes: 18 additions & 2 deletions spec/support/rails_template.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,24 @@
generate :model, 'post title:string:uniq body:text author:references'

#Add validation
inject_into_file "app/models/author.rb", " validates_presence_of :name\n validates_uniqueness_of :last_name\n", after: "Base\n"
inject_into_file "app/models/post.rb", " validates_presence_of :author\n", after: ":author\n"
inject_into_file "app/models/author.rb", " validates_presence_of :name\n validates_uniqueness_of :last_name\n", after: "ApplicationRecord\n"
inject_into_file "app/models/post.rb", " validates_presence_of :author\n", after: ":author\n"

# Add ransackable_attributes
inject_into_file "app/models/author.rb",
" def self.ransackable_attributes(auth_object = nil)\n" \
" [\"name\", \"last_name\", \"birthday\"]\n" \
" end\n",
after: "ApplicationRecord\n"

inject_into_file "app/models/post.rb",
" def self.ransackable_attributes(auth_object = nil)\n" \
" [\"title\", \"body\", \"author_id\"]\n" \
" end\n" \
" def self.ransackable_associations(auth_object = nil)\n" \
" [\"author\"]\n" \
" 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"
Expand Down

0 comments on commit 73a489d

Please sign in to comment.