active_admin_import 5.0.0 → 6.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/test.yml +162 -0
- data/Gemfile +18 -12
- data/README.md +254 -17
- data/Rakefile +1 -4
- data/active_admin_import.gemspec +4 -4
- data/lib/active_admin_import/dsl.rb +22 -5
- data/lib/active_admin_import/import_result.rb +11 -1
- data/lib/active_admin_import/importer.rb +3 -2
- data/lib/active_admin_import/model.rb +4 -1
- data/lib/active_admin_import/options.rb +2 -1
- data/lib/active_admin_import/version.rb +1 -1
- data/spec/fixtures/files/author_invalid_format.txt +2 -0
- data/spec/fixtures/files/authors_values_exceeded_headers.csv +3 -0
- data/spec/fixtures/files/post_comments.csv +3 -0
- data/spec/import_spec.rb +206 -1
- data/spec/spec_helper.rb +13 -17
- data/spec/support/admin.rb +16 -0
- data/spec/support/rails_template.rb +49 -18
- data/tasks/test.rake +18 -4
- metadata +20 -39
- data/.travis.yml +0 -14
- data/CHANGELOG.md +0 -33
|
@@ -16,6 +16,7 @@ module ActiveAdminImport
|
|
|
16
16
|
:ignore,
|
|
17
17
|
:template,
|
|
18
18
|
:template_object,
|
|
19
|
+
:result_class,
|
|
19
20
|
:resource_class,
|
|
20
21
|
:resource_label,
|
|
21
22
|
:plural_resource_label,
|
|
@@ -26,7 +27,7 @@ module ActiveAdminImport
|
|
|
26
27
|
|
|
27
28
|
def self.options_for(config, options = {})
|
|
28
29
|
unless options.key? :template_object
|
|
29
|
-
options[:template_object] = ActiveAdminImport::Model.new
|
|
30
|
+
options[:template_object] = -> { ActiveAdminImport::Model.new }
|
|
30
31
|
end
|
|
31
32
|
|
|
32
33
|
{
|
data/spec/import_spec.rb
CHANGED
|
@@ -27,7 +27,7 @@ describe 'import', type: :feature do
|
|
|
27
27
|
zip_file = File.expand_path("./spec/fixtures/files/#{name}.zip")
|
|
28
28
|
|
|
29
29
|
begin
|
|
30
|
-
Zip::File.open(zip_file,
|
|
30
|
+
Zip::File.open(zip_file, create: true) do |z|
|
|
31
31
|
z.add "#{name}.csv", File.expand_path("./spec/fixtures/files/#{name}.csv")
|
|
32
32
|
end
|
|
33
33
|
instance_eval &block
|
|
@@ -96,6 +96,38 @@ describe 'import', type: :feature do
|
|
|
96
96
|
end
|
|
97
97
|
include_examples 'successful inserts for author'
|
|
98
98
|
end
|
|
99
|
+
|
|
100
|
+
context 'when template object passed like proc' do
|
|
101
|
+
before do
|
|
102
|
+
add_post_resource(template_object: -> { ActiveAdminImport::Model.new(author_id: author.id) },
|
|
103
|
+
validate: true,
|
|
104
|
+
before_batch_import: lambda do |importer|
|
|
105
|
+
importer.csv_lines.map! { |row| row << importer.model.author_id }
|
|
106
|
+
importer.headers.merge!(:'Author Id' => :author_id)
|
|
107
|
+
end
|
|
108
|
+
)
|
|
109
|
+
|
|
110
|
+
visit '/admin/posts/import'
|
|
111
|
+
upload_file!(:posts_for_author)
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
include_examples 'successful inserts for author'
|
|
115
|
+
|
|
116
|
+
context 'after successful import try without file' do
|
|
117
|
+
let(:after_successful_import_do!) do
|
|
118
|
+
# reload page
|
|
119
|
+
visit '/admin/posts/import'
|
|
120
|
+
# submit form without file
|
|
121
|
+
find_button('Import').click
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
it 'should render validation error' do
|
|
125
|
+
after_successful_import_do!
|
|
126
|
+
|
|
127
|
+
expect(page).to have_content I18n.t('active_admin_import.no_file_error')
|
|
128
|
+
end
|
|
129
|
+
end
|
|
130
|
+
end
|
|
99
131
|
end
|
|
100
132
|
|
|
101
133
|
context 'for csv with author name' do
|
|
@@ -424,6 +456,36 @@ describe 'import', type: :feature do
|
|
|
424
456
|
expect(Author.count).to eq(2)
|
|
425
457
|
end
|
|
426
458
|
end
|
|
459
|
+
|
|
460
|
+
context 'with empty csv and auto detect encoding' do
|
|
461
|
+
let(:options) do
|
|
462
|
+
attributes = { force_encoding: :auto }
|
|
463
|
+
{ template_object: ActiveAdminImport::Model.new(attributes) }
|
|
464
|
+
end
|
|
465
|
+
|
|
466
|
+
before do
|
|
467
|
+
upload_file!(:empty)
|
|
468
|
+
end
|
|
469
|
+
|
|
470
|
+
it 'should render warning' do
|
|
471
|
+
expect(page).to have_content I18n.t('active_admin_import.file_empty_error')
|
|
472
|
+
expect(Author.count).to eq(0)
|
|
473
|
+
end
|
|
474
|
+
end
|
|
475
|
+
|
|
476
|
+
context 'with csv which has exceeded values' do
|
|
477
|
+
before do
|
|
478
|
+
upload_file!(:authors_values_exceeded_headers)
|
|
479
|
+
end
|
|
480
|
+
|
|
481
|
+
it 'should render warning' do
|
|
482
|
+
# 5 columns: 'birthday, name, last_name, created_at, updated_at'
|
|
483
|
+
# 6 values: '"1988-11-16", "Jane", "Roe", " exceeded value", datetime, datetime'
|
|
484
|
+
msg = 'Number of values (6) exceeds number of columns (5)'
|
|
485
|
+
expect(page).to have_content I18n.t('active_admin_import.file_error', message: msg)
|
|
486
|
+
expect(Author.count).to eq(0)
|
|
487
|
+
end
|
|
488
|
+
end
|
|
427
489
|
end
|
|
428
490
|
|
|
429
491
|
context 'with callback procs options' do
|
|
@@ -526,4 +588,147 @@ describe 'import', type: :feature do
|
|
|
526
588
|
expect { add_author_resource(options) }.to raise_error(ArgumentError)
|
|
527
589
|
end
|
|
528
590
|
end
|
|
591
|
+
|
|
592
|
+
context 'when submitting empty form after validation error' do
|
|
593
|
+
let(:options) { {} }
|
|
594
|
+
|
|
595
|
+
before do
|
|
596
|
+
add_author_resource(options)
|
|
597
|
+
visit '/admin/authors/import'
|
|
598
|
+
end
|
|
599
|
+
|
|
600
|
+
it 'should NOT reuse cached file from previous submission' do
|
|
601
|
+
expect do
|
|
602
|
+
upload_file!(:author_broken_header)
|
|
603
|
+
expect(page).to have_content("can't write unknown attribute")
|
|
604
|
+
end.not_to change { Author.count }
|
|
605
|
+
|
|
606
|
+
# Second submission without selecting a file
|
|
607
|
+
expect do
|
|
608
|
+
find_button('Import').click
|
|
609
|
+
expect(page).to have_content(I18n.t('active_admin_import.no_file_error'))
|
|
610
|
+
end.not_to change { Author.count }
|
|
611
|
+
end
|
|
612
|
+
end
|
|
613
|
+
|
|
614
|
+
context 'when importing file with invalid format and auto force_encoding' do
|
|
615
|
+
let(:options) { { template_object: ActiveAdminImport::Model.new(force_encoding: :auto) } }
|
|
616
|
+
|
|
617
|
+
before do
|
|
618
|
+
add_author_resource(options)
|
|
619
|
+
visit '/admin/authors/import'
|
|
620
|
+
end
|
|
621
|
+
|
|
622
|
+
it 'should reject invalid file format before encoding' do
|
|
623
|
+
expect do
|
|
624
|
+
upload_file!(:author_invalid_format, 'txt')
|
|
625
|
+
expect(page).to have_content I18n.t('active_admin_import.file_format_error')
|
|
626
|
+
end.not_to change { Author.count }
|
|
627
|
+
end
|
|
628
|
+
end
|
|
629
|
+
|
|
630
|
+
context 'with active_admin_import_context defined on the controller' do
|
|
631
|
+
before { Author.create!(name: 'John', last_name: 'Doe') }
|
|
632
|
+
|
|
633
|
+
let(:author) { Author.take }
|
|
634
|
+
|
|
635
|
+
context 'when context returns request-derived attributes' do
|
|
636
|
+
before do
|
|
637
|
+
author_id = author.id
|
|
638
|
+
add_post_resource(
|
|
639
|
+
template_object: ActiveAdminImport::Model.new(author_id: author_id),
|
|
640
|
+
before_batch_import: lambda do |importer|
|
|
641
|
+
ip = importer.model.request_ip
|
|
642
|
+
a_id = importer.model.author_id
|
|
643
|
+
importer.csv_lines.map! { |row| row << ip << a_id }
|
|
644
|
+
importer.headers.merge!(:'Request Ip' => :request_ip, :'Author Id' => :author_id)
|
|
645
|
+
end,
|
|
646
|
+
controller_block: proc do
|
|
647
|
+
def active_admin_import_context
|
|
648
|
+
{ request_ip: request.remote_ip }
|
|
649
|
+
end
|
|
650
|
+
end
|
|
651
|
+
)
|
|
652
|
+
visit '/admin/posts/import'
|
|
653
|
+
upload_file!(:posts_for_author)
|
|
654
|
+
end
|
|
655
|
+
|
|
656
|
+
it 'merges the context into the import model so callbacks see it' do
|
|
657
|
+
expect(page).to have_content 'Successfully imported 2 posts'
|
|
658
|
+
expect(Post.count).to eq(2)
|
|
659
|
+
Post.all.each do |post|
|
|
660
|
+
expect(post.request_ip).to eq('127.0.0.1')
|
|
661
|
+
expect(post.author_id).to eq(author.id)
|
|
662
|
+
end
|
|
663
|
+
end
|
|
664
|
+
end
|
|
665
|
+
|
|
666
|
+
context 'when context returns parent id for a nested belongs_to resource' do
|
|
667
|
+
let(:post) { Post.create!(title: 'A post', body: 'body', author: author) }
|
|
668
|
+
|
|
669
|
+
before do
|
|
670
|
+
add_nested_post_comment_resource(
|
|
671
|
+
before_batch_import: lambda do |importer|
|
|
672
|
+
importer.csv_lines.map! { |row| row << importer.model.post_id }
|
|
673
|
+
importer.headers.merge!(:'Post Id' => :post_id)
|
|
674
|
+
end,
|
|
675
|
+
controller_block: proc do
|
|
676
|
+
def active_admin_import_context
|
|
677
|
+
{ post_id: parent.id }
|
|
678
|
+
end
|
|
679
|
+
end
|
|
680
|
+
)
|
|
681
|
+
visit "/admin/posts/#{post.id}/post_comments/import"
|
|
682
|
+
upload_file!(:post_comments)
|
|
683
|
+
end
|
|
684
|
+
|
|
685
|
+
it 'automatically assigns the parent post_id to every imported comment' do
|
|
686
|
+
expect(page).to have_content 'Successfully imported 2 post comments'
|
|
687
|
+
expect(PostComment.count).to eq(2)
|
|
688
|
+
expect(PostComment.where(post_id: post.id).count).to eq(2)
|
|
689
|
+
end
|
|
690
|
+
end
|
|
691
|
+
end
|
|
692
|
+
|
|
693
|
+
# PG-only: activerecord-import populates `result.ids` reliably on PostgreSQL
|
|
694
|
+
# via RETURNING. On MySQL/SQLite the array is not populated by default, so
|
|
695
|
+
# the assertion would not be meaningful there. The :result_class option
|
|
696
|
+
# itself works on every adapter — this spec just demonstrates the canonical
|
|
697
|
+
# PR #191 use case (collecting inserted ids) on the adapter that supports it.
|
|
698
|
+
if ENV['DB'] == 'postgres'
|
|
699
|
+
context 'with custom result_class (PostgreSQL)' do
|
|
700
|
+
# Subclass that captures inserted ids alongside the standard counters.
|
|
701
|
+
# Lives in user-land so the gem itself stays free of adapter-specific
|
|
702
|
+
# quirks around RETURNING. This is the example documented in the README.
|
|
703
|
+
class ImportResultWithIds < ActiveAdminImport::ImportResult
|
|
704
|
+
attr_reader :ids
|
|
705
|
+
|
|
706
|
+
def initialize
|
|
707
|
+
super
|
|
708
|
+
@ids = []
|
|
709
|
+
end
|
|
710
|
+
|
|
711
|
+
def add(batch_result, qty)
|
|
712
|
+
super
|
|
713
|
+
@ids.concat(Array(batch_result.ids))
|
|
714
|
+
end
|
|
715
|
+
end
|
|
716
|
+
|
|
717
|
+
before do
|
|
718
|
+
add_author_resource(result_class: ImportResultWithIds) do |result, _options|
|
|
719
|
+
# Expose the captured ids on the flash so the test asserts via the
|
|
720
|
+
# rendered page rather than closure capture.
|
|
721
|
+
flash[:notice] = "Imported ids: [#{result.ids.sort.join(',')}]"
|
|
722
|
+
end
|
|
723
|
+
visit '/admin/authors/import'
|
|
724
|
+
upload_file!(:authors)
|
|
725
|
+
end
|
|
726
|
+
|
|
727
|
+
it 'collects the ids of inserted records via the custom subclass' do
|
|
728
|
+
expect(Author.count).to eq(2)
|
|
729
|
+
expected = "Imported ids: [#{Author.pluck(:id).sort.join(',')}]"
|
|
730
|
+
expect(page).to have_content(expected)
|
|
731
|
+
end
|
|
732
|
+
end
|
|
733
|
+
end
|
|
529
734
|
end
|
data/spec/spec_helper.rb
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
require 'simplecov'
|
|
2
|
+
SimpleCov.start do
|
|
3
|
+
add_filter '/spec/'
|
|
4
|
+
end
|
|
4
5
|
|
|
5
6
|
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
|
6
7
|
$LOAD_PATH << File.expand_path('../support', __FILE__)
|
|
@@ -10,22 +11,18 @@ require 'bundler'
|
|
|
10
11
|
Bundler.setup
|
|
11
12
|
|
|
12
13
|
ENV['RAILS_ENV'] = 'test'
|
|
13
|
-
# Ensure the Active Admin load path is happy
|
|
14
14
|
require 'rails'
|
|
15
15
|
ENV['RAILS'] = Rails.version
|
|
16
|
-
ENV['
|
|
17
|
-
|
|
16
|
+
ENV['DB'] ||= 'sqlite'
|
|
17
|
+
ENV['RAILS_ROOT'] = File.expand_path("../rails/rails-#{ENV['RAILS']}-#{ENV['DB']}", __FILE__)
|
|
18
18
|
system 'rake setup' unless File.exist?(ENV['RAILS_ROOT'])
|
|
19
19
|
|
|
20
20
|
require 'active_model'
|
|
21
|
-
# require ActiveRecord to ensure that Ransack loads correctly
|
|
22
21
|
require 'active_record'
|
|
23
22
|
require 'action_view'
|
|
24
23
|
require 'active_admin'
|
|
25
24
|
ActiveAdmin.application.load_paths = [ENV['RAILS_ROOT'] + '/app/admin']
|
|
26
25
|
require ENV['RAILS_ROOT'] + '/config/environment.rb'
|
|
27
|
-
# Disabling authentication in specs so that we don't have to worry about
|
|
28
|
-
# it allover the place
|
|
29
26
|
ActiveAdmin.application.authentication_method = false
|
|
30
27
|
ActiveAdmin.application.current_user_method = false
|
|
31
28
|
|
|
@@ -33,21 +30,20 @@ require 'rspec/rails'
|
|
|
33
30
|
require 'support/admin'
|
|
34
31
|
require 'capybara/rails'
|
|
35
32
|
require 'capybara/rspec'
|
|
36
|
-
require 'capybara/
|
|
33
|
+
require 'capybara/cuprite'
|
|
37
34
|
|
|
38
|
-
Capybara.
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
debug: true,
|
|
42
|
-
phantomjs_options: ['--debug=no', '--load-images=no'])
|
|
35
|
+
Capybara.server = :webrick
|
|
36
|
+
Capybara.register_driver :cuprite do |app|
|
|
37
|
+
Capybara::Cuprite::Driver.new(app, headless: true, window_size: [1280, 800])
|
|
43
38
|
end
|
|
44
|
-
|
|
45
|
-
Capybara.
|
|
39
|
+
Capybara.javascript_driver = :cuprite
|
|
40
|
+
Capybara.default_max_wait_time = 5
|
|
46
41
|
|
|
47
42
|
RSpec.configure do |config|
|
|
48
43
|
config.use_transactional_fixtures = false
|
|
49
44
|
|
|
50
45
|
config.before(:suite) do
|
|
46
|
+
ActiveRecord::Migration.maintain_test_schema!
|
|
51
47
|
DatabaseCleaner.strategy = :truncation
|
|
52
48
|
DatabaseCleaner.clean_with(:truncation)
|
|
53
49
|
end
|
data/spec/support/admin.rb
CHANGED
|
@@ -8,8 +8,24 @@ def add_author_resource(options = {}, &block)
|
|
|
8
8
|
end
|
|
9
9
|
|
|
10
10
|
def add_post_resource(options = {}, &block)
|
|
11
|
+
cb = options.delete(:controller_block)
|
|
11
12
|
ActiveAdmin.register Post do
|
|
12
13
|
config.filters = false
|
|
14
|
+
controller(&cb) if cb
|
|
15
|
+
active_admin_import(options, &block)
|
|
16
|
+
end
|
|
17
|
+
Rails.application.reload_routes!
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def add_nested_post_comment_resource(options = {}, &block)
|
|
21
|
+
cb = options.delete(:controller_block)
|
|
22
|
+
ActiveAdmin.register Post do
|
|
23
|
+
config.filters = false
|
|
24
|
+
end
|
|
25
|
+
ActiveAdmin.register PostComment do
|
|
26
|
+
config.filters = false
|
|
27
|
+
belongs_to :post
|
|
28
|
+
controller(&cb) if cb
|
|
13
29
|
active_admin_import(options, &block)
|
|
14
30
|
end
|
|
15
31
|
Rails.application.reload_routes!
|
|
@@ -1,29 +1,60 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
create_file "app/assets/config/manifest.js", skip: true
|
|
2
|
+
|
|
3
|
+
db = ENV['DB'] || 'sqlite'
|
|
4
|
+
case db
|
|
5
|
+
when 'mysql'
|
|
6
|
+
remove_file 'config/database.yml'
|
|
7
|
+
create_file 'config/database.yml', <<~YAML
|
|
8
|
+
default: &default
|
|
9
|
+
adapter: mysql2
|
|
10
|
+
encoding: utf8mb4
|
|
11
|
+
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
|
|
12
|
+
host: <%= ENV.fetch("DB_HOST", "127.0.0.1") %>
|
|
13
|
+
port: <%= ENV.fetch("DB_PORT", 3306) %>
|
|
14
|
+
username: <%= ENV.fetch("DB_USERNAME", "root") %>
|
|
15
|
+
password: <%= ENV.fetch("DB_PASSWORD", "root") %>
|
|
16
|
+
|
|
17
|
+
test:
|
|
18
|
+
<<: *default
|
|
19
|
+
database: active_admin_import_test
|
|
20
|
+
YAML
|
|
21
|
+
when 'postgres', 'postgresql'
|
|
22
|
+
remove_file 'config/database.yml'
|
|
23
|
+
create_file 'config/database.yml', <<~YAML
|
|
24
|
+
default: &default
|
|
25
|
+
adapter: postgresql
|
|
26
|
+
encoding: unicode
|
|
27
|
+
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
|
|
28
|
+
host: <%= ENV.fetch("DB_HOST", "127.0.0.1") %>
|
|
29
|
+
port: <%= ENV.fetch("DB_PORT", 5432) %>
|
|
30
|
+
username: <%= ENV.fetch("DB_USERNAME", "postgres") %>
|
|
31
|
+
password: <%= ENV.fetch("DB_PASSWORD", "postgres") %>
|
|
32
|
+
|
|
33
|
+
test:
|
|
34
|
+
<<: *default
|
|
35
|
+
database: active_admin_import_test
|
|
36
|
+
YAML
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
generate :model, 'author name:string{10}:uniq last_name:string birthday:date --force'
|
|
40
|
+
generate :model, 'post title:string:uniq body:text request_ip:string author:references --force'
|
|
41
|
+
generate :model, 'post_comment body:text post:references --force'
|
|
3
42
|
|
|
4
|
-
generate :model, 'author name:string{10}:uniq last_name:string birthday:date'
|
|
5
|
-
generate :model, 'post title:string:uniq body:text author:references'
|
|
6
|
-
|
|
7
|
-
# Add validation
|
|
8
43
|
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'
|
|
10
|
-
|
|
11
|
-
# Configure default_url_options in test environment
|
|
12
|
-
inject_into_file 'config/environments/test.rb', " config.action_mailer.default_url_options = { :host => 'example.com' }\n", after: "config.cache_classes = true\n"
|
|
44
|
+
inject_into_file 'app/models/post.rb', " validates_presence_of :author\n has_many :post_comments\n", before: 'end'
|
|
13
45
|
|
|
14
|
-
# Add our local Active Admin to the load path
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
46
|
+
# Add our local Active Admin to the load path (Rails 7.1+)
|
|
47
|
+
gsub_file "config/environment.rb",
|
|
48
|
+
'require_relative "application"',
|
|
49
|
+
"require_relative \"application\"\n$LOAD_PATH.unshift('#{File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'lib'))}')\nrequire \"active_admin\"\n"
|
|
18
50
|
|
|
19
51
|
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
|
20
52
|
|
|
21
53
|
generate :'active_admin:install --skip-users'
|
|
22
54
|
generate :'formtastic:install'
|
|
23
55
|
|
|
24
|
-
run 'rm -
|
|
25
|
-
run 'rm -r spec'
|
|
26
|
-
|
|
56
|
+
run 'rm -rf test'
|
|
27
57
|
route "root :to => 'admin/dashboard#index'"
|
|
58
|
+
rake 'db:create db:migrate'
|
|
28
59
|
|
|
29
|
-
|
|
60
|
+
run 'rm -f Gemfile Gemfile.lock'
|
data/tasks/test.rake
CHANGED
|
@@ -1,7 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
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"
|
|
3
2
|
task :setup do
|
|
4
3
|
require 'rails/version'
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
|
|
5
|
+
db = ENV['DB'] || 'sqlite'
|
|
6
|
+
rails_db = case db
|
|
7
|
+
when 'mysql' then 'mysql'
|
|
8
|
+
when 'postgres', 'postgresql' then 'postgresql'
|
|
9
|
+
else 'sqlite3'
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
rails_new_opts = %W(
|
|
13
|
+
--skip-turbolinks
|
|
14
|
+
--skip-spring
|
|
15
|
+
--skip-bootsnap
|
|
16
|
+
-d #{rails_db}
|
|
17
|
+
-m
|
|
18
|
+
spec/support/rails_template.rb
|
|
19
|
+
)
|
|
20
|
+
system "bundle exec rails new spec/rails/rails-#{Rails::VERSION::STRING}-#{db} #{rails_new_opts.join(' ')}"
|
|
7
21
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: active_admin_import
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 6.0.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Igor Fedoronchuk
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: bin
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
13
|
name: activerecord-import
|
|
@@ -16,14 +15,14 @@ dependencies:
|
|
|
16
15
|
requirements:
|
|
17
16
|
- - ">="
|
|
18
17
|
- !ruby/object:Gem::Version
|
|
19
|
-
version: '0
|
|
18
|
+
version: '2.0'
|
|
20
19
|
type: :runtime
|
|
21
20
|
prerelease: false
|
|
22
21
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
22
|
requirements:
|
|
24
23
|
- - ">="
|
|
25
24
|
- !ruby/object:Gem::Version
|
|
26
|
-
version: '0
|
|
25
|
+
version: '2.0'
|
|
27
26
|
- !ruby/object:Gem::Dependency
|
|
28
27
|
name: rchardet
|
|
29
28
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -58,14 +57,20 @@ dependencies:
|
|
|
58
57
|
requirements:
|
|
59
58
|
- - ">="
|
|
60
59
|
- !ruby/object:Gem::Version
|
|
61
|
-
version:
|
|
60
|
+
version: '3.0'
|
|
61
|
+
- - "<"
|
|
62
|
+
- !ruby/object:Gem::Version
|
|
63
|
+
version: '4.0'
|
|
62
64
|
type: :runtime
|
|
63
65
|
prerelease: false
|
|
64
66
|
version_requirements: !ruby/object:Gem::Requirement
|
|
65
67
|
requirements:
|
|
66
68
|
- - ">="
|
|
67
69
|
- !ruby/object:Gem::Version
|
|
68
|
-
version:
|
|
70
|
+
version: '3.0'
|
|
71
|
+
- - "<"
|
|
72
|
+
- !ruby/object:Gem::Version
|
|
73
|
+
version: '4.0'
|
|
69
74
|
description: The most efficient way to import for Active Admin
|
|
70
75
|
email:
|
|
71
76
|
- fedoronchuk@gmail.com
|
|
@@ -73,10 +78,9 @@ executables: []
|
|
|
73
78
|
extensions: []
|
|
74
79
|
extra_rdoc_files: []
|
|
75
80
|
files:
|
|
81
|
+
- ".github/workflows/test.yml"
|
|
76
82
|
- ".gitignore"
|
|
77
83
|
- ".rubocop.yml"
|
|
78
|
-
- ".travis.yml"
|
|
79
|
-
- CHANGELOG.md
|
|
80
84
|
- Gemfile
|
|
81
85
|
- LICENSE
|
|
82
86
|
- README.md
|
|
@@ -108,17 +112,20 @@ files:
|
|
|
108
112
|
- spec/fixtures/files/author.csv
|
|
109
113
|
- spec/fixtures/files/author_broken_header.csv
|
|
110
114
|
- spec/fixtures/files/author_invalid.csv
|
|
115
|
+
- spec/fixtures/files/author_invalid_format.txt
|
|
111
116
|
- spec/fixtures/files/authors.csv
|
|
112
117
|
- spec/fixtures/files/authors_bom.csv
|
|
113
118
|
- spec/fixtures/files/authors_invalid_db.csv
|
|
114
119
|
- spec/fixtures/files/authors_invalid_model.csv
|
|
115
120
|
- spec/fixtures/files/authors_no_headers.csv
|
|
121
|
+
- spec/fixtures/files/authors_values_exceeded_headers.csv
|
|
116
122
|
- spec/fixtures/files/authors_win1251_win_endline.csv
|
|
117
123
|
- spec/fixtures/files/authors_with_ids.csv
|
|
118
124
|
- spec/fixtures/files/authors_with_semicolons.csv
|
|
119
125
|
- spec/fixtures/files/authors_with_tabs.tsv
|
|
120
126
|
- spec/fixtures/files/empty.csv
|
|
121
127
|
- spec/fixtures/files/only_headers.csv
|
|
128
|
+
- spec/fixtures/files/post_comments.csv
|
|
122
129
|
- spec/fixtures/files/posts.csv
|
|
123
130
|
- spec/fixtures/files/posts_for_author.csv
|
|
124
131
|
- spec/fixtures/files/posts_for_author_no_headers.csv
|
|
@@ -130,11 +137,10 @@ files:
|
|
|
130
137
|
- spec/support/admin.rb
|
|
131
138
|
- spec/support/rails_template.rb
|
|
132
139
|
- tasks/test.rake
|
|
133
|
-
homepage:
|
|
140
|
+
homepage: https://github.com/activeadmin-plugins/active_admin_import
|
|
134
141
|
licenses:
|
|
135
142
|
- MIT
|
|
136
143
|
metadata: {}
|
|
137
|
-
post_install_message:
|
|
138
144
|
rdoc_options: []
|
|
139
145
|
require_paths:
|
|
140
146
|
- lib
|
|
@@ -142,39 +148,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
142
148
|
requirements:
|
|
143
149
|
- - ">="
|
|
144
150
|
- !ruby/object:Gem::Version
|
|
145
|
-
version:
|
|
151
|
+
version: 3.1.0
|
|
146
152
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
147
153
|
requirements:
|
|
148
154
|
- - ">="
|
|
149
155
|
- !ruby/object:Gem::Version
|
|
150
156
|
version: '0'
|
|
151
157
|
requirements: []
|
|
152
|
-
rubygems_version: 3.1
|
|
153
|
-
signing_key:
|
|
158
|
+
rubygems_version: 3.7.1
|
|
154
159
|
specification_version: 4
|
|
155
160
|
summary: ActiveAdmin import based on activerecord-import gem.
|
|
156
|
-
test_files:
|
|
157
|
-
- spec/fixtures/files/author.csv
|
|
158
|
-
- spec/fixtures/files/author_broken_header.csv
|
|
159
|
-
- spec/fixtures/files/author_invalid.csv
|
|
160
|
-
- spec/fixtures/files/authors.csv
|
|
161
|
-
- spec/fixtures/files/authors_bom.csv
|
|
162
|
-
- spec/fixtures/files/authors_invalid_db.csv
|
|
163
|
-
- spec/fixtures/files/authors_invalid_model.csv
|
|
164
|
-
- spec/fixtures/files/authors_no_headers.csv
|
|
165
|
-
- spec/fixtures/files/authors_win1251_win_endline.csv
|
|
166
|
-
- spec/fixtures/files/authors_with_ids.csv
|
|
167
|
-
- spec/fixtures/files/authors_with_semicolons.csv
|
|
168
|
-
- spec/fixtures/files/authors_with_tabs.tsv
|
|
169
|
-
- spec/fixtures/files/empty.csv
|
|
170
|
-
- spec/fixtures/files/only_headers.csv
|
|
171
|
-
- spec/fixtures/files/posts.csv
|
|
172
|
-
- spec/fixtures/files/posts_for_author.csv
|
|
173
|
-
- spec/fixtures/files/posts_for_author_no_headers.csv
|
|
174
|
-
- spec/import_result_spec.rb
|
|
175
|
-
- spec/import_spec.rb
|
|
176
|
-
- spec/model_spec.rb
|
|
177
|
-
- spec/spec_helper.rb
|
|
178
|
-
- spec/support/active_model_lint.rb
|
|
179
|
-
- spec/support/admin.rb
|
|
180
|
-
- spec/support/rails_template.rb
|
|
161
|
+
test_files: []
|
data/.travis.yml
DELETED
data/CHANGELOG.md
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
# Changelog
|
|
2
|
-
## [5.0.0] - 2021-11-16
|
|
3
|
-
- Ruby 3 compatibility added #190 | @clinejj
|
|
4
|
-
- Support for a non UTF-8 file when zip uploading #185| @naokirin
|
|
5
|
-
- Rails 6 supported #183 | @pnghai
|
|
6
|
-
- Drop ruby 2.4 support #192 | @Fivell
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
## [4.2.0] - 2020-02-05
|
|
10
|
-
- generic exception for import added #175 | @linqueta
|
|
11
|
-
|
|
12
|
-
## [4.1.2] - 2019-12-16
|
|
13
|
-
- allow application/octet-stream content-type #172 | @dmitry-sinina
|
|
14
|
-
- Allow activerecord-import >= 0.27 #171 | @sagium
|
|
15
|
-
|
|
16
|
-
## [4.1.1] - 2019-09-20
|
|
17
|
-
- Fix column slicing #168 | @doredesign
|
|
18
|
-
- Handle errors on base #163
|
|
19
|
-
|
|
20
|
-
## [4.1.0] - 2019-01-15
|
|
21
|
-
- Upgrade dependencies: `activerecord-import` to >=0.27.1 | @jkowens
|
|
22
|
-
|
|
23
|
-
## [4.0.0] - 2018-07-19
|
|
24
|
-
- Adde German translation | @morris-frank
|
|
25
|
-
- Remove support for Ruby 2.1 and Rails 4
|
|
26
|
-
|
|
27
|
-
## [3.1.0] - 2018-04-10
|
|
28
|
-
- Lower dependency of ActiveAdmin to >= 1.0.0.pre2
|
|
29
|
-
- Add possibility to skip columns/values in CSV (batch_slice_columns method)
|
|
30
|
-
|
|
31
|
-
[Unreleased]: https://github.com/activeadmin-plugins/active_admin_import/compare/v4.0.0...HEAD
|
|
32
|
-
[4.0.0]: https://github.com/activeadmin-plugins/active_admin_import/compare/v3.1.0...v4.0.0
|
|
33
|
-
[3.1.0]: https://github.com/activeadmin-plugins/active_admin_import/compare/3.0.0...v3.1.0
|