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.
Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/lib/active_admin_import/version.rb +1 -1
  3. metadata +2 -42
  4. data/.github/workflows/test.yml +0 -219
  5. data/.gitignore +0 -19
  6. data/.rubocop.yml +0 -43
  7. data/Gemfile +0 -37
  8. data/Rakefile +0 -5
  9. data/active_admin_import.gemspec +0 -22
  10. data/spec/fixtures/files/author.csv +0 -2
  11. data/spec/fixtures/files/author_broken_header.csv +0 -2
  12. data/spec/fixtures/files/author_invalid.csv +0 -2
  13. data/spec/fixtures/files/author_invalid_format.txt +0 -2
  14. data/spec/fixtures/files/authors.csv +0 -3
  15. data/spec/fixtures/files/authors_blank_header_end.csv +0 -3
  16. data/spec/fixtures/files/authors_blank_header_middle.csv +0 -3
  17. data/spec/fixtures/files/authors_bom.csv +0 -3
  18. data/spec/fixtures/files/authors_empty_header.csv +0 -3
  19. data/spec/fixtures/files/authors_invalid_db.csv +0 -3
  20. data/spec/fixtures/files/authors_invalid_model.csv +0 -3
  21. data/spec/fixtures/files/authors_many.csv +0 -6
  22. data/spec/fixtures/files/authors_no_headers.csv +0 -2
  23. data/spec/fixtures/files/authors_values_exceeded_headers.csv +0 -3
  24. data/spec/fixtures/files/authors_win1251_win_endline.csv +0 -3
  25. data/spec/fixtures/files/authors_with_ids.csv +0 -3
  26. data/spec/fixtures/files/authors_with_semicolons.csv +0 -3
  27. data/spec/fixtures/files/authors_with_tabs.tsv +0 -3
  28. data/spec/fixtures/files/empty.csv +0 -0
  29. data/spec/fixtures/files/only_headers.csv +0 -1
  30. data/spec/fixtures/files/post_comments.csv +0 -3
  31. data/spec/fixtures/files/posts.csv +0 -4
  32. data/spec/fixtures/files/posts_for_author.csv +0 -3
  33. data/spec/fixtures/files/posts_for_author_no_headers.csv +0 -2
  34. data/spec/import_result_spec.rb +0 -39
  35. data/spec/import_spec.rb +0 -859
  36. data/spec/model_spec.rb +0 -6
  37. data/spec/spec_helper.rb +0 -54
  38. data/spec/support/active_model_lint.rb +0 -15
  39. data/spec/support/admin.rb +0 -32
  40. data/spec/support/import_form_selectors.rb +0 -24
  41. data/spec/support/rails_template.rb +0 -71
  42. data/spec/support/test_app_paths.rb +0 -14
  43. data/tasks/test.rake +0 -39
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f6e8f38e5549666b0bc1cd0d996f53fc0bebdfa5449750434fa4dbeb2ec4bc3b
4
- data.tar.gz: 47298769ad0b0c7dfae9b21b470cf78b1164e6978aeb374ee9d4991de037814e
3
+ metadata.gz: 819977aed599842eef5880ab33a1c266653ba87b940e622eb0f94d14441333db
4
+ data.tar.gz: aca4a062d3febdafe940182362fbd2405f2f9d7a38bd9bc0b7e8f482bbb14a99
5
5
  SHA512:
6
- metadata.gz: b45454513b6a1312b1dd0490ab0f34def99e0928177a3fc209220be9fcb7d6cb371b0c9d086818ef8318f62d97ef39f8f38264acdef32d5795af02c90d54332c
7
- data.tar.gz: c8a7a5aa657e2e78f9678e5e4da6ab348af718473b5431bdbbd84393050b58da560970da80b4d81904e901ddc13e7ca1f98b63e5bcb2367c41c8f2aa023cc7d3
6
+ metadata.gz: '096418fa77f5de062e20f395d973edf6b342240bc050ebcf8a08abf616ce7aab293cac48d4cfb87d80a9a55f0dccf32534c28c3432c9c95f1281b215e3a7b670'
7
+ data.tar.gz: 706bb15939f91914f40965820296d27cb0db8cdef876882f6b2fe94c94c8ddf9d3decae457278d7e7a124910c5ba602337ea3eef2ac4a97a461011038077c256
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ActiveAdminImport
4
- VERSION = '8.0.0'
4
+ VERSION = '8.0.1'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_admin_import
3
3
  version: !ruby/object:Gem::Version
