Skip to content

Commit 588af96

Browse files
authored
Merge pull request #34 from workgena/aa2.0_compatibility
Prepare for ActiveAdmin 2.0
2 parents a6311e6 + 3289329 commit 588af96

File tree

8 files changed

+81
-56
lines changed

8 files changed

+81
-56
lines changed

.travis.yml

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,22 @@
1+
sudo: required
2+
3+
language: ruby
4+
5+
addons:
6+
chrome: stable
7+
8+
before_install:
9+
- gem uninstall -v '>= 2' -i $(rvm gemdir)@global -ax bundler || true
10+
- gem install bundler -v '< 2'
11+
112
script: bundle exec rspec spec
13+
14+
env:
15+
matrix:
16+
- RAILS=4.2.0 AA=1.1.0
17+
- RAILS=5.2.0 AA=1.4.0
18+
- RAILS=5.2.0 AA=2.0.0
19+
220
rvm:
3-
- 2.2.7
4-
- 2.3.4
5-
before_install:
6-
- gem install bundler -v '= 1.9.3'
7-
- gem update --system
8-
- gem --version
21+
- 2.4.6
22+
- 2.6.3

Gemfile

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
11
source 'https://rubygems.org'
22

3-
# Specify your gem's dependencies in activeadmin_scoped_collection_actions.gemspec
43
gemspec
4+
55
group :test do
6-
gem 'sprockets-rails', '2.3.3'
7-
gem 'rails', '~> 5.1'
8-
gem 'rspec-rails'
6+
gem 'activeadmin', "~> #{ENV['AA'] || '1.4.3'}"
7+
gem 'rails', "~> #{ENV['RAILS'] || '4.2.11'}"
8+
9+
gem 'capybara'
10+
gem 'chromedriver-helper'
11+
gem 'coveralls', require: false # Test coverage website. Go to https://coveralls.io
12+
gem 'database_cleaner'
913
gem 'draper'
10-
gem 'activeadmin', '1.0.0'
11-
gem 'sass-rails'
12-
gem 'sqlite3'
1314
gem 'launchy'
14-
gem 'database_cleaner'
15-
gem 'capybara'
15+
gem 'rspec-rails'
16+
gem 'sass-rails'
1617
gem 'selenium-webdriver'
17-
gem 'poltergeist'
18+
gem 'sqlite3', '~> 1.3.6'
1819
end

active_admin_scoped_collection_actions.gemspec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@ Gem::Specification.new do |spec|
1717
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
1818
spec.require_paths = ["lib"]
1919

20-
spec.add_development_dependency "bundler", "~> 1.8"
21-
spec.add_development_dependency "rake", "~> 10.0"
20+
spec.add_dependency "coffee-rails"
21+
spec.add_dependency "activeadmin", ">= 1.1", "< 3.a"
2222
end

spec/authors_actions_spec.rb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -79,14 +79,16 @@
7979

8080

8181
context 'perform Delete-action when cheked only one item' do
82-
8382
let(:delete_author) { Author.first }
8483

8584
before do
86-
page.find('#collection_actions_sidebar_section button', text: 'Delete').click
87-
page.find("#batch_action_item_#{delete_author.id}").trigger('click')
88-
page.within ('body>.active_admin_dialog_mass_update_by_filter') do
89-
page.find('button', text: 'OK').click
85+
# select one item
86+
find("#batch_action_item_#{delete_author.id}", visible: true).click
87+
# click "Delete batch"
88+
find('#collection_actions_sidebar_section button', text: 'Delete').click
89+
# confirm deletion
90+
within 'body > .active_admin_dialog_mass_update_by_filter' do
91+
find('button', text: 'OK').click
9092
end
9193
end
9294

@@ -96,7 +98,5 @@
9698
expect(Author.take.id).not_to eq(delete_author.id)
9799
expect(page).to have_css("#batch_action_item_#{Author.take.id}")
98100
end
99-
100101
end
101-
102102
end

spec/spec_helper.rb

Lines changed: 7 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,36 +2,36 @@
22
$LOAD_PATH << File.expand_path('../support', __FILE__)
33

