active_importer 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
data/lib/active_importer/base.rb
CHANGED
@@ -10,6 +10,17 @@ describe ActiveImporter::Base do
|
|
10
10
|
]
|
11
11
|
end
|
12
12
|
|
13
|
+
let(:spreadsheet_data_with_errors) do
|
14
|
+
[
|
15
|
+
['List of employees'],
|
16
|
+
['Name', 'Birth Date', 'Department', 'Manager'],
|
17
|
+
['John Doe', '2013-10-25', 'IT'],
|
18
|
+
['Invalid', '2013-10-24', 'Management'],
|
19
|
+
['Invalid', '2013-10-24', 'Accounting'],
|
20
|
+
['Jane Doe', '2013-10-26', 'Sales'],
|
21
|
+
]
|
22
|
+
end
|
23
|
+
|
13
24
|
let(:importer) { EmployeeImporter.new('/dummy/file') }
|
14
25
|
|
15
26
|
before do
|
@@ -36,17 +47,36 @@ describe ActiveImporter::Base do
|
|
36
47
|
EmployeeImporter.import('/dummy/file')
|
37
48
|
end
|
38
49
|
|
39
|
-
context
|
40
|
-
let(:spreadsheet_data)
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
['Invalid', '2013-10-24', 'Accounting'],
|
46
|
-
['Jane Doe', '2013-10-26', 'Sales'],
|
47
|
-
]
|
50
|
+
context do
|
51
|
+
let(:spreadsheet_data) { spreadsheet_data_with_errors }
|
52
|
+
|
53
|
+
before do
|
54
|
+
expect(EmployeeImporter).to receive(:new).once.and_return(importer)
|
55
|
+
EmployeeImporter.import('/dummy/file')
|
48
56
|
end
|
49
57
|
|
58
|
+
describe '.row_processed_count' do
|
59
|
+
it 'reports the number of rows processed' do
|
60
|
+
expect(importer.row_processed_count).to eq(4)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
describe '.row_success_count' do
|
65
|
+
it 'reports the number of rows imported successfully' do
|
66
|
+
expect(importer.row_success_count).to eq(2)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
describe '.row_error_count' do
|
71
|
+
it 'reports the number of rows with errors' do
|
72
|
+
expect(importer.row_error_count).to eq(2)
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
context 'when there are rows with errors' do
|
78
|
+
let(:spreadsheet_data) { spreadsheet_data_with_errors }
|
79
|
+
|
50
80
|
it 'does not import those rows' do
|
51
81
|
expect { EmployeeImporter.import('/dummy/file') }.to change(Employee, :count).by(2)
|
52
82
|
end
|
@@ -100,6 +130,12 @@ describe ActiveImporter::Base do
|
|
100
130
|
it 'smartly skips any rows before the header' do
|
101
131
|
expect { EmployeeImporter.import('/dummy/file') }.to change(Employee, :count).by(2)
|
102
132
|
end
|
133
|
+
|
134
|
+
it 'reports the number of processed rows correctly' do
|
135
|
+
expect(EmployeeImporter).to receive(:new).once.and_return(importer)
|
136
|
+
EmployeeImporter.import('/dummy/file')
|
137
|
+
expect(importer.row_processed_count).to eq(2)
|
138
|
+
end
|
103
139
|
end
|
104
140
|
|
105
141
|
describe '.fetch_model' do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_importer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-11-
|
12
|
+
date: 2013-11-13 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: roo
|
@@ -112,7 +112,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
112
112
|
version: '0'
|
113
113
|
segments:
|
114
114
|
- 0
|
115
|
-
hash: -
|
115
|
+
hash: -3865447106793864810
|
116
116
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
117
117
|
none: false
|
118
118
|
requirements:
|
@@ -121,7 +121,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
121
121
|
version: '0'
|
122
122
|
segments:
|
123
123
|
- 0
|
124
|
-
hash: -
|
124
|
+
hash: -3865447106793864810
|
125
125
|
requirements: []
|
126
126
|
rubyforge_project:
|
127
127
|
rubygems_version: 1.8.23
|