4
- version: 8.0.0
4
+ version: 8.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Igor Fedoronchuk
@@ -78,14 +78,8 @@ executables: []
78
78
  extensions: []
79
79
  extra_rdoc_files: []
80
80
  files:
81
- - ".github/workflows/test.yml"
82
- - ".gitignore"
83
- - ".rubocop.yml"
84
- - Gemfile
85
81
  - LICENSE
86
82
  - README.md
87
- - Rakefile
88
- - active_admin_import.gemspec
89
83
  - app/views/admin/import.html.erb
90
84
  - config/locales/de.yml
91
85
  - config/locales/en.yml
@@ -109,40 +103,6 @@ files:
109
103
  - lib/active_admin_import/model.rb
110
104
  - lib/active_admin_import/options.rb
111
105
  - lib/active_admin_import/version.rb
112
- - spec/fixtures/files/author.csv
113
- - spec/fixtures/files/author_broken_header.csv
114
- - spec/fixtures/files/author_invalid.csv
115
- - spec/fixtures/files/author_invalid_format.txt
116
- - spec/fixtures/files/authors.csv
117
- - spec/fixtures/files/authors_blank_header_end.csv
118
- - spec/fixtures/files/authors_blank_header_middle.csv
119
- - spec/fixtures/files/authors_bom.csv
120
- - spec/fixtures/files/authors_empty_header.csv
121
- - spec/fixtures/files/authors_invalid_db.csv
122
- - spec/fixtures/files/authors_invalid_model.csv
123
- - spec/fixtures/files/authors_many.csv
124
- - spec/fixtures/files/authors_no_headers.csv
125
- - spec/fixtures/files/authors_values_exceeded_headers.csv
126
- - spec/fixtures/files/authors_win1251_win_endline.csv
127
- - spec/fixtures/files/authors_with_ids.csv
128
- - spec/fixtures/files/authors_with_semicolons.csv
129
- - spec/fixtures/files/authors_with_tabs.tsv
130
- - spec/fixtures/files/empty.csv
131
- - spec/fixtures/files/only_headers.csv
132
- - spec/fixtures/files/post_comments.csv
133
- - spec/fixtures/files/posts.csv
134
- - spec/fixtures/files/posts_for_author.csv
135
- - spec/fixtures/files/posts_for_author_no_headers.csv
136
- - spec/import_result_spec.rb
137
- - spec/import_spec.rb
138
- - spec/model_spec.rb
139
- - spec/spec_helper.rb
140
- - spec/support/active_model_lint.rb
141
- - spec/support/admin.rb
142
- - spec/support/import_form_selectors.rb
143
- - spec/support/rails_template.rb
144
- - spec/support/test_app_paths.rb
145
- - tasks/test.rake
146
106
  homepage: https://github.com/activeadmin-plugins/active_admin_import
147
107
  licenses:
148
108
  - MIT
@@ -161,7 +121,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
161
121
  - !ruby/object:Gem::Version
162
122
  version: '0'
163
123
  requirements: []
164
- rubygems_version: 3.7.1
124
+ rubygems_version: 3.6.9
165
125
  specification_version: 4
166
126
  summary: ActiveAdmin import based on activerecord-import gem.
167
127
  test_files: []
