simple_params 2.0.2 → 2.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.bundle/install.log +30 -0
- data/Appraisals +11 -1
- data/Gemfile.lock +1 -4
- data/gemfiles/activemodel_5.gemfile.lock +1 -4
- data/gemfiles/activemodel_5_1.gemfile +8 -0
- data/gemfiles/activemodel_5_1.gemfile.lock +75 -0
- data/gemfiles/activemodel_5_2.gemfile +8 -0
- data/gemfiles/activemodel_5_2.gemfile.lock +75 -0
- data/lib/simple_params/errors.rb +7 -6
- data/lib/simple_params/version.rb +1 -1
- data/spec/errors_spec.rb +6 -6
- data/spec/rails_integration_spec.rb +27 -1
- metadata +7 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 81beac7b9d60ea3e31bcf4043568cb9700090b65
|
4
|
+
data.tar.gz: ed9d20b152f2cac724265ba086cf089ef1106ec6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b4715f84b1ae13d318d13f165e6fd68737883bf0c16e7e6898d400726df98c40b7d30339dda1cbf19bf5429d315a28c13a34850ed7fad239f1aa5cf11b080daa
|
7
|
+
data.tar.gz: 331c41c42a4f16d0929fde4b5dd02a466b3e92134361135d5989116d225c05528660054cf4ceb1e552d9593ae4099a9b2f4a4fde60806ca6af94da9eea3d1aba
|
data/.bundle/install.log
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
# Logfile created on 2019-07-23 01:04:55 -0400 by logger.rb/56815
|
2
|
+
I, [2019-07-23T01:04:55.252827 #83076] INFO -- : 0: rake (10.4.2) from /Users/brycesenz/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/specifications/rake-10.4.2.gemspec
|
3
|
+
I, [2019-07-23T01:04:55.253099 #83076] INFO -- : 0: concurrent-ruby (1.0.5) from /Users/brycesenz/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/specifications/concurrent-ruby-1.0.5.gemspec
|
4
|
+
I, [2019-07-23T01:04:55.253337 #83076] INFO -- : 0: i18n (0.9.0) from /Users/brycesenz/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/specifications/i18n-0.9.0.gemspec
|
5
|
+
I, [2019-07-23T01:04:55.253564 #83076] INFO -- : 0: minitest (5.10.3) from /Users/brycesenz/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/specifications/minitest-5.10.3.gemspec
|
6
|
+
I, [2019-07-23T01:04:55.253767 #83076] INFO -- : 0: thread_safe (0.3.6) from /Users/brycesenz/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/specifications/thread_safe-0.3.6.gemspec
|
7
|
+
I, [2019-07-23T01:04:55.253995 #83076] INFO -- : 0: tzinfo (1.2.4) from /Users/brycesenz/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/specifications/tzinfo-1.2.4.gemspec
|
8
|
+
I, [2019-07-23T01:04:55.254211 #83076] INFO -- : 0: activesupport (5.1.4) from /Users/brycesenz/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/specifications/activesupport-5.1.4.gemspec
|
9
|
+
I, [2019-07-23T01:04:55.254435 #83076] INFO -- : 0: activemodel (5.1.4) from /Users/brycesenz/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/specifications/activemodel-5.1.4.gemspec
|
10
|
+
I, [2019-07-23T01:04:55.254683 #83076] INFO -- : 0: bundler (1.5.0) from /Users/brycesenz/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/specifications/bundler-1.5.0.gemspec
|
11
|
+
I, [2019-07-23T01:04:55.254903 #83076] INFO -- : 0: thor (0.20.0) from /Users/brycesenz/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/specifications/thor-0.20.0.gemspec
|
12
|
+
I, [2019-07-23T01:04:55.255106 #83076] INFO -- : 0: appraisal (2.2.0) from /Users/brycesenz/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/specifications/appraisal-2.2.0.gemspec
|
13
|
+
I, [2019-07-23T01:04:55.255294 #83076] INFO -- : 0: descendants_tracker (0.0.4) from /Users/brycesenz/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/specifications/descendants_tracker-0.0.4.gemspec
|
14
|
+
I, [2019-07-23T01:04:55.255477 #83076] INFO -- : 0: ice_nine (0.11.2) from /Users/brycesenz/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/specifications/ice_nine-0.11.2.gemspec
|
15
|
+
I, [2019-07-23T01:04:55.255661 #83076] INFO -- : 0: axiom-types (0.1.1) from /Users/brycesenz/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/specifications/axiom-types-0.1.1.gemspec
|
16
|
+
I, [2019-07-23T01:04:55.255848 #83076] INFO -- : 0: coderay (1.1.0) from /Users/brycesenz/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/specifications/coderay-1.1.0.gemspec
|
17
|
+
I, [2019-07-23T01:04:55.256053 #83076] INFO -- : 0: coercible (1.0.0) from /Users/brycesenz/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/specifications/coercible-1.0.0.gemspec
|
18
|
+
I, [2019-07-23T01:04:55.256260 #83076] INFO -- : 0: diff-lcs (1.2.5) from /Users/brycesenz/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/specifications/diff-lcs-1.2.5.gemspec
|
19
|
+
I, [2019-07-23T01:04:55.256437 #83076] INFO -- : 0: equalizer (0.0.11) from /Users/brycesenz/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/specifications/equalizer-0.0.11.gemspec
|
20
|
+
I, [2019-07-23T01:04:55.256639 #83076] INFO -- : 0: method_source (0.8.2) from /Users/brycesenz/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/specifications/method_source-0.8.2.gemspec
|
21
|
+
I, [2019-07-23T01:04:55.256841 #83076] INFO -- : 0: slop (3.6.0) from /Users/brycesenz/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/specifications/slop-3.6.0.gemspec
|
22
|
+
I, [2019-07-23T01:04:55.257038 #83076] INFO -- : 0: pry (0.10.1) from /Users/brycesenz/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/specifications/pry-0.10.1.gemspec
|
23
|
+
I, [2019-07-23T01:04:55.257239 #83076] INFO -- : 0: rspec-core (2.99.2) from /Users/brycesenz/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/specifications/rspec-core-2.99.2.gemspec
|
24
|
+
I, [2019-07-23T01:04:55.257439 #83076] INFO -- : 0: rspec-expectations (2.99.2) from /Users/brycesenz/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/specifications/rspec-expectations-2.99.2.gemspec
|
25
|
+
I, [2019-07-23T01:04:55.257631 #83076] INFO -- : 0: rspec-mocks (2.99.3) from /Users/brycesenz/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/specifications/rspec-mocks-2.99.3.gemspec
|
26
|
+
I, [2019-07-23T01:04:55.257828 #83076] INFO -- : 0: rspec (2.99.0) from /Users/brycesenz/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/specifications/rspec-2.99.0.gemspec
|
27
|
+
I, [2019-07-23T01:04:55.258027 #83076] INFO -- : 0: shoulda-matchers (3.1.2) from /Users/brycesenz/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/specifications/shoulda-matchers-3.1.2.gemspec
|
28
|
+
I, [2019-07-23T01:04:55.258225 #83076] INFO -- : 0: virtus (1.0.5) from /Users/brycesenz/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/specifications/virtus-1.0.5.gemspec
|
29
|
+
E, [2019-07-23T01:04:55.378885 #83076] ERROR -- : NoMethodError: undefined method `spec' for nil:NilClass
|
30
|
+
/Users/brycesenz/.rbenv/versions/2.4.1/lib/ruby/2.4.0/rubygems/installer.rb:262:in `spec' \n/Users/brycesenz/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/bundler-1.5.0/lib/bundler/source/path/installer.rb:17:in `generate_bin' \n/Users/brycesenz/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/bundler-1.5.0/lib/bundler/source/path.rb:176:in `generate_bin' \n/Users/brycesenz/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/bundler-1.5.0/lib/bundler/source/path.rb:73:in `install' \n/Users/brycesenz/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/bundler-1.5.0/lib/bundler/installer.rb:111:in `block in install_gem_from_spec' \n/Users/brycesenz/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/bundler-1.5.0/lib/bundler/rubygems_integration.rb:150:in `with_build_args' \n/Users/brycesenz/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/bundler-1.5.0/lib/bundler/installer.rb:110:in `install_gem_from_spec' \n/Users/brycesenz/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/bundler-1.5.0/lib/bundler/installer.rb:295:in `block in install_sequentially' \n/Users/brycesenz/.rbenv/versions/2.4.1/lib/ruby/2.4.0/forwardable.rb:229:in `each' \n/Users/brycesenz/.rbenv/versions/2.4.1/lib/ruby/2.4.0/forwardable.rb:229:in `each' \n/Users/brycesenz/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/bundler-1.5.0/lib/bundler/installer.rb:294:in `install_sequentially' \n/Users/brycesenz/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/bundler-1.5.0/lib/bundler/installer.rb:97:in `run' \n/Users/brycesenz/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/bundler-1.5.0/lib/bundler/installer.rb:15:in `install' \n/usr/local/Cellar/rbenv/1.1.2/rbenv.d/exec/gem-rehash/rubygems_plugin.rb:27:in `install' \n/Users/brycesenz/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/bundler-1.5.0/lib/bundler/cli.rb:257:in `install' \n/Users/brycesenz/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/bundler-1.5.0/lib/bundler/vendor/thor/command.rb:27:in `run' \n/Users/brycesenz/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/bundler-1.5.0/lib/bundler/vendor/thor/invocation.rb:120:in `invoke_command' \n/Users/brycesenz/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/bundler-1.5.0/lib/bundler/vendor/thor.rb:363:in `dispatch' \n/Users/brycesenz/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/bundler-1.5.0/lib/bundler/vendor/thor/base.rb:438:in `start' \n/Users/brycesenz/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/bundler-1.5.0/lib/bundler/cli.rb:10:in `start' \n/Users/brycesenz/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/bundler-1.5.0/bin/bundle:22:in `block in <top (required)>' \n/Users/brycesenz/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/bundler-1.5.0/lib/bundler/friendly_errors.rb:5:in `with_friendly_errors' \n/Users/brycesenz/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/bundler-1.5.0/bin/bundle:22:in `<top (required)>' \n/Users/brycesenz/.rbenv/versions/2.4.1/bin/bundle:22:in `load' \n/Users/brycesenz/.rbenv/versions/2.4.1/bin/bundle:22:in `<main>'
|
data/Appraisals
CHANGED
@@ -11,4 +11,14 @@ end
|
|
11
11
|
appraise 'activemodel-5' do
|
12
12
|
gem 'activemodel', '>= 5.0'
|
13
13
|
gem 'shoulda-matchers', '>= 3.0'
|
14
|
-
end
|
14
|
+
end
|
15
|
+
|
16
|
+
appraise 'activemodel-5_1' do
|
17
|
+
gem 'activemodel', '>= 5.1'
|
18
|
+
gem 'shoulda-matchers', '>= 3.0'
|
19
|
+
end
|
20
|
+
|
21
|
+
appraise 'activemodel-5_2' do
|
22
|
+
gem 'activemodel', '>= 5.2'
|
23
|
+
gem 'shoulda-matchers', '>= 3.0'
|
24
|
+
end
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
simple_params (2.0.
|
4
|
+
simple_params (2.0.2)
|
5
5
|
activemodel (>= 3.0, <= 6.0)
|
6
6
|
shoulda-matchers (>= 2.8)
|
7
7
|
virtus (>= 1.0.0)
|
@@ -73,6 +73,3 @@ DEPENDENCIES
|
|
73
73
|
rake (~> 10.1)
|
74
74
|
rspec (~> 2.6)
|
75
75
|
simple_params!
|
76
|
-
|
77
|
-
BUNDLED WITH
|
78
|
-
1.15.4
|
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: ..
|
3
3
|
specs:
|
4
|
-
simple_params (2.0.
|
4
|
+
simple_params (2.0.2)
|
5
5
|
activemodel (>= 3.0, <= 6.0)
|
6
6
|
shoulda-matchers (>= 2.8)
|
7
7
|
virtus (>= 1.0.0)
|
@@ -75,6 +75,3 @@ DEPENDENCIES
|
|
75
75
|
rspec (~> 2.6)
|
76
76
|
shoulda-matchers (>= 3.0)
|
77
77
|
simple_params!
|
78
|
-
|
79
|
-
BUNDLED WITH
|
80
|
-
1.15.4
|
@@ -0,0 +1,75 @@
|
|
1
|
+
PATH
|
2
|
+
remote: ../
|
3
|
+
specs:
|
4
|
+
simple_params (2.0.2)
|
5
|
+
activemodel (>= 3.0, <= 6.0)
|
6
|
+
shoulda-matchers (>= 2.8)
|
7
|
+
virtus (>= 1.0.0)
|
8
|
+
|
9
|
+
GEM
|
10
|
+
remote: https://rubygems.org/
|
11
|
+
specs:
|
12
|
+
activemodel (5.2.3)
|
13
|
+
activesupport (= 5.2.3)
|
14
|
+
activesupport (5.2.3)
|
15
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
16
|
+
i18n (>= 0.7, < 2)
|
17
|
+
minitest (~> 5.1)
|
18
|
+
tzinfo (~> 1.1)
|
19
|
+
appraisal (2.2.0)
|
20
|
+
bundler
|
21
|
+
rake
|
22
|
+
thor (>= 0.14.0)
|
23
|
+
axiom-types (0.1.1)
|
24
|
+
descendants_tracker (~> 0.0.4)
|
25
|
+
ice_nine (~> 0.11.0)
|
26
|
+
thread_safe (~> 0.3, >= 0.3.1)
|
27
|
+
coderay (1.1.2)
|
28
|
+
coercible (1.0.0)
|
29
|
+
descendants_tracker (~> 0.0.1)
|
30
|
+
concurrent-ruby (1.1.4)
|
31
|
+
descendants_tracker (0.0.4)
|
32
|
+
thread_safe (~> 0.3, >= 0.3.1)
|
33
|
+
diff-lcs (1.3)
|
34
|
+
equalizer (0.0.11)
|
35
|
+
i18n (1.0.1)
|
36
|
+
concurrent-ruby (~> 1.0)
|
37
|
+
ice_nine (0.11.2)
|
38
|
+
method_source (0.9.2)
|
39
|
+
minitest (5.11.3)
|
40
|
+
pry (0.12.0)
|
41
|
+
coderay (~> 1.1.0)
|
42
|
+
method_source (~> 0.9.0)
|
43
|
+
rake (10.4.2)
|
44
|
+
rspec (2.99.0)
|
45
|
+
rspec-core (~> 2.99.0)
|
46
|
+
rspec-expectations (~> 2.99.0)
|
47
|
+
rspec-mocks (~> 2.99.0)
|
48
|
+
rspec-core (2.99.2)
|
49
|
+
rspec-expectations (2.99.2)
|
50
|
+
diff-lcs (>= 1.1.3, < 2.0)
|
51
|
+
rspec-mocks (2.99.3)
|
52
|
+
shoulda-matchers (3.1.2)
|
53
|
+
activesupport (>= 4.0.0)
|
54
|
+
thor (0.20.3)
|
55
|
+
thread_safe (0.3.6)
|
56
|
+
tzinfo (1.2.5)
|
57
|
+
thread_safe (~> 0.1)
|
58
|
+
virtus (1.0.5)
|
59
|
+
axiom-types (~> 0.1)
|
60
|
+
coercible (~> 1.0)
|
61
|
+
descendants_tracker (~> 0.0, >= 0.0.3)
|
62
|
+
equalizer (~> 0.0, >= 0.0.9)
|
63
|
+
|
64
|
+
PLATFORMS
|
65
|
+
ruby
|
66
|
+
|
67
|
+
DEPENDENCIES
|
68
|
+
activemodel (>= 5.1)
|
69
|
+
appraisal
|
70
|
+
bundler (~> 1.5)
|
71
|
+
pry
|
72
|
+
rake (~> 10.1)
|
73
|
+
rspec (~> 2.6)
|
74
|
+
shoulda-matchers (>= 3.0)
|
75
|
+
simple_params!
|
@@ -0,0 +1,75 @@
|
|
1
|
+
PATH
|
2
|
+
remote: ../
|
3
|
+
specs:
|
4
|
+
simple_params (2.0.2)
|
5
|
+
activemodel (>= 3.0, <= 6.0)
|
6
|
+
shoulda-matchers (>= 2.8)
|
7
|
+
virtus (>= 1.0.0)
|
8
|
+
|
9
|
+
GEM
|
10
|
+
remote: https://rubygems.org/
|
11
|
+
specs:
|
12
|
+
activemodel (5.2.3)
|
13
|
+
activesupport (= 5.2.3)
|
14
|
+
activesupport (5.2.3)
|
15
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
16
|
+
i18n (>= 0.7, < 2)
|
17
|
+
minitest (~> 5.1)
|
18
|
+
tzinfo (~> 1.1)
|
19
|
+
appraisal (2.2.0)
|
20
|
+
bundler
|
21
|
+
rake
|
22
|
+
thor (>= 0.14.0)
|
23
|
+
axiom-types (0.1.1)
|
24
|
+
descendants_tracker (~> 0.0.4)
|
25
|
+
ice_nine (~> 0.11.0)
|
26
|
+
thread_safe (~> 0.3, >= 0.3.1)
|
27
|
+
coderay (1.1.2)
|
28
|
+
coercible (1.0.0)
|
29
|
+
descendants_tracker (~> 0.0.1)
|
30
|
+
concurrent-ruby (1.1.4)
|
31
|
+
descendants_tracker (0.0.4)
|
32
|
+
thread_safe (~> 0.3, >= 0.3.1)
|
33
|
+
diff-lcs (1.3)
|
34
|
+
equalizer (0.0.11)
|
35
|
+
i18n (1.0.1)
|
36
|
+
concurrent-ruby (~> 1.0)
|
37
|
+
ice_nine (0.11.2)
|
38
|
+
method_source (0.9.2)
|
39
|
+
minitest (5.11.3)
|
40
|
+
pry (0.12.0)
|
41
|
+
coderay (~> 1.1.0)
|
42
|
+
method_source (~> 0.9.0)
|
43
|
+
rake (10.4.2)
|
44
|
+
rspec (2.99.0)
|
45
|
+
rspec-core (~> 2.99.0)
|
46
|
+
rspec-expectations (~> 2.99.0)
|
47
|
+
rspec-mocks (~> 2.99.0)
|
48
|
+
rspec-core (2.99.2)
|
49
|
+
rspec-expectations (2.99.2)
|
50
|
+
diff-lcs (>= 1.1.3, < 2.0)
|
51
|
+
rspec-mocks (2.99.3)
|
52
|
+
shoulda-matchers (3.1.2)
|
53
|
+
activesupport (>= 4.0.0)
|
54
|
+
thor (0.20.3)
|
55
|
+
thread_safe (0.3.6)
|
56
|
+
tzinfo (1.2.5)
|
57
|
+
thread_safe (~> 0.1)
|
58
|
+
virtus (1.0.5)
|
59
|
+
axiom-types (~> 0.1)
|
60
|
+
coercible (~> 1.0)
|
61
|
+
descendants_tracker (~> 0.0, >= 0.0.3)
|
62
|
+
equalizer (~> 0.0, >= 0.0.9)
|
63
|
+
|
64
|
+
PLATFORMS
|
65
|
+
ruby
|
66
|
+
|
67
|
+
DEPENDENCIES
|
68
|
+
activemodel (>= 5.2)
|
69
|
+
appraisal
|
70
|
+
bundler (~> 1.5)
|
71
|
+
pry
|
72
|
+
rake (~> 10.1)
|
73
|
+
rspec (~> 2.6)
|
74
|
+
shoulda-matchers (>= 3.0)
|
75
|
+
simple_params!
|
data/lib/simple_params/errors.rb
CHANGED
@@ -43,7 +43,7 @@ module SimpleParams
|
|
43
43
|
super &&
|
44
44
|
nested_instances.all? { |i| i.errors.empty? }
|
45
45
|
end
|
46
|
-
alias_method :blank?, :empty?
|
46
|
+
alias_method :blank?, :empty?
|
47
47
|
|
48
48
|
def include?(attribute)
|
49
49
|
if nested_attribute?(attribute)
|
@@ -52,7 +52,7 @@ module SimpleParams
|
|
52
52
|
messages[attribute].present?
|
53
53
|
end
|
54
54
|
end
|
55
|
-
alias_method :has_key?, :include?
|
55
|
+
alias_method :has_key?, :include?
|
56
56
|
alias_method :key?, :include?
|
57
57
|
|
58
58
|
def values
|
@@ -62,7 +62,7 @@ module SimpleParams
|
|
62
62
|
|
63
63
|
def full_messages
|
64
64
|
parent_messages = map { |attribute, message| full_message(attribute, message) }
|
65
|
-
nested_messages = nested_instances.map do |i|
|
65
|
+
nested_messages = nested_instances.map do |i|
|
66
66
|
i.errors.full_messages.map { |message| "#{i.parent_attribute_name} " + message }
|
67
67
|
end
|
68
68
|
|
@@ -77,7 +77,7 @@ module SimpleParams
|
|
77
77
|
msgs = get_messages(self, full_messages)
|
78
78
|
|
79
79
|
@nested_classes.map do |attribute, klass|
|
80
|
-
nested_msgs = run_or_mapped_run(klass) do |k|
|
80
|
+
nested_msgs = run_or_mapped_run(klass) do |k|
|
81
81
|
unless k.nil?
|
82
82
|
get_messages(k.errors, full_messages)
|
83
83
|
end
|
@@ -113,12 +113,13 @@ module SimpleParams
|
|
113
113
|
end
|
114
114
|
|
115
115
|
def get_messages(object, full_messages = false)
|
116
|
+
valid_messages = object.messages.reject { |key, val| empty_messages?(val) }
|
116
117
|
if full_messages
|
117
|
-
|
118
|
+
valid_messages.each_with_object({}) do |(attribute, array), messages|
|
118
119
|
messages[attribute] = array.map { |message| object.full_message(attribute, message) }
|
119
120
|
end
|
120
121
|
else
|
121
|
-
|
122
|
+
valid_messages
|
122
123
|
end
|
123
124
|
end
|
124
125
|
|
data/spec/errors_spec.rb
CHANGED
@@ -251,7 +251,7 @@ describe SimpleParams::Errors do
|
|
251
251
|
person = Person.new
|
252
252
|
person.errors.add(:name, "can not be blank")
|
253
253
|
person.dog.errors.add(:breed, "can not be nil")
|
254
|
-
person.errors.to_hash.should eq({
|
254
|
+
person.errors.to_hash.should eq({
|
255
255
|
name: ["can not be blank"],
|
256
256
|
dog: {
|
257
257
|
breed: ["can not be nil"]
|
@@ -265,7 +265,7 @@ describe SimpleParams::Errors do
|
|
265
265
|
person.errors.add(:name, "can not be blank")
|
266
266
|
person.dog.errors.add(:base, :invalid)
|
267
267
|
person.dog.errors.add(:breed, "can not be nil")
|
268
|
-
person.errors.to_hash.should eq({
|
268
|
+
person.errors.to_hash.should eq({
|
269
269
|
base: ["is invalid"],
|
270
270
|
name: ["can not be blank"],
|
271
271
|
dog: {
|
@@ -282,7 +282,7 @@ describe SimpleParams::Errors do
|
|
282
282
|
person.dog.errors.add(:base, :invalid)
|
283
283
|
person.dog.errors.add(:breed, "can not be nil")
|
284
284
|
person.cats.first.errors.add(:name, "can not be blank")
|
285
|
-
person.errors.to_hash.should eq({
|
285
|
+
person.errors.to_hash.should eq({
|
286
286
|
base: ["is invalid"],
|
287
287
|
name: ["can not be blank"],
|
288
288
|
dog: {
|
@@ -311,13 +311,13 @@ describe SimpleParams::Errors do
|
|
311
311
|
person.errors[:name] = 'can not be nil'
|
312
312
|
person.errors[:name].should eq(["can not be nil"])
|
313
313
|
person.errors.as_json(full_messages: true).should eq({ name: ["name can not be nil"] })
|
314
|
-
end
|
314
|
+
end
|
315
315
|
|
316
316
|
it "handles nested attributes without full_messages" do
|
317
317
|
person = Person.new
|
318
318
|
person.errors[:name] = 'can not be nil'
|
319
319
|
person.dog.errors[:breed] = 'is invalid'
|
320
|
-
person.errors.as_json.should eq({
|
320
|
+
person.errors.as_json.should eq({
|
321
321
|
name: ["can not be nil"],
|
322
322
|
dog: {
|
323
323
|
breed: ["is invalid"]
|
@@ -329,7 +329,7 @@ describe SimpleParams::Errors do
|
|
329
329
|
person = Person.new
|
330
330
|
person.errors[:name] = 'can not be nil'
|
331
331
|
person.dog.errors[:breed] = 'is invalid'
|
332
|
-
person.errors.as_json(full_messages: true).should eq({
|
332
|
+
person.errors.as_json(full_messages: true).should eq({
|
333
333
|
name: ["name can not be nil"],
|
334
334
|
dog: {
|
335
335
|
breed: ["breed is invalid"]
|
@@ -2,7 +2,7 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
class RailsIntegrationParams < SimpleParams::Params
|
4
4
|
with_rails_helpers
|
5
|
-
|
5
|
+
|
6
6
|
param :name
|
7
7
|
param :age, type: :integer, optional: true, validations: { inclusion: { in: 18..100 } }
|
8
8
|
param :current_time, type: :datetime, optional: true
|
@@ -99,4 +99,30 @@ describe SimpleParams::Params do
|
|
99
99
|
expect(params.current_time).to eq(nil)
|
100
100
|
end
|
101
101
|
end
|
102
|
+
|
103
|
+
context "with missing required params" do
|
104
|
+
let!(:params) do
|
105
|
+
RailsIntegrationParams.new(
|
106
|
+
name: "Tom",
|
107
|
+
age: 21,
|
108
|
+
)
|
109
|
+
end
|
110
|
+
|
111
|
+
specify "correct error output" do
|
112
|
+
params.valid?
|
113
|
+
expected = {
|
114
|
+
:address => {
|
115
|
+
:street => ["can't be blank"],
|
116
|
+
:city => ["is too short (minimum is 4 characters)", "can't be blank"]
|
117
|
+
},
|
118
|
+
:dogs => [
|
119
|
+
{
|
120
|
+
:name => ["can't be blank"],
|
121
|
+
:age => ["is not included in the list", "can't be blank"]
|
122
|
+
}
|
123
|
+
]
|
124
|
+
}
|
125
|
+
expect(params.errors.to_hash).to eq(expected)
|
126
|
+
end
|
127
|
+
end
|
102
128
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simple_params
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- brycesenz
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-07-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|
@@ -135,6 +135,7 @@ executables: []
|
|
135
135
|
extensions: []
|
136
136
|
extra_rdoc_files: []
|
137
137
|
files:
|
138
|
+
- ".bundle/install.log"
|
138
139
|
- ".gitignore"
|
139
140
|
- ".rspec"
|
140
141
|
- ".ruby-gemset"
|
@@ -150,6 +151,10 @@ files:
|
|
150
151
|
- gemfiles/activemodel_4.gemfile.lock
|
151
152
|
- gemfiles/activemodel_5.gemfile
|
152
153
|
- gemfiles/activemodel_5.gemfile.lock
|
154
|
+
- gemfiles/activemodel_5_1.gemfile
|
155
|
+
- gemfiles/activemodel_5_1.gemfile.lock
|
156
|
+
- gemfiles/activemodel_5_2.gemfile
|
157
|
+
- gemfiles/activemodel_5_2.gemfile.lock
|
153
158
|
- lib/simple_params.rb
|
154
159
|
- lib/simple_params/api_pie_doc.rb
|
155
160
|
- lib/simple_params/api_pie_doc/attribute.rb
|