active_admin_import 8.0.0 → 8.0.1
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/lib/active_admin_import/version.rb +1 -1
- metadata +2 -42
- data/.github/workflows/test.yml +0 -219
- data/.gitignore +0 -19
- data/.rubocop.yml +0 -43
- data/Gemfile +0 -37
- data/Rakefile +0 -5
- data/active_admin_import.gemspec +0 -22
- data/spec/fixtures/files/author.csv +0 -2
- data/spec/fixtures/files/author_broken_header.csv +0 -2
- data/spec/fixtures/files/author_invalid.csv +0 -2
- data/spec/fixtures/files/author_invalid_format.txt +0 -2
- data/spec/fixtures/files/authors.csv +0 -3
- data/spec/fixtures/files/authors_blank_header_end.csv +0 -3
- data/spec/fixtures/files/authors_blank_header_middle.csv +0 -3
- data/spec/fixtures/files/authors_bom.csv +0 -3
- data/spec/fixtures/files/authors_empty_header.csv +0 -3
- data/spec/fixtures/files/authors_invalid_db.csv +0 -3
- data/spec/fixtures/files/authors_invalid_model.csv +0 -3
- data/spec/fixtures/files/authors_many.csv +0 -6
- data/spec/fixtures/files/authors_no_headers.csv +0 -2
- data/spec/fixtures/files/authors_values_exceeded_headers.csv +0 -3
- data/spec/fixtures/files/authors_win1251_win_endline.csv +0 -3
- data/spec/fixtures/files/authors_with_ids.csv +0 -3
- data/spec/fixtures/files/authors_with_semicolons.csv +0 -3
- data/spec/fixtures/files/authors_with_tabs.tsv +0 -3
- data/spec/fixtures/files/empty.csv +0 -0
- data/spec/fixtures/files/only_headers.csv +0 -1
- data/spec/fixtures/files/post_comments.csv +0 -3
- data/spec/fixtures/files/posts.csv +0 -4
- data/spec/fixtures/files/posts_for_author.csv +0 -3
- data/spec/fixtures/files/posts_for_author_no_headers.csv +0 -2
- data/spec/import_result_spec.rb +0 -39
- data/spec/import_spec.rb +0 -859
- data/spec/model_spec.rb +0 -6
- data/spec/spec_helper.rb +0 -54
- data/spec/support/active_model_lint.rb +0 -15
- data/spec/support/admin.rb +0 -32
- data/spec/support/import_form_selectors.rb +0 -24
- data/spec/support/rails_template.rb +0 -71
- data/spec/support/test_app_paths.rb +0 -14
- data/tasks/test.rake +0 -39
data/spec/model_spec.rb
DELETED
data/spec/spec_helper.rb
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
require 'simplecov'
|
|
2
|
-
SimpleCov.start do
|
|
3
|
-
add_filter '/spec/'
|
|
4
|
-
end
|
|
5
|
-
|
|
6
|
-
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
|
7
|
-
$LOAD_PATH << File.expand_path('../support', __FILE__)
|
|
8
|
-
|
|
9
|
-
ENV['BUNDLE_GEMFILE'] = File.expand_path('../../Gemfile', __FILE__)
|
|
10
|
-
require 'bundler'
|
|
11
|
-
Bundler.setup
|
|
12
|
-
|
|
13
|
-
ENV['RAILS_ENV'] = 'test'
|
|
14
|
-
require 'rails'
|
|
15
|
-
require 'test_app_paths'
|
|
16
|
-
ENV['RAILS'] = Rails.version
|
|
17
|
-
ENV['RAILS_ROOT'] = TestAppPaths.app_root
|
|
18
|
-
system 'rake setup' unless File.exist?(ENV['RAILS_ROOT'])
|
|
19
|
-
|
|
20
|
-
require 'active_model'
|
|
21
|
-
require 'active_record'
|
|
22
|
-
require 'action_view'
|
|
23
|
-
require 'active_admin'
|
|
24
|
-
ActiveAdmin.application.load_paths = [ENV['RAILS_ROOT'] + '/app/admin']
|
|
25
|
-
require ENV['RAILS_ROOT'] + '/config/environment.rb'
|
|
26
|
-
ActiveAdmin.application.authentication_method = false
|
|
27
|
-
ActiveAdmin.application.current_user_method = false
|
|
28
|
-
|
|
29
|
-
require 'rspec/rails'
|
|
30
|
-
require 'support/admin'
|
|
31
|
-
require 'support/import_form_selectors'
|
|
32
|
-
require 'capybara/rails'
|
|
33
|
-
require 'capybara/rspec'
|
|
34
|
-
|
|
35
|
-
# Specs exercise ActiveAdmin through Capybara's default rack_test driver — no
|
|
36
|
-
# JavaScript or real browser is needed, so no Cuprite/Chrome or app server.
|
|
37
|
-
Capybara.default_driver = :rack_test
|
|
38
|
-
|
|
39
|
-
RSpec.configure do |config|
|
|
40
|
-
config.use_transactional_fixtures = false
|
|
41
|
-
|
|
42
|
-
config.before(:suite) do
|
|
43
|
-
ActiveRecord::Migration.maintain_test_schema!
|
|
44
|
-
DatabaseCleaner.strategy = :truncation
|
|
45
|
-
DatabaseCleaner.clean_with(:truncation)
|
|
46
|
-
end
|
|
47
|
-
config.before(:each) do
|
|
48
|
-
DatabaseCleaner.strategy = :truncation
|
|
49
|
-
DatabaseCleaner.start
|
|
50
|
-
end
|
|
51
|
-
config.after(:each) do
|
|
52
|
-
DatabaseCleaner.clean
|
|
53
|
-
end
|
|
54
|
-
end
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
shared_examples_for 'ActiveModel' do
|
|
3
|
-
include ActiveModel::Lint::Tests
|
|
4
|
-
|
|
5
|
-
# to_s is to support ruby-1.9
|
|
6
|
-
ActiveModel::Lint::Tests.public_instance_methods.map(&:to_s).grep(/^test/).each do |m|
|
|
7
|
-
example m.tr('_', ' ') do
|
|
8
|
-
send m
|
|
9
|
-
end
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
def model
|
|
13
|
-
subject
|
|
14
|
-
end
|
|
15
|
-
end
|
data/spec/support/admin.rb
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
def add_author_resource(options = {}, &block)
|
|
3
|
-
ActiveAdmin.register Author do
|
|
4
|
-
config.filters = false
|
|
5
|
-
active_admin_import(options, &block)
|
|
6
|
-
end
|
|
7
|
-
Rails.application.reload_routes!
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
def add_post_resource(options = {}, &block)
|
|
11
|
-
cb = options.delete(:controller_block)
|
|
12
|
-
ActiveAdmin.register Post do
|
|
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
|
|
29
|
-
active_admin_import(options, &block)
|
|
30
|
-
end
|
|
31
|
-
Rails.application.reload_routes!
|
|
32
|
-
end
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
# Formtastic 6 (AA 4) keeps the same DOM IDs as Formtastic 4 (AA 3) for this
|
|
4
|
-
# form, so one selector set serves both — branch here if a future AA shifts an ID.
|
|
5
|
-
module ImportFormSelectors
|
|
6
|
-
module_function
|
|
7
|
-
|
|
8
|
-
SELECTORS = {
|
|
9
|
-
form_id: 'new_active_admin_import_model',
|
|
10
|
-
file_input_id: 'active_admin_import_model_file',
|
|
11
|
-
file_input_css: 'input#active_admin_import_model_file',
|
|
12
|
-
submit_css: '#active_admin_import_model_submit_action input',
|
|
13
|
-
import_button_text: 'Import',
|
|
14
|
-
import_link_text: 'Import Authors'
|
|
15
|
-
}.freeze
|
|
16
|
-
|
|
17
|
-
def form_id = SELECTORS[:form_id]
|
|
18
|
-
def form_css = "##{form_id}"
|
|
19
|
-
def file_input_id = SELECTORS[:file_input_id]
|
|
20
|
-
def file_input_css = SELECTORS[:file_input_css]
|
|
21
|
-
def submit_css = SELECTORS[:submit_css]
|
|
22
|
-
def import_button_text = SELECTORS[:import_button_text]
|
|
23
|
-
def import_link_text = SELECTORS[:import_link_text]
|
|
24
|
-
end
|
|
@@ -1,71 +0,0 @@
|
|
|
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'
|
|
42
|
-
|
|
43
|
-
inject_into_file 'app/models/author.rb', " validates_presence_of :name\n validates_uniqueness_of :last_name\n", before: 'end'
|
|
44
|
-
inject_into_file 'app/models/post.rb', " validates_presence_of :author\n has_many :post_comments\n", before: 'end'
|
|
45
|
-
|
|
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"
|
|
50
|
-
|
|
51
|
-
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
|
52
|
-
|
|
53
|
-
aa_v4 = ENV['AA']&.start_with?('4')
|
|
54
|
-
|
|
55
|
-
generate :'active_admin:install --skip-users'
|
|
56
|
-
|
|
57
|
-
if aa_v4
|
|
58
|
-
# `active_admin:assets` swaps AA 3's Sprockets SCSS/JS for AA 4's Tailwind CSS
|
|
59
|
-
# stub. We don't compile it — specs assert on DOM and flash text, not styling,
|
|
60
|
-
# so the stub suffices and no Node is needed. `builds/` satisfies cssbundling-rails.
|
|
61
|
-
generate :'active_admin:assets'
|
|
62
|
-
run 'mkdir -p app/assets/builds'
|
|
63
|
-
else
|
|
64
|
-
generate :'formtastic:install'
|
|
65
|
-
end
|
|
66
|
-
|
|
67
|
-
run 'rm -rf test'
|
|
68
|
-
route "root :to => 'admin/dashboard#index'"
|
|
69
|
-
rake 'db:create db:migrate'
|
|
70
|
-
|
|
71
|
-
run 'rm -f Gemfile Gemfile.lock'
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module TestAppPaths
|
|
4
|
-
module_function
|
|
5
|
-
|
|
6
|
-
def app_dir_name
|
|
7
|
-
"rails-#{Rails::VERSION::STRING}-#{ENV['DB'] || 'sqlite'}-aa#{ENV['AA'] || 'default'}"
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
# Absolute path under spec/rails/, used as RAILS_ROOT.
|
|
11
|
-
def app_root
|
|
12
|
-
File.expand_path("../rails/#{app_dir_name}", __dir__)
|
|
13
|
-
end
|
|
14
|
-
end
|
data/tasks/test.rake
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
require_relative '../spec/support/test_app_paths'
|
|
2
|
-
|
|
3
|
-
desc "Creates a test rails app for the specs to run against"
|
|
4
|
-
task :setup do
|
|
5
|
-
require 'rails/version'
|
|
6
|
-
|
|
7
|
-
db = ENV['DB'] || 'sqlite'
|
|
8
|
-
rails_db = case db
|
|
9
|
-
when 'mysql' then 'mysql'
|
|
10
|
-
when 'postgres', 'postgresql' then 'postgresql'
|
|
11
|
-
else 'sqlite3'
|
|
12
|
-
end
|
|
13
|
-
aa_v4 = ENV['AA']&.start_with?('4')
|
|
14
|
-
|
|
15
|
-
puts "[setup] ActiveAdmin: #{ENV['AA'] || '(Gemfile default)'} / Rails: #{Rails::VERSION::STRING} / DB: #{rails_db}"
|
|
16
|
-
|
|
17
|
-
rails_new_opts = %W(
|
|
18
|
-
--skip-turbolinks
|
|
19
|
-
--skip-spring
|
|
20
|
-
--skip-bootsnap
|
|
21
|
-
-d #{rails_db}
|
|
22
|
-
-m
|
|
23
|
-
spec/support/rails_template.rb
|
|
24
|
-
)
|
|
25
|
-
# v4 drops sprockets-rails (see Gemfile), so skip the asset pipeline to
|
|
26
|
-
# avoid the auto-generated `config/initializers/assets.rb` crashing at boot.
|
|
27
|
-
if aa_v4
|
|
28
|
-
rails_new_opts.unshift('--skip-asset-pipeline')
|
|
29
|
-
else
|
|
30
|
-
# Rails 8.1 wires importmap-rails into the generated ApplicationController
|
|
31
|
-
# (`stale_when_importmap_changes`). The AA 3 app uses Sprockets, not
|
|
32
|
-
# importmap, so that gem is absent and the controller raises NameError at
|
|
33
|
-
# boot. Skip JavaScript so the macro is never generated — the specs run on
|
|
34
|
-
# rack_test and never execute JS anyway.
|
|
35
|
-
rails_new_opts.unshift('--skip-javascript')
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
system "bundle exec rails new spec/rails/#{TestAppPaths.app_dir_name} #{rails_new_opts.join(' ')}"
|
|
39
|
-
end
|