active_admin_import 3.0.0.pre → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +43 -0
- data/.travis.yml +14 -6
- data/Gemfile +8 -8
- data/README.md +25 -33
- data/Rakefile +3 -2
- data/active_admin_import.gemspec +14 -17
- data/config/locales/fr.yml +23 -0
- data/config/locales/ja.yml +24 -0
- data/config/locales/ko.yml +23 -0
- data/config/locales/pt-BR.yml +23 -0
- data/config/locales/ru.yml +27 -0
- data/config/locales/uk.yml +27 -0
- data/lib/active_admin_import.rb +1 -2
- data/lib/active_admin_import/authorization.rb +1 -0
- data/lib/active_admin_import/dsl.rb +57 -41
- data/lib/active_admin_import/engine.rb +2 -3
- data/lib/active_admin_import/import_result.rb +9 -8
- data/lib/active_admin_import/importer.rb +18 -18
- data/lib/active_admin_import/model.rb +47 -36
- data/lib/active_admin_import/options.rb +34 -33
- data/lib/active_admin_import/version.rb +2 -1
- data/spec/fixtures/files/authors_with_tabs.tsv +3 -0
- data/spec/import_result_spec.rb +15 -9
- data/spec/import_spec.rb +148 -137
- data/spec/model_spec.rb +4 -3
- data/spec/spec_helper.rb +13 -25
- data/spec/support/active_model_lint.rb +5 -4
- data/spec/support/admin.rb +5 -9
- data/spec/support/rails_template.rb +10 -10
- data/tasks/test.rake +5 -4
- metadata +25 -24
- data/.hound.yml +0 -4
data/spec/model_spec.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
require 'coveralls'
|
2
3
|
Coveralls.wear!
|
3
4
|
|
@@ -5,27 +6,23 @@ $LOAD_PATH.unshift(File.dirname(__FILE__))
|
|
5
6
|
$LOAD_PATH << File.expand_path('../support', __FILE__)
|
6
7
|
|
7
8
|
ENV['BUNDLE_GEMFILE'] = File.expand_path('../../Gemfile', __FILE__)
|
8
|
-
require
|
9
|
+
require 'bundler'
|
9
10
|
Bundler.setup
|
10
11
|
|
11
|
-
ENV['RAILS'] = '4.1.9'
|
12
|
-
|
13
12
|
ENV['RAILS_ENV'] = 'test'
|
13
|
+
# Ensure the Active Admin load path is happy
|
14
|
+
require 'rails'
|
15
|
+
ENV['RAILS'] = Rails.version
|
14
16
|
ENV['RAILS_ROOT'] = File.expand_path("../rails/rails-#{ENV['RAILS']}", __FILE__)
|
15
|
-
|
16
17
|
# Create the test app if it doesn't exists
|
17
|
-
unless File.
|
18
|
-
system 'rake setup'
|
19
|
-
end
|
18
|
+
system 'rake setup' unless File.exist?(ENV['RAILS_ROOT'])
|
20
19
|
|
21
|
-
# Ensure the Active Admin load path is happy
|
22
|
-
require 'rails'
|
23
20
|
require 'active_model'
|
21
|
+
# require ActiveRecord to ensure that Ransack loads correctly
|
22
|
+
require 'active_record'
|
24
23
|
require 'active_admin'
|
25
|
-
ActiveAdmin.application.load_paths = [ENV['RAILS_ROOT'] +
|
26
|
-
|
24
|
+
ActiveAdmin.application.load_paths = [ENV['RAILS_ROOT'] + '/app/admin']
|
27
25
|
require ENV['RAILS_ROOT'] + '/config/environment.rb'
|
28
|
-
|
29
26
|
# Disabling authentication in specs so that we don't have to worry about
|
30
27
|
# it allover the place
|
31
28
|
ActiveAdmin.application.authentication_method = false
|
@@ -37,23 +34,15 @@ require 'capybara/rails'
|
|
37
34
|
require 'capybara/rspec'
|
38
35
|
require 'capybara/poltergeist'
|
39
36
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
37
|
Capybara.register_driver :poltergeist do |app|
|
44
|
-
Capybara::Poltergeist::Driver.new(app,
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
:phantomjs_options => ['--debug=no', '--load-images=no']
|
49
|
-
|
50
|
-
})
|
38
|
+
Capybara::Poltergeist::Driver.new(app, js_errors: true,
|
39
|
+
timeout: 80,
|
40
|
+
debug: true,
|
41
|
+
phantomjs_options: ['--debug=no', '--load-images=no'])
|
51
42
|
end
|
52
43
|
|
53
|
-
|
54
44
|
Capybara.javascript_driver = :poltergeist
|
55
45
|
|
56
|
-
|
57
46
|
RSpec.configure do |config|
|
58
47
|
config.use_transactional_fixtures = false
|
59
48
|
|
@@ -69,4 +58,3 @@ RSpec.configure do |config|
|
|
69
58
|
DatabaseCleaner.clean
|
70
59
|
end
|
71
60
|
end
|
72
|
-
|
@@ -1,9 +1,10 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
shared_examples_for 'ActiveModel' do
|
2
3
|
include ActiveModel::Lint::Tests
|
3
4
|
|
4
5
|
# to_s is to support ruby-1.9
|
5
|
-
ActiveModel::Lint::Tests.public_instance_methods.map
|
6
|
-
example m.
|
6
|
+
ActiveModel::Lint::Tests.public_instance_methods.map(&:to_s).grep(/^test/).each do |m|
|
7
|
+
example m.tr('_', ' ') do
|
7
8
|
send m
|
8
9
|
end
|
9
10
|
end
|
@@ -11,4 +12,4 @@ shared_examples_for "ActiveModel" do
|
|
11
12
|
def model
|
12
13
|
subject
|
13
14
|
end
|
14
|
-
end
|
15
|
+
end
|
data/spec/support/admin.rb
CHANGED
@@ -1,20 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
def add_author_resource(options = {}, &block)
|
2
|
-
|
3
3
|
ActiveAdmin.register Author do
|
4
|
-
|
5
|
-
|
4
|
+
config.filters = false
|
5
|
+
active_admin_import(options, &block)
|
6
6
|
end
|
7
7
|
Rails.application.reload_routes!
|
8
|
-
|
9
8
|
end
|
10
9
|
|
11
|
-
|
12
10
|
def add_post_resource(options = {}, &block)
|
13
|
-
|
14
11
|
ActiveAdmin.register Post do
|
15
|
-
|
16
|
-
|
12
|
+
config.filters = false
|
13
|
+
active_admin_import(options, &block)
|
17
14
|
end
|
18
15
|
Rails.application.reload_routes!
|
19
|
-
|
20
16
|
end
|
@@ -1,29 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
# Rails template to build the sample app for specs
|
2
3
|
|
3
4
|
generate :model, 'author name:string{10}:uniq last_name:string birthday:date'
|
4
5
|
generate :model, 'post title:string:uniq body:text author:references'
|
5
6
|
|
6
|
-
#Add validation
|
7
|
-
inject_into_file
|
8
|
-
inject_into_file
|
7
|
+
# Add validation
|
8
|
+
inject_into_file 'app/models/author.rb', " validates_presence_of :name\n validates_uniqueness_of :last_name\n", before: 'end'
|
9
|
+
inject_into_file 'app/models/post.rb', " validates_presence_of :author\n", before: 'end'
|
9
10
|
|
10
11
|
# Configure default_url_options in test environment
|
11
|
-
inject_into_file
|
12
|
+
inject_into_file 'config/environments/test.rb', " config.action_mailer.default_url_options = { :host => 'example.com' }\n", after: "config.cache_classes = true\n"
|
12
13
|
|
13
14
|
# Add our local Active Admin to the load path
|
14
|
-
inject_into_file
|
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__)"
|
15
16
|
|
16
|
-
run
|
17
|
+
run 'rm Gemfile'
|
17
18
|
|
18
19
|
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
19
20
|
|
20
21
|
generate :'active_admin:install --skip-users'
|
21
22
|
generate :'formtastic:install'
|
22
23
|
|
23
|
-
run
|
24
|
-
run
|
24
|
+
run 'rm -r test'
|
25
|
+
run 'rm -r spec'
|
25
26
|
|
26
|
-
# Setup a root path for devise
|
27
27
|
route "root :to => 'admin/dashboard#index'"
|
28
28
|
|
29
|
-
rake
|
29
|
+
rake 'db:migrate'
|
data/tasks/test.rake
CHANGED
@@ -1,6 +1,7 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
desc 'Creates a test rails app for the specs to run against'
|
2
3
|
task :setup do
|
3
4
|
require 'rails/version'
|
4
|
-
system(
|
5
|
-
system "bundle exec rails new spec/rails/rails-#{Rails::VERSION::STRING} -m spec/support/rails_template.rb --skip-spring"
|
6
|
-
end
|
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"
|
7
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_admin_import
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.0
|
4
|
+
version: 3.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Igor Fedoronchuk
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-04-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord-import
|
@@ -16,62 +16,56 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.
|
19
|
+
version: 0.17.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.
|
26
|
+
version: 0.17.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rchardet
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '1.
|
33
|
+
version: '1.6'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '1.
|
40
|
+
version: '1.6'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rubyzip
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '1.
|
48
|
-
- - ">="
|
49
|
-
- !ruby/object:Gem::Version
|
50
|
-
version: 1.0.0
|
47
|
+
version: '1.2'
|
51
48
|
type: :runtime
|
52
49
|
prerelease: false
|
53
50
|
version_requirements: !ruby/object:Gem::Requirement
|
54
51
|
requirements:
|
55
52
|
- - "~>"
|
56
53
|
- !ruby/object:Gem::Version
|
57
|
-
version: '1.
|
58
|
-
- - ">="
|
59
|
-
- !ruby/object:Gem::Version
|
60
|
-
version: 1.0.0
|
54
|
+
version: '1.2'
|
61
55
|
- !ruby/object:Gem::Dependency
|
62
|
-
name:
|
56
|
+
name: activeadmin
|
63
57
|
requirement: !ruby/object:Gem::Requirement
|
64
58
|
requirements:
|
65
|
-
- - "
|
59
|
+
- - "~>"
|
66
60
|
- !ruby/object:Gem::Version
|
67
|
-
version: '
|
61
|
+
version: '1.0'
|
68
62
|
type: :runtime
|
69
63
|
prerelease: false
|
70
64
|
version_requirements: !ruby/object:Gem::Requirement
|
71
65
|
requirements:
|
72
|
-
- - "
|
66
|
+
- - "~>"
|
73
67
|
- !ruby/object:Gem::Version
|
74
|
-
version: '
|
68
|
+
version: '1.0'
|
75
69
|
description: The most efficient way to import for Active Admin
|
76
70
|
email:
|
77
71
|
- fedoronchuk@gmail.com
|
@@ -80,7 +74,7 @@ extensions: []
|
|
80
74
|
extra_rdoc_files: []
|
81
75
|
files:
|
82
76
|
- ".gitignore"
|
83
|
-
- ".
|
77
|
+
- ".rubocop.yml"
|
84
78
|
- ".travis.yml"
|
85
79
|
- Gemfile
|
86
80
|
- LICENSE
|
@@ -90,7 +84,13 @@ files:
|
|
90
84
|
- app/views/admin/import.html.erb
|
91
85
|
- config/locales/en.yml
|
92
86
|
- config/locales/es.yml
|
87
|
+
- config/locales/fr.yml
|
93
88
|
- config/locales/it.yml
|
89
|
+
- config/locales/ja.yml
|
90
|
+
- config/locales/ko.yml
|
91
|
+
- config/locales/pt-BR.yml
|
92
|
+
- config/locales/ru.yml
|
93
|
+
- config/locales/uk.yml
|
94
94
|
- config/locales/zh-CN.yml
|
95
95
|
- lib/active_admin_import.rb
|
96
96
|
- lib/active_admin_import/authorization.rb
|
@@ -112,6 +112,7 @@ files:
|
|
112
112
|
- spec/fixtures/files/authors_win1251_win_endline.csv
|
113
113
|
- spec/fixtures/files/authors_with_ids.csv
|
114
114
|
- spec/fixtures/files/authors_with_semicolons.csv
|
115
|
+
- spec/fixtures/files/authors_with_tabs.tsv
|
115
116
|
- spec/fixtures/files/empty.csv
|
116
117
|
- spec/fixtures/files/only_headers.csv
|
117
118
|
- spec/fixtures/files/posts.csv
|
@@ -140,12 +141,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
140
141
|
version: '0'
|
141
142
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
142
143
|
requirements:
|
143
|
-
- - "
|
144
|
+
- - ">="
|
144
145
|
- !ruby/object:Gem::Version
|
145
|
-
version:
|
146
|
+
version: '0'
|
146
147
|
requirements: []
|
147
148
|
rubyforge_project:
|
148
|
-
rubygems_version: 2.
|
149
|
+
rubygems_version: 2.6.10
|
149
150
|
signing_key:
|
150
151
|
specification_version: 4
|
151
152
|
summary: ActiveAdmin import based on activerecord-import gem.
|
@@ -161,6 +162,7 @@ test_files:
|
|
161
162
|
- spec/fixtures/files/authors_win1251_win_endline.csv
|
162
163
|
- spec/fixtures/files/authors_with_ids.csv
|
163
164
|
- spec/fixtures/files/authors_with_semicolons.csv
|
165
|
+
- spec/fixtures/files/authors_with_tabs.tsv
|
164
166
|
- spec/fixtures/files/empty.csv
|
165
167
|
- spec/fixtures/files/only_headers.csv
|
166
168
|
- spec/fixtures/files/posts.csv
|
@@ -173,4 +175,3 @@ test_files:
|
|
173
175
|
- spec/support/active_model_lint.rb
|
174
176
|
- spec/support/admin.rb
|
175
177
|
- spec/support/rails_template.rb
|
176
|
-
has_rdoc:
|
data/.hound.yml
DELETED