@@ -1,219 +0,0 @@
1
- name: CI
2
- on:
3
- pull_request:
4
- push:
5
- branches: [master]
6
-
7
- permissions:
8
- contents: read
9
- pages: write
10
- id-token: write
11
-
12
- jobs:
13
- test:
14
- name: Ruby ${{ matrix.ruby }} / Rails ${{ matrix.rails }} / AA ${{ matrix.activeadmin }} / SQLite
15
- runs-on: ubuntu-latest
16
- strategy:
17
- fail-fast: false
18
- matrix:
19
- ruby: ['3.3', '3.4', '4.0']
20
- rails: ['7.2.0', '8.0.0', '8.1.0']
21
- activeadmin: ['3.2.0', '3.3.0', '3.4.0', '3.5.1']
22
- exclude:
23
- # ActiveAdmin 3.2.0 predates Rails 8 support.
24
- - rails: '8.0.0'
25
- activeadmin: '3.2.0'
26
- - rails: '8.1.0'
27
- activeadmin: '3.2.0'
28
- include:
29
- # ActiveAdmin 4 requires railties >= 7.2, so cover its floor and the
30
- # newest supported Rails releases.
31
- - ruby: '3.4'
32
- rails: '7.2.0'
33
- activeadmin: '4.0.0.beta22'
34
- - ruby: '3.4'
35
- rails: '8.0.0'
36
- activeadmin: '4.0.0.beta22'
37
- - ruby: '3.4'
38
- rails: '8.1.0'
39
- activeadmin: '4.0.0.beta22'
40
- env:
41
- RAILS: ${{ matrix.rails }}
42
- AA: ${{ matrix.activeadmin }}
43
- steps:
44
- - uses: actions/checkout@v4
45
- - uses: ruby/setup-ruby@v1
46
- with:
47
- ruby-version: ${{ matrix.ruby }}
48
- bundler-cache: true
49
- - name: AA v4 environment summary
50
- if: matrix.activeadmin == '4.0.0.beta22'
51
- run: |
52
- bundle exec gem list activeadmin
53
- bundle info activeadmin
54
- - name: Run tests
55
- run: bundle exec rspec spec
56
- test-mysql:
57
- name: Ruby 3.4 / Rails 8.0.0 / AA 3.5.1 / MySQL 8.0
58
- runs-on: ubuntu-latest
59
- env:
60
- RAILS: '8.0.0'
61
- AA: '3.5.1'
62
- DB: mysql
63
- DB_HOST: 127.0.0.1
64
- DB_PORT: 3306
65
- DB_USERNAME: root
66
- DB_PASSWORD: root
67
- services:
68
- mysql:
69
- image: mysql:8.0
70
- env:
71
- MYSQL_ROOT_PASSWORD: root
72
- MYSQL_DATABASE: active_admin_import_test
73
- ports:
74
- - 3306:3306
75
- options: >-
76
- --health-cmd="mysqladmin ping -h localhost -uroot -proot"
77
- --health-interval=10s
78
- --health-timeout=5s
79
- --health-retries=10
80
- steps:
81
- - uses: actions/checkout@v4
82
- - uses: ruby/setup-ruby@v1
83
- with:
84
- ruby-version: '3.4'
85
- bundler-cache: true
86
- - name: Run tests
87
- run: bundle exec rspec spec
88
- test-postgres:
89
- name: Ruby 3.4 / Rails 8.0.0 / AA 3.5.1 / PostgreSQL 16
90
- runs-on: ubuntu-latest
91
- env:
92
- RAILS: '8.0.0'
93
- AA: '3.5.1'
94
- DB: postgres
95
- DB_HOST: 127.0.0.1
96
- DB_PORT: 5432
97
- DB_USERNAME: postgres
98
- DB_PASSWORD: postgres
99
- services:
100
- postgres:
101
- image: postgres:16
102
- env:
103
- POSTGRES_USER: postgres
104
- POSTGRES_PASSWORD: postgres
105
- POSTGRES_DB: active_admin_import_test
106
- ports:
107
- - 5432:5432
108
- options: >-
109
- --health-cmd="pg_isready -U postgres"
110
- --health-interval=10s
111
- --health-timeout=5s
112
- --health-retries=10
113
- steps:
114
- - uses: actions/checkout@v4
115
- - uses: ruby/setup-ruby@v1
116
- with:
117
- ruby-version: '3.4'
118
- bundler-cache: true
119
- - name: Run tests
120
- run: bundle exec rspec spec
121
- test-postgres-aa4:
122
- name: Ruby 3.4 / Rails 8.0.0 / AA 4.0.0.beta22 / PostgreSQL 16
123
- runs-on: ubuntu-latest
124
- env:
125
- RAILS: '8.0.0'
126
- AA: '4.0.0.beta22'
127
- DB: postgres
128
- DB_HOST: 127.0.0.1
129
- DB_PORT: 5432
130
- DB_USERNAME: postgres
131
- DB_PASSWORD: postgres
132
- services:
133
- postgres:
134
- image: postgres:16
135
- env:
136
- POSTGRES_USER: postgres
137
- POSTGRES_PASSWORD: postgres
138
- POSTGRES_DB: active_admin_import_test
139
- ports:
140
- - 5432:5432
141
- options: >-
142
- --health-cmd="pg_isready -U postgres"
143
- --health-interval=10s
144
- --health-timeout=5s
145
- --health-retries=10
146
- steps:
147
- - uses: actions/checkout@v4
148
- - uses: ruby/setup-ruby@v1
149
- with:
150
- ruby-version: '3.4'
151
- bundler-cache: true
152
- - name: AA v4 environment summary
153
- run: |
154
- bundle exec gem list activeadmin
155
- bundle info activeadmin
156
- - name: Run tests
157
- run: bundle exec rspec spec
158
- coverage:
159
- name: Coverage
160
- runs-on: ubuntu-latest
161
- steps:
162
- - uses: actions/checkout@v4
163
- - uses: ruby/setup-ruby@v1
164
- with:
165
- ruby-version: '3.4'
166
- bundler-cache: true
167
- - name: Run tests with coverage
168
- run: bundle exec rspec spec
169
- - name: Upload coverage
170
- uses: actions/upload-artifact@v4
171
- with:
172
- name: coverage
173
- path: coverage/
174
-
175
- - name: Generate badge.json
176
- run: |
177
- LAST_RUN="coverage/.last_run.json"
178
- if [ ! -f "$LAST_RUN" ]; then
179
- mkdir -p badge
180
- echo '{"schemaVersion":1,"label":"coverage","message":"unknown","color":"lightgrey"}' > badge/badge.json
181
- exit 0
182
- fi
183
- PERCENT=$(ruby -rjson -e "puts JSON.parse(File.read('$LAST_RUN')).dig('result','line').round(1)")
184
- PERCENT_NUM=$(ruby -rjson -e "puts JSON.parse(File.read('$LAST_RUN')).dig('result','line')")
185
- if ruby -e "exit(($PERCENT_NUM >= 90) ? 0 : 1)"; then COLOR="brightgreen"
186
- elif ruby -e "exit(($PERCENT_NUM >= 75) ? 0 : 1)"; then COLOR="green"
187
- elif ruby -e "exit(($PERCENT_NUM >= 60) ? 0 : 1)"; then COLOR="yellow"
188
- else COLOR="red"; fi
189
- mkdir -p badge
190
- echo "{\"schemaVersion\":1,\"label\":\"coverage\",\"message\":\"${PERCENT}%\",\"color\":\"${COLOR}\"}" > badge/badge.json
191
-
192
- - name: Upload badge artifact
193
- uses: actions/upload-artifact@v4
194
- with:
195
- name: coverage-badge
196
- path: badge
197
-
198
- deploy-coverage:
199
- needs: coverage
200
- if: github.ref == 'refs/heads/master' && github.event_name == 'push'
201
- runs-on: ubuntu-latest
202
- environment:
203
- name: github-pages
204
- url: ${{ steps.deployment.outputs.page_url }}
205
- steps:
206
- - name: Download coverage badge
207
- uses: actions/download-artifact@v4
208
- with:
209
- name: coverage-badge
210
- path: .
211
- - name: Setup Pages
212
- uses: actions/configure-pages@v5
213
- - name: Upload Pages artifact
214
- uses: actions/upload-pages-artifact@v3
215
- with:
216
- path: .
217
- - name: Deploy to GitHub Pages
218
- id: deployment
219
- uses: actions/deploy-pages@v4
data/.gitignore DELETED
@@ -1,19 +0,0 @@
1
- *.rbc
2
- *.sassc
3
- .sass-cache
4
- capybara-*.html
5
- .rspec
6
- /.bundle
7
- /vendor/bundle
8
- /log/*
9
- /tmp/*
10
- /db/*.sqlite3
11
- /public/system/*
12
- /coverage/
13
- /spec/tmp/*
14
- **.orig
15
- rerun.txt
16
- pickle-email-*.html
17
- pkg
18
- spec/rails
19
- Gemfile.lock
data/.rubocop.yml DELETED
@@ -1,43 +0,0 @@
1
- AllCops:
2
- TargetRubyVersion: 2.3
3
- Exclude:
4
- - 'spec/fixtures/**/*'
5
-
6
- Style/IndentationWidth:
7
- Width: 2
8
-
9
- Style/Documentation:
10
- Enabled: false
11
-
12
- Style/Encoding:
13
- Enabled: false
14
-
15
- Style/MultilineOperationIndentation:
16
- EnforcedStyle: indented
17
-
18
- Style/FirstParameterIndentation:
19
- EnforcedStyle: special_for_inner_method_call_in_parentheses
20
-
21
- Metrics/AbcSize:
22
- Max: 25
23
-
24
- Metrics/LineLength:
25
- Max: 120
26
-
27
- Metrics/MethodLength:
28
- Max: 40
29
-
30
- Metrics/ClassLength:
31
- Max: 250
32
-
33
- Metrics/ModuleLength:
34
- Max: 250
35
-
36
- Metrics/CyclomaticComplexity:
37
- Max: 8
38
-
39
- Metrics/PerceivedComplexity:
40
- Max: 8
41
-
42
- Rails:
43
- Enabled: true
data/Gemfile DELETED
@@ -1,37 +0,0 @@
1
- source 'https://rubygems.org'
2
- gemspec
3
-
4
- default_rails_version = '8.0.0'
5
- default_activeadmin_version = '3.5.1'
6
-
7
- # `~> 4.0.0.beta22` would admit 4.0.0 GA — pin prereleases exactly so the
8
- # CI cell tests the AA build it claims to test.
9
- aa_version = ENV['AA'] || default_activeadmin_version
10
- aa_op = aa_version.match?(/[a-z]/) ? '=' : '~>'
11
-
12
- gem 'rails', "~> #{ENV['RAILS'] || default_rails_version}"
13
- gem 'activeadmin', "#{aa_op} #{aa_version}"
14
-
15
- if ENV['AA']&.start_with?('4')
16
- # AA 4 uses Tailwind + importmap; sass-rails conflicts with Tailwind v4.
17
- gem 'cssbundling-rails'
18
- gem 'importmap-rails'
19
- else
20
- gem 'sprockets-rails'
21
- gem 'sass-rails'
22
- end
23
-
24
- group :test do
25
- gem 'simplecov', require: false
26
- gem 'rspec-rails'
27
- case ENV['DB']
28
- when 'mysql'
29
- gem 'mysql2'
30
- when 'postgres', 'postgresql'
31
- gem 'pg'
32
- else
33
- gem 'sqlite3', '~> 2.0'
34
- end
35
- gem 'database_cleaner'
36
- gem 'capybara'
37
- end
data/Rakefile DELETED
@@ -1,5 +0,0 @@
1
- require "bundler"
2
- require 'rake'
3
- Bundler.setup
4
- Bundler::GemHelper.install_tasks
5
- FileList['tasks/**/*.rake'].each { |task| import task }
@@ -1,22 +0,0 @@
1
- # -*- encoding: utf-8 -*-
2
- # frozen_string_literal: true
3
- require File.expand_path('../lib/active_admin_import/version', __FILE__)
4
-
5
- Gem::Specification.new do |gem|
6
- gem.authors = ['Igor Fedoronchuk']
7
- gem.email = ['fedoronchuk@gmail.com']
8
- gem.description = 'The most efficient way to import for Active Admin'
9
- gem.summary = 'ActiveAdmin import based on activerecord-import gem.'
10
- gem.homepage = 'https://github.com/activeadmin-plugins/active_admin_import'
11
- gem.license = 'MIT'
12
- gem.required_ruby_version = '>= 3.3.0'
13
- gem.files = `git ls-files`.split($OUTPUT_RECORD_SEPARATOR)
14
- gem.executables = gem.files.grep(%r{^bin/}).map { |f| File.basename(f) }
15
- gem.name = 'active_admin_import'
16
- gem.require_paths = ['lib']
17
- gem.version = ActiveAdminImport::VERSION
18
- gem.add_runtime_dependency 'activerecord-import', '>= 2.0'
19
- gem.add_runtime_dependency 'rchardet', '>= 1.6'
20
- gem.add_runtime_dependency 'rubyzip', '>= 1.2'
21
- gem.add_dependency 'activeadmin', '>= 3.0', '< 4.1'
22
- end
@@ -1,2 +0,0 @@
1
- Name,Last name,Birthday
2
- John,Doe,1986-05-01
@@ -1,2 +0,0 @@
1
- Name,Second name,Birthday
2
- John,Doe,1986-05-01
@@ -1,2 +0,0 @@
1
- Name,Last name,Birthday
2
- ,Doe,1986-05-01
@@ -1,2 +0,0 @@
1
- Name,Last name,Birthday
2
- John,Doe,1986-05-01
@@ -1,3 +0,0 @@
1
- Birthday,Name,Last name
2
- 1986-05-01,John,Doe
3
- 1988-11-16,Jane,Roe
@@ -1,3 +0,0 @@
1
- Name,Last name,Birthday,
2
- John,Doe,1986-05-01,x
3
- Jane,Roe,1988-11-16,y
@@ -1,3 +0,0 @@
1
- Name,,Last name,Birthday
2
- John,x,Doe,1986-05-01
3
- Jane,y,Roe,1988-11-16
@@ -1,3 +0,0 @@
1
- Name,Last name,Birthday
2
- John,Doe,1986-05-01
3
- Jane,Roe,1988-11-16
@@ -1,3 +0,0 @@
1
- ,Name,Last name,Birthday
2
- x,John,Doe,1986-05-01
3
- y,Jane,Roe,1988-11-16
@@ -1,3 +0,0 @@
1
- Name,Last name,Birthday
2
- John,Doe,1986-05-01
3
- John,Doe,1986-05-01
@@ -1,3 +0,0 @@
1
- Name,Last name,Birthday
2
- Jim,Doe,1986-05-01
3
- Jane,Roe,1986-05-01
@@ -1,6 +0,0 @@
1
- Birthday,Name,Last name
2
- 1986-05-01,John,Doe
3
- 1988-11-16,Jane,Roe
4
- 1990-01-01,Jack,Smith
5
- 1991-02-02,Jill,Jones
6
- 1992-03-03,Joe,Brown
@@ -1,2 +0,0 @@
1
- John,Doe,1986-05-01
2
- Jane,Roe,1988-11-16
@@ -1,3 +0,0 @@
1
- Birthday,Name,Last name
2
- 1986-05-01,John,Doe
3
- 1988-11-16,Jane,Roe, exceeded value
@@ -1,3 +0,0 @@
1
- Name,Last name,Birthday
2
- �������,���������,1986-05-01
3
- Jane,Roe,1988-11-16
@@ -1,3 +0,0 @@
1
- Id,Name,Last name,Birthday
2
- 1,John,Doe,1986-05-01
3
- 2,Jane,Roe,1988-11-16
@@ -1,3 +0,0 @@
1
- Name;Last name;Birthday
2
- John;Doe;1986-05-01
3
- Jane;Roe;1988-11-16
@@ -1,3 +0,0 @@
1
- Name Last name Birthday
2
- John Doe 1986-05-01
3
- Jane Roe 1988-11-16
File without changes
@@ -1 +0,0 @@
1
- Name,Last name,Birthday
@@ -1,3 +0,0 @@
1
- "Body"
2
- "First comment"
3
- "Second comment"
@@ -1,4 +0,0 @@
1
- "Title","Body","Author Name"
2
- "title1","some body","John"
3
- "title2","some body","Jane"
4
-
@@ -1,3 +0,0 @@
1
- "Title","Body"
2
- "title1","some body"
3
- "title2","some body"
@@ -1,2 +0,0 @@
1
- "title1","some body"
2
- "title2","some body"
@@ -1,39 +0,0 @@
1
- # frozen_string_literal: true
2
- require 'spec_helper'
3
-
4
- describe ActiveAdminImport::ImportResult do
5
- context 'failed_message' do
6
- let(:import_result) { ActiveAdminImport::ImportResult.new }
7
-
8
-
9
- let(:failed_instances) do
10
- [
11
- Author.new(last_name: 'Doe').tap {|r| r.errors.add(:last_name, :taken) },
12
- Author.new(name: "", last_name: 'Doe').tap {|r| r.errors.add(:name, :blank); r.errors.add(:last_name, :taken) },
13
- Author.new.tap {|r| r.errors.add(:base, 'custom') }
14
- ]
15
- end
16
-
17
- before do
18
- @result = double \
19
- failed_instances: failed_instances
20
- end
21
-
22
- it 'should work without any failed instances' do
23
- expect(import_result.failed_message).to eq('')
24
- end
25
-
26
- it 'should work' do
27
- import_result.add(@result, 4)
28
- expect(import_result.failed_message)
29
- .to eq(
30
- "Last name has already been taken - Doe ; Name can't be blank - , Last name has already been taken - Doe ; custom"
31
- )
32
- end
33
-
34
- it 'should work on limit param' do
35
- import_result.add(@result, 4)
36
- expect(import_result.failed_message(limit: 1)).to eq('Last name has already been taken - Doe')
37
- end
38
- end
39
- end