44
ENV['BUNDLE_GEMFILE'] = File.expand_path('../../Gemfile', __FILE__)
5-
require "bundler"
5+
require 'bundler'
66
Bundler.setup
77

88
ENV['RAILS_ENV'] = 'test'
99
# Ensure the Active Admin load path is happy
1010
require 'rails'
1111
ENV['RAILS'] = Rails.version
1212
ENV['RAILS_ROOT'] = File.expand_path("../rails/rails-#{ENV['RAILS']}", __FILE__)
13+
1314
# Create the test app if it doesn't exists
14-
unless File.exists?(ENV['RAILS_ROOT'])
15-
system 'rake setup'
16-
end
15+
system 'rake setup' unless File.exist?(ENV['RAILS_ROOT'])
1716

1817
require 'active_model'
1918
# require ActiveRecord to ensure that Ransack loads correctly
2019
require 'active_record'
2120
require 'active_admin'
22-
ActiveAdmin.application.load_paths = [ENV['RAILS_ROOT'] + "/app/admin"]
21+
ActiveAdmin.application.load_paths = [ENV['RAILS_ROOT'] + '/app/admin']
2322
require ENV['RAILS_ROOT'] + '/config/environment.rb'
2423
# Disabling authentication in specs so that we don't have to worry about
2524
# it allover the place
2625
ActiveAdmin.application.authentication_method = false
2726
ActiveAdmin.application.current_user_method = false
2827

2928
require 'rspec/rails'
30-
require 'support/admin'
3129
require 'capybara/rails'
3230
require 'capybara/rspec'
33-
require 'capybara/poltergeist'
31+
require 'selenium-webdriver'
3432

33+
require 'support/admin'
34+
require 'support/capybara'
3535

3636
RSpec.configure do |config|
3737
config.use_transactional_fixtures = false
@@ -47,22 +47,4 @@
4747
config.after(:each) do
4848
DatabaseCleaner.clean
4949
end
50-
51-
end
52-
53-
# RSpec.configure do |config|
54-
# config.before(:each, js: true) do
55-
# page.driver.browser.manage.window.maximize if page.driver.browser.respond_to?(:manage)
56-
# end
57-
# end
58-
# Capybara.javascript_driver = :selenium
59-
60-
Capybara.register_driver :poltergeist do |app|
61-
Capybara::Poltergeist::Driver.new(app, {
62-
js_errors: true,
63-
timeout: 80,
64-
debug: true,
65-
:phantomjs_options => ['--debug=no', '--load-images=no']
66-
})
6750
end
68-
Capybara.javascript_driver = :poltergeist

spec/support/capybara.rb

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

spec/support/rails_template.rb

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,15 @@
2828
"@import \"active_admin_scoped_collection_actions\";\n",
2929
after: "@import \"active_admin/base\";\n"
3030

31-
inject_into_file "app/assets/javascripts/active_admin.js.coffee",
32-
"#= require active_admin_scoped_collection_actions\n",
33-
after: "#= require active_admin/base\n"
31+
if File.file?("app/assets/javascripts/active_admin.js.coffee")
32+
inject_into_file "app/assets/javascripts/active_admin.js.coffee",
33+
"#= require active_admin_scoped_collection_actions\n",
34+
after: "#= require active_admin/base\n"
35+
else
36+
inject_into_file "app/assets/javascripts/active_admin.js",
37+
"//= require active_admin_scoped_collection_actions\n",
38+
after: "//= require active_admin/base\n"
39+
end
3440

3541
run "rm -r test"
3642
run "rm -r spec"

tasks/test.rake

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
1-
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'
22
task :setup do
33
require 'rails/version'
4-
system("mkdir spec/rails") unless File.exists?("spec/rails")
5-
system "bundle exec rails new spec/rails/rails-#{Rails::VERSION::STRING} -m spec/support/rails_template.rb --skip-spring"
4+
5+
rails_new_args = %w[
6+
--skip-turbolinks
7+
--skip-spring
8+
--skip-bootsnap
9+
-m
10+
spec/support/rails_template.rb
11+
].join(' ')
12+
13+
system "bundle exec rails new spec/rails/rails-#{Rails::VERSION::STRING} #{rails_new_args}"
614
end

0 commit comments

Comments
 (0)