active_interaction 5.3.0 → 5.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +13 -0
- data/README.md +2 -2
- data/lib/active_interaction/errors.rb +1 -1
- data/lib/active_interaction/version.rb +1 -1
- metadata +26 -112
- data/spec/active_interaction/array_input_spec.rb +0 -164
- data/spec/active_interaction/base_spec.rb +0 -536
- data/spec/active_interaction/concerns/active_modelable_spec.rb +0 -43
- data/spec/active_interaction/concerns/active_recordable_spec.rb +0 -47
- data/spec/active_interaction/concerns/hashable_spec.rb +0 -44
- data/spec/active_interaction/concerns/missable_spec.rb +0 -97
- data/spec/active_interaction/concerns/runnable_spec.rb +0 -395
- data/spec/active_interaction/errors_spec.rb +0 -223
- data/spec/active_interaction/filter/column_spec.rb +0 -85
- data/spec/active_interaction/filter_spec.rb +0 -58
- data/spec/active_interaction/filters/abstract_date_time_filter_spec.rb +0 -11
- data/spec/active_interaction/filters/abstract_numeric_filter_spec.rb +0 -11
- data/spec/active_interaction/filters/array_filter_spec.rb +0 -248
- data/spec/active_interaction/filters/boolean_filter_spec.rb +0 -85
- data/spec/active_interaction/filters/date_filter_spec.rb +0 -176
- data/spec/active_interaction/filters/date_time_filter_spec.rb +0 -187
- data/spec/active_interaction/filters/decimal_filter_spec.rb +0 -124
- data/spec/active_interaction/filters/file_filter_spec.rb +0 -38
- data/spec/active_interaction/filters/float_filter_spec.rb +0 -109
- data/spec/active_interaction/filters/hash_filter_spec.rb +0 -127
- data/spec/active_interaction/filters/integer_filter_spec.rb +0 -102
- data/spec/active_interaction/filters/interface_filter_spec.rb +0 -459
- data/spec/active_interaction/filters/object_filter_spec.rb +0 -235
- data/spec/active_interaction/filters/record_filter_spec.rb +0 -204
- data/spec/active_interaction/filters/string_filter_spec.rb +0 -58
- data/spec/active_interaction/filters/symbol_filter_spec.rb +0 -44
- data/spec/active_interaction/filters/time_filter_spec.rb +0 -249
- data/spec/active_interaction/grouped_input_spec.rb +0 -15
- data/spec/active_interaction/hash_input_spec.rb +0 -56
- data/spec/active_interaction/i18n_spec.rb +0 -111
- data/spec/active_interaction/inputs_spec.rb +0 -264
- data/spec/active_interaction/integration/array_interaction_spec.rb +0 -87
- data/spec/active_interaction/integration/boolean_interaction_spec.rb +0 -11
- data/spec/active_interaction/integration/date_interaction_spec.rb +0 -3
- data/spec/active_interaction/integration/date_time_interaction_spec.rb +0 -3
- data/spec/active_interaction/integration/file_interaction_spec.rb +0 -17
- data/spec/active_interaction/integration/float_interaction_spec.rb +0 -3
- data/spec/active_interaction/integration/hash_interaction_spec.rb +0 -106
- data/spec/active_interaction/integration/integer_interaction_spec.rb +0 -3
- data/spec/active_interaction/integration/interface_interaction_spec.rb +0 -18
- data/spec/active_interaction/integration/object_interaction_spec.rb +0 -12
- data/spec/active_interaction/integration/record_integration_spec.rb +0 -3
- data/spec/active_interaction/integration/string_interaction_spec.rb +0 -3
- data/spec/active_interaction/integration/symbol_interaction_spec.rb +0 -3
- data/spec/active_interaction/integration/time_interaction_spec.rb +0 -86
- data/spec/active_interaction/modules/validation_spec.rb +0 -55
- data/spec/spec_helper.rb +0 -22
- data/spec/support/concerns.rb +0 -13
- data/spec/support/filters.rb +0 -227
- data/spec/support/interactions.rb +0 -124
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f39aaac6de9ca228f9a223ef78ce39b17f7b934ac161e66067993b33968851c6
|
4
|
+
data.tar.gz: 9b16a1f1e0e0ecacb542709b103db93a79c9995a7cc90c5cff89d619ffcad204
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4c1796f310a05133999ad8b69ea16073f017856a4fb371d4f38381d8d69c3503b3b1b2e1e45126b4f8feec0723de622ce672d043b5e6a933840abd5825327235
|
7
|
+
data.tar.gz: b7af241f16b1554e186456e647e2d612446b4a1ad8bb9ae2a4fa903a5231fe4b04751e6ba4becd4c5d2edd69ebe4698ab27b82534a73a464ca631073a7f71160
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,13 @@
|
|
1
|
+
# [5.4.0][] (2024-11-23)
|
2
|
+
|
3
|
+
## Added
|
4
|
+
|
5
|
+
- [#579][] Support for Rails 8. Thanks @bvalentino!
|
6
|
+
|
7
|
+
## Fixed
|
8
|
+
|
9
|
+
- [#577][] Manually pull in the `ostruct` gem since it's being removed from stdlib.
|
10
|
+
|
1
11
|
# [5.3.0][] (2023-05-06)
|
2
12
|
|
3
13
|
## Added
|
@@ -1141,6 +1151,7 @@ Example.run
|
|
1141
1151
|
|
1142
1152
|
- Initial release.
|
1143
1153
|
|
1154
|
+
[5.3.0]: https://github.com/AaronLasseigne/active_interaction/compare/v5.2.0...v5.3.0
|
1144
1155
|
[5.2.0]: https://github.com/AaronLasseigne/active_interaction/compare/v5.1.1...v5.2.0
|
1145
1156
|
[5.1.1]: https://github.com/AaronLasseigne/active_interaction/compare/v5.1.0...v5.1.1
|
1146
1157
|
[5.1.0]: https://github.com/AaronLasseigne/active_interaction/compare/v5.0.0...v5.1.0
|
@@ -1374,3 +1385,5 @@ Example.run
|
|
1374
1385
|
[#545]: https://github.com/AaronLasseigne/active_interaction/issues/545
|
1375
1386
|
[#554]: https://github.com/AaronLasseigne/active_interaction/issues/554
|
1376
1387
|
[#553]: https://github.com/AaronLasseigne/active_interaction/issues/553
|
1388
|
+
[#577]: https://github.com/AaronLasseigne/active_interaction/issues/577
|
1389
|
+
[#579]: https://github.com/AaronLasseigne/active_interaction/pull/579
|
data/README.md
CHANGED
@@ -60,13 +60,13 @@ If ActiveModel deals with your nouns, then ActiveInteraction handles your verbs.
|
|
60
60
|
Add it to your Gemfile:
|
61
61
|
|
62
62
|
``` rb
|
63
|
-
gem 'active_interaction', '~> 5.
|
63
|
+
gem 'active_interaction', '~> 5.4'
|
64
64
|
```
|
65
65
|
|
66
66
|
Or install it manually:
|
67
67
|
|
68
68
|
``` sh
|
69
|
-
$ gem install active_interaction --version '~> 5.
|
69
|
+
$ gem install active_interaction --version '~> 5.4'
|
70
70
|
```
|
71
71
|
|
72
72
|
This project uses [Semantic Versioning][]. Check out [GitHub releases][] for a
|
@@ -56,7 +56,7 @@ module ActiveInteraction
|
|
56
56
|
options = detail.dup
|
57
57
|
error = options.delete(:error)
|
58
58
|
|
59
|
-
add(attribute, error, **options
|
59
|
+
add(attribute, error, **options, message: message) unless added?(attribute, error, **options)
|
60
60
|
else
|
61
61
|
merge_message!(attribute, detail, message)
|
62
62
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_interaction
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.
|
4
|
+
version: 5.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aaron Lasseigne
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2024-11-23 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activemodel
|
@@ -20,7 +20,7 @@ dependencies:
|
|
20
20
|
version: '5.2'
|
21
21
|
- - "<"
|
22
22
|
- !ruby/object:Gem::Version
|
23
|
-
version: '
|
23
|
+
version: '9'
|
24
24
|
type: :runtime
|
25
25
|
prerelease: false
|
26
26
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -30,7 +30,7 @@ dependencies:
|
|
30
30
|
version: '5.2'
|
31
31
|
- - "<"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '9'
|
34
34
|
- !ruby/object:Gem::Dependency
|
35
35
|
name: activesupport
|
36
36
|
requirement: !ruby/object:Gem::Requirement
|
@@ -40,7 +40,7 @@ dependencies:
|
|
40
40
|
version: '5.2'
|
41
41
|
- - "<"
|
42
42
|
- !ruby/object:Gem::Version
|
43
|
-
version: '
|
43
|
+
version: '9'
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
46
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -50,7 +50,7 @@ dependencies:
|
|
50
50
|
version: '5.2'
|
51
51
|
- - "<"
|
52
52
|
- !ruby/object:Gem::Version
|
53
|
-
version: '
|
53
|
+
version: '9'
|
54
54
|
- !ruby/object:Gem::Dependency
|
55
55
|
name: actionpack
|
56
56
|
requirement: !ruby/object:Gem::Requirement
|
@@ -93,6 +93,20 @@ dependencies:
|
|
93
93
|
- - "~>"
|
94
94
|
- !ruby/object:Gem::Version
|
95
95
|
version: '2.1'
|
96
|
+
- !ruby/object:Gem::Dependency
|
97
|
+
name: ostruct
|
98
|
+
requirement: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - "~>"
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '0.6'
|
103
|
+
type: :development
|
104
|
+
prerelease: false
|
105
|
+
version_requirements: !ruby/object:Gem::Requirement
|
106
|
+
requirements:
|
107
|
+
- - "~>"
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0.6'
|
96
110
|
- !ruby/object:Gem::Dependency
|
97
111
|
name: rake
|
98
112
|
requirement: !ruby/object:Gem::Requirement
|
@@ -127,14 +141,14 @@ dependencies:
|
|
127
141
|
requirements:
|
128
142
|
- - "~>"
|
129
143
|
- !ruby/object:Gem::Version
|
130
|
-
version: 1.
|
144
|
+
version: 1.68.0
|
131
145
|
type: :development
|
132
146
|
prerelease: false
|
133
147
|
version_requirements: !ruby/object:Gem::Requirement
|
134
148
|
requirements:
|
135
149
|
- - "~>"
|
136
150
|
- !ruby/object:Gem::Version
|
137
|
-
version: 1.
|
151
|
+
version: 1.68.0
|
138
152
|
- !ruby/object:Gem::Dependency
|
139
153
|
name: rubocop-rake
|
140
154
|
requirement: !ruby/object:Gem::Requirement
|
@@ -155,14 +169,14 @@ dependencies:
|
|
155
169
|
requirements:
|
156
170
|
- - "~>"
|
157
171
|
- !ruby/object:Gem::Version
|
158
|
-
version: 2.
|
172
|
+
version: 3.2.0
|
159
173
|
type: :development
|
160
174
|
prerelease: false
|
161
175
|
version_requirements: !ruby/object:Gem::Requirement
|
162
176
|
requirements:
|
163
177
|
- - "~>"
|
164
178
|
- !ruby/object:Gem::Version
|
165
|
-
version: 2.
|
179
|
+
version: 3.2.0
|
166
180
|
- !ruby/object:Gem::Dependency
|
167
181
|
name: sqlite3
|
168
182
|
requirement: !ruby/object:Gem::Requirement
|
@@ -249,56 +263,6 @@ files:
|
|
249
263
|
- lib/active_interaction/locale/pt-BR.yml
|
250
264
|
- lib/active_interaction/modules/validation.rb
|
251
265
|
- lib/active_interaction/version.rb
|
252
|
-
- spec/active_interaction/array_input_spec.rb
|
253
|
-
- spec/active_interaction/base_spec.rb
|
254
|
-
- spec/active_interaction/concerns/active_modelable_spec.rb
|
255
|
-
- spec/active_interaction/concerns/active_recordable_spec.rb
|
256
|
-
- spec/active_interaction/concerns/hashable_spec.rb
|
257
|
-
- spec/active_interaction/concerns/missable_spec.rb
|
258
|
-
- spec/active_interaction/concerns/runnable_spec.rb
|
259
|
-
- spec/active_interaction/errors_spec.rb
|
260
|
-
- spec/active_interaction/filter/column_spec.rb
|
261
|
-
- spec/active_interaction/filter_spec.rb
|
262
|
-
- spec/active_interaction/filters/abstract_date_time_filter_spec.rb
|
263
|
-
- spec/active_interaction/filters/abstract_numeric_filter_spec.rb
|
264
|
-
- spec/active_interaction/filters/array_filter_spec.rb
|
265
|
-
- spec/active_interaction/filters/boolean_filter_spec.rb
|
266
|
-
- spec/active_interaction/filters/date_filter_spec.rb
|
267
|
-
- spec/active_interaction/filters/date_time_filter_spec.rb
|
268
|
-
- spec/active_interaction/filters/decimal_filter_spec.rb
|
269
|
-
- spec/active_interaction/filters/file_filter_spec.rb
|
270
|
-
- spec/active_interaction/filters/float_filter_spec.rb
|
271
|
-
- spec/active_interaction/filters/hash_filter_spec.rb
|
272
|
-
- spec/active_interaction/filters/integer_filter_spec.rb
|
273
|
-
- spec/active_interaction/filters/interface_filter_spec.rb
|
274
|
-
- spec/active_interaction/filters/object_filter_spec.rb
|
275
|
-
- spec/active_interaction/filters/record_filter_spec.rb
|
276
|
-
- spec/active_interaction/filters/string_filter_spec.rb
|
277
|
-
- spec/active_interaction/filters/symbol_filter_spec.rb
|
278
|
-
- spec/active_interaction/filters/time_filter_spec.rb
|
279
|
-
- spec/active_interaction/grouped_input_spec.rb
|
280
|
-
- spec/active_interaction/hash_input_spec.rb
|
281
|
-
- spec/active_interaction/i18n_spec.rb
|
282
|
-
- spec/active_interaction/inputs_spec.rb
|
283
|
-
- spec/active_interaction/integration/array_interaction_spec.rb
|
284
|
-
- spec/active_interaction/integration/boolean_interaction_spec.rb
|
285
|
-
- spec/active_interaction/integration/date_interaction_spec.rb
|
286
|
-
- spec/active_interaction/integration/date_time_interaction_spec.rb
|
287
|
-
- spec/active_interaction/integration/file_interaction_spec.rb
|
288
|
-
- spec/active_interaction/integration/float_interaction_spec.rb
|
289
|
-
- spec/active_interaction/integration/hash_interaction_spec.rb
|
290
|
-
- spec/active_interaction/integration/integer_interaction_spec.rb
|
291
|
-
- spec/active_interaction/integration/interface_interaction_spec.rb
|
292
|
-
- spec/active_interaction/integration/object_interaction_spec.rb
|
293
|
-
- spec/active_interaction/integration/record_integration_spec.rb
|
294
|
-
- spec/active_interaction/integration/string_interaction_spec.rb
|
295
|
-
- spec/active_interaction/integration/symbol_interaction_spec.rb
|
296
|
-
- spec/active_interaction/integration/time_interaction_spec.rb
|
297
|
-
- spec/active_interaction/modules/validation_spec.rb
|
298
|
-
- spec/spec_helper.rb
|
299
|
-
- spec/support/concerns.rb
|
300
|
-
- spec/support/filters.rb
|
301
|
-
- spec/support/interactions.rb
|
302
266
|
homepage: https://github.com/AaronLasseigne/active_interaction
|
303
267
|
licenses:
|
304
268
|
- MIT
|
@@ -322,58 +286,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
322
286
|
- !ruby/object:Gem::Version
|
323
287
|
version: '0'
|
324
288
|
requirements: []
|
325
|
-
rubygems_version: 3.
|
289
|
+
rubygems_version: 3.5.22
|
326
290
|
signing_key:
|
327
291
|
specification_version: 4
|
328
292
|
summary: Manage application specific business logic.
|
329
|
-
test_files:
|
330
|
-
- spec/active_interaction/array_input_spec.rb
|
331
|
-
- spec/active_interaction/base_spec.rb
|
332
|
-
- spec/active_interaction/concerns/active_modelable_spec.rb
|
333
|
-
- spec/active_interaction/concerns/active_recordable_spec.rb
|
334
|
-
- spec/active_interaction/concerns/hashable_spec.rb
|
335
|
-
- spec/active_interaction/concerns/missable_spec.rb
|
336
|
-
- spec/active_interaction/concerns/runnable_spec.rb
|
337
|
-
- spec/active_interaction/errors_spec.rb
|
338
|
-
- spec/active_interaction/filter/column_spec.rb
|
339
|
-
- spec/active_interaction/filter_spec.rb
|
340
|
-
- spec/active_interaction/filters/abstract_date_time_filter_spec.rb
|
341
|
-
- spec/active_interaction/filters/abstract_numeric_filter_spec.rb
|
342
|
-
- spec/active_interaction/filters/array_filter_spec.rb
|
343
|
-
- spec/active_interaction/filters/boolean_filter_spec.rb
|
344
|
-
- spec/active_interaction/filters/date_filter_spec.rb
|
345
|
-
- spec/active_interaction/filters/date_time_filter_spec.rb
|
346
|
-
- spec/active_interaction/filters/decimal_filter_spec.rb
|
347
|
-
- spec/active_interaction/filters/file_filter_spec.rb
|
348
|
-
- spec/active_interaction/filters/float_filter_spec.rb
|
349
|
-
- spec/active_interaction/filters/hash_filter_spec.rb
|
350
|
-
- spec/active_interaction/filters/integer_filter_spec.rb
|
351
|
-
- spec/active_interaction/filters/interface_filter_spec.rb
|
352
|
-
- spec/active_interaction/filters/object_filter_spec.rb
|
353
|
-
- spec/active_interaction/filters/record_filter_spec.rb
|
354
|
-
- spec/active_interaction/filters/string_filter_spec.rb
|
355
|
-
- spec/active_interaction/filters/symbol_filter_spec.rb
|
356
|
-
- spec/active_interaction/filters/time_filter_spec.rb
|
357
|
-
- spec/active_interaction/grouped_input_spec.rb
|
358
|
-
- spec/active_interaction/hash_input_spec.rb
|
359
|
-
- spec/active_interaction/i18n_spec.rb
|
360
|
-
- spec/active_interaction/inputs_spec.rb
|
361
|
-
- spec/active_interaction/integration/array_interaction_spec.rb
|
362
|
-
- spec/active_interaction/integration/boolean_interaction_spec.rb
|
363
|
-
- spec/active_interaction/integration/date_interaction_spec.rb
|
364
|
-
- spec/active_interaction/integration/date_time_interaction_spec.rb
|
365
|
-
- spec/active_interaction/integration/file_interaction_spec.rb
|
366
|
-
- spec/active_interaction/integration/float_interaction_spec.rb
|
367
|
-
- spec/active_interaction/integration/hash_interaction_spec.rb
|
368
|
-
- spec/active_interaction/integration/integer_interaction_spec.rb
|
369
|
-
- spec/active_interaction/integration/interface_interaction_spec.rb
|
370
|
-
- spec/active_interaction/integration/object_interaction_spec.rb
|
371
|
-
- spec/active_interaction/integration/record_integration_spec.rb
|
372
|
-
- spec/active_interaction/integration/string_interaction_spec.rb
|
373
|
-
- spec/active_interaction/integration/symbol_interaction_spec.rb
|
374
|
-
- spec/active_interaction/integration/time_interaction_spec.rb
|
375
|
-
- spec/active_interaction/modules/validation_spec.rb
|
376
|
-
- spec/spec_helper.rb
|
377
|
-
- spec/support/concerns.rb
|
378
|
-
- spec/support/filters.rb
|
379
|
-
- spec/support/interactions.rb
|
293
|
+
test_files: []
|
@@ -1,164 +0,0 @@
|
|
1
|
-
RSpec.describe ActiveInteraction::ArrayInput do
|
2
|
-
subject(:input) do
|
3
|
-
described_class.new(filter,
|
4
|
-
value: value,
|
5
|
-
error: error,
|
6
|
-
index_errors: index_errors,
|
7
|
-
children: children
|
8
|
-
)
|
9
|
-
end
|
10
|
-
|
11
|
-
let(:filter) do
|
12
|
-
ActiveInteraction::ArrayFilter.new(:a, &block)
|
13
|
-
end
|
14
|
-
let(:block) { proc { integer } }
|
15
|
-
let(:value) { nil }
|
16
|
-
let(:error) { nil }
|
17
|
-
let(:index_errors) { false }
|
18
|
-
let(:children) { [] }
|
19
|
-
|
20
|
-
describe '#errors' do
|
21
|
-
context 'with no errors' do
|
22
|
-
it 'returns an empty array' do
|
23
|
-
expect(input.errors).to be_empty
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
context 'with an error on the array' do
|
28
|
-
let(:error) { ActiveInteraction::Filter::Error.new(filter, :invalid_type) }
|
29
|
-
|
30
|
-
it 'returns one error in the array' do
|
31
|
-
expect(input.errors.size).to be 1
|
32
|
-
|
33
|
-
error = input.errors.first
|
34
|
-
expect(error.name).to be filter.name
|
35
|
-
expect(error.type).to be :invalid_type
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
context 'with children with errors' do
|
40
|
-
let(:child_filter) { ActiveInteraction::IntegerFilter.new(:'') }
|
41
|
-
let(:child_error) { ActiveInteraction::Filter::Error.new(child_filter, :invalid_type) }
|
42
|
-
let(:child1) { ActiveInteraction::Input.new(child_filter, value: 'a', error: child_error) }
|
43
|
-
let(:child2) { ActiveInteraction::Input.new(child_filter, value: 'b', error: child_error) }
|
44
|
-
let(:children) { [child1, child2] }
|
45
|
-
|
46
|
-
context 'with an error on the array' do
|
47
|
-
let(:error) { ActiveInteraction::Filter::Error.new(filter, :invalid_type) }
|
48
|
-
|
49
|
-
it 'returns one error in the array' do
|
50
|
-
expect(input.errors.size).to be 1
|
51
|
-
|
52
|
-
error = input.errors.first
|
53
|
-
expect(error.name).to be filter.name
|
54
|
-
expect(error.type).to be :invalid_type
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
context 'without :index_errors' do
|
59
|
-
it 'promotes the first child error and returns it in the array' do
|
60
|
-
expect(input.errors.size).to be 1
|
61
|
-
|
62
|
-
error = input.errors.first
|
63
|
-
expect(error.name).to be filter.name
|
64
|
-
expect(error.type).to be :invalid_type
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
context 'with :index_errors' do
|
69
|
-
let(:index_errors) { true }
|
70
|
-
|
71
|
-
it 'lists all child errors in the array' do
|
72
|
-
expect(input.errors.size).to be 2
|
73
|
-
|
74
|
-
input.errors.each_with_index do |error, i|
|
75
|
-
expect(error.name).to be :"#{filter.name}[#{i}]"
|
76
|
-
expect(error.type).to be :invalid_type
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
context 'with a nested array' do
|
81
|
-
let(:invalid_value) { Object.new }
|
82
|
-
let(:array_child) do
|
83
|
-
filter = ActiveInteraction::IntegerFilter.new(:'')
|
84
|
-
ActiveInteraction::Input.new(filter,
|
85
|
-
value: invalid_value,
|
86
|
-
error: ActiveInteraction::Filter::Error.new(filter, :invalid_type)
|
87
|
-
)
|
88
|
-
end
|
89
|
-
let(:child_filter) { ActiveInteraction::ArrayFilter.new(:'') { integer } }
|
90
|
-
let(:child) do
|
91
|
-
described_class.new(child_filter,
|
92
|
-
value: [invalid_value],
|
93
|
-
index_errors: index_errors,
|
94
|
-
children: [array_child]
|
95
|
-
)
|
96
|
-
end
|
97
|
-
let(:children) { [child] }
|
98
|
-
|
99
|
-
it 'returns the error' do
|
100
|
-
expect(input.errors.size).to be 1
|
101
|
-
|
102
|
-
error = input.errors.first
|
103
|
-
expect(error.name).to be :"#{filter.name}[0][0]"
|
104
|
-
expect(error.type).to be :invalid_type
|
105
|
-
end
|
106
|
-
end
|
107
|
-
|
108
|
-
context 'with a nested hash' do
|
109
|
-
let(:hash_child_a) do
|
110
|
-
filter = ActiveInteraction::IntegerFilter.new(:a)
|
111
|
-
ActiveInteraction::Input.new(filter,
|
112
|
-
value: nil,
|
113
|
-
error: ActiveInteraction::Filter::Error.new(filter, :missing)
|
114
|
-
)
|
115
|
-
end
|
116
|
-
let(:hash_child_b) do
|
117
|
-
filter = ActiveInteraction::IntegerFilter.new(:b)
|
118
|
-
ActiveInteraction::Input.new(filter,
|
119
|
-
value: nil,
|
120
|
-
error: ActiveInteraction::Filter::Error.new(filter, :missing)
|
121
|
-
)
|
122
|
-
end
|
123
|
-
let(:child_filter) { ActiveInteraction::HashFilter.new(:'') { integer :a, :b } }
|
124
|
-
let(:child) do
|
125
|
-
ActiveInteraction::HashInput.new(child_filter, value: {}, children: { a: hash_child_a, b: hash_child_b })
|
126
|
-
end
|
127
|
-
let(:children) { [child] }
|
128
|
-
|
129
|
-
it 'list all child errors' do
|
130
|
-
expect(input.errors.size).to be 2
|
131
|
-
|
132
|
-
error = input.errors.first
|
133
|
-
expect(error.name).to be :"#{filter.name}[0].a"
|
134
|
-
expect(error.type).to be :missing
|
135
|
-
|
136
|
-
error = input.errors.last
|
137
|
-
expect(error.name).to be :"#{filter.name}[0].b"
|
138
|
-
expect(error.type).to be :missing
|
139
|
-
end
|
140
|
-
|
141
|
-
context 'with an invalid hash' do
|
142
|
-
let(:child_filter) { ActiveInteraction::HashFilter.new(:'') }
|
143
|
-
let(:child) do
|
144
|
-
ActiveInteraction::HashInput.new(child_filter,
|
145
|
-
value: Object.new,
|
146
|
-
error: ActiveInteraction::Filter::Error.new(child_filter, :invalid_type),
|
147
|
-
children: {}
|
148
|
-
)
|
149
|
-
end
|
150
|
-
let(:children) { [child] }
|
151
|
-
|
152
|
-
it 'list all child errors' do
|
153
|
-
expect(input.errors.size).to be 1
|
154
|
-
|
155
|
-
error = input.errors.first
|
156
|
-
expect(error.name).to be :"#{filter.name}[0]"
|
157
|
-
expect(error.type).to be :invalid_type
|
158
|
-
end
|
159
|
-
end
|
160
|
-
end
|
161
|
-
end
|
162
|
-
end
|
163
|
-
end
|
164
|
-
end
|