Skip to content

Commit 4ac23ee

Browse files
committed
rails 5 support
1 parent 311c351 commit 4ac23ee

5 files changed

Lines changed: 29 additions & 10 deletions

File tree

.travis.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,21 @@ env:
44
- RAILS=4.0.13
55
- RAILS=4.1.15
66
- RAILS=4.2.6
7+
- RAILS=5.0.0
78
rvm:
89
- 1.9.3
910
- 2.0.0
1011
- 2.1.9
1112
- 2.2.5
1213
- 2.3.1
14+
matrix:
15+
exclude:
16+
- rvm: 1.9.3
17+
env: RAILS=5.0.0
18+
- rvm: 2.0.0
19+
env: RAILS=5.0.0
20+
- rvm: 2.1.9
21+
env: RAILS=5.0.0
1322
before_install:
1423
- gem install bundler -v '= 1.9.3'
1524
- gem update --system

Gemfile

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,29 @@ source 'https://rubygems.org'
22

33
# Specify your gem's dependencies in active_admin_importable.gemspec
44
gemspec
5+
default_rails_version = '4.2.6'
6+
rails_version = ENV['RAILS'] || default_rails_version
7+
rails_major = rails_version[0]
8+
59
group :test do
6-
default_rails_version = '4.2.6'
7-
gem 'sprockets-rails', '2.3.3'
8-
gem 'rails', "#{ENV['RAILS'] || default_rails_version}"
10+
11+
gem 'rails', rails_version
12+
if rails_major == '5'
13+
gem 'inherited_resources', github: 'activeadmin/inherited_resources'
14+
gem 'activeadmin', github: 'activeadmin/activeadmin'
15+
else
16+
gem 'activeadmin', '1.0.0.pre4'
17+
end
18+
919
gem 'rspec-rails'
10-
gem 'activeadmin', github: 'activeadmin' , ref: 'd787029e5523be2eb2ed99816eb0cecca2b72862'
1120
gem 'coveralls', require: false # Test coverage website. Go to https://coveralls.io
12-
gem 'sass-rails'
1321
gem 'sqlite3'
1422
gem 'launchy'
1523
gem 'database_cleaner'
1624
gem 'capybara'
1725
gem 'selenium-webdriver'
1826
gem 'poltergeist'
19-
gem 'json', '~> 1.8', platforms: :ruby_19 # Json 2.0 requires Ruby >= 2.0
27+
gem 'json', '< 2.0', platforms: :ruby_19 # Json 2.0 requires Ruby >= 2.0
2028
gem 'mime-types', '< 3.0.0', platforms: [:ruby_19, :ruby_20]
29+
gem 'tins', '< 1.3.4', platforms: :ruby_19
2130
end

lib/active_admin_import/dsl.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@ def active_admin_import(options = {}, &block)
6363

6464
collection_action :do_import, method: :post do
6565
authorize!(ActiveAdminImport::Auth::IMPORT, active_admin_config.resource_class)
66-
66+
_params = params.respond_to?(:to_unsafe_h) ? params.to_unsafe_h : params
67+
params = ActiveSupport::HashWithIndifferentAccess.new _params
6768
@active_admin_import_model = options[:template_object]
6869
@active_admin_import_model.assign_attributes(params[params_key].try(:deep_symbolize_keys) || {})
6970
#go back to form

spec/support/rails_template.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
generate :model, 'post title:string:uniq body:text author:references'
55

66
#Add validation
7-
inject_into_file "app/models/author.rb", " validates_presence_of :name\n validates_uniqueness_of :last_name\n", after: "Base\n"
8-
inject_into_file "app/models/post.rb", " validates_presence_of :author\n", after: ":author\n"
7+
inject_into_file "app/models/author.rb", " validates_presence_of :name\n validates_uniqueness_of :last_name\n", before: "end"
8+
inject_into_file "app/models/post.rb", " validates_presence_of :author\n", before: "end"
99

1010
# Configure default_url_options in test environment
1111
inject_into_file "config/environments/test.rb", " config.action_mailer.default_url_options = { :host => 'example.com' }\n", after: "config.cache_classes = true\n"

tasks/test.rake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ desc "Creates a test rails app for the specs to run against"
22
task :setup do
33
require 'rails/version'
44
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"
5+
system "bundle exec rails new spec/rails/rails-#{Rails::VERSION::STRING} -m spec/support/rails_template.rb --skip-spring --skip-turbolinks"
66
end

0 commit comments

Comments
 (0)