explicit-parameters 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +6 -2
- data/Rakefile +13 -0
- data/explicit-parameters.gemspec +2 -2
- data/gemfiles/Gemfile.rails-4.2 +7 -0
- data/gemfiles/Gemfile.rails-4.2.lock +94 -0
- data/gemfiles/Gemfile.rails-5.0 +7 -0
- data/gemfiles/Gemfile.rails-5.0.lock +89 -0
- data/lib/explicit_parameters.rb +3 -0
- data/lib/explicit_parameters/parameters.rb +2 -1
- data/lib/explicit_parameters/version.rb +1 -1
- data/spec/controller_spec.rb +23 -9
- metadata +27 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 40398cce3128c89367609acaba917403bcdb5016
|
4
|
+
data.tar.gz: 71262a6bbc997abcdc385f91d8eeefb73989098b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d3cd1f16c5eaf0fef10669a363ce3f739174f0223de527e03f350579a88e1193a01d52ef9c33707925d4f17046f775827bdf8d33ef2dc2670edd1131a9135c79
|
7
|
+
data.tar.gz: 8193ca84de290b2f55585eafb4455552eeca5272d1c35cc5940c742345652f6aeeeda160c601c6ce6270f7aa4f5f22afd6ddaa38df4c549b1fa544de019cd14e
|
data/.travis.yml
CHANGED
data/Rakefile
CHANGED
@@ -5,3 +5,16 @@ require 'rspec/core/rake_task'
|
|
5
5
|
RSpec::Core::RakeTask.new(:spec)
|
6
6
|
|
7
7
|
task default: :spec
|
8
|
+
|
9
|
+
namespace :spec do
|
10
|
+
task :all do
|
11
|
+
%w(4.2 5.0).each do |rails_version|
|
12
|
+
command = %W{
|
13
|
+
BUNDLE_GEMFILE=gemfiles/Gemfile.rails-#{rails_version}
|
14
|
+
rspec
|
15
|
+
}.join(' ')
|
16
|
+
puts command
|
17
|
+
system(command)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
data/explicit-parameters.gemspec
CHANGED
@@ -17,8 +17,8 @@ Gem::Specification.new do |spec|
|
|
17
17
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
18
|
spec.require_paths = ['lib']
|
19
19
|
|
20
|
-
spec.add_dependency 'actionpack', '
|
21
|
-
spec.add_dependency 'activemodel', '
|
20
|
+
spec.add_dependency 'actionpack', '>= 4.2', '< 5.1'
|
21
|
+
spec.add_dependency 'activemodel', '>= 4.2', '< 5.1'
|
22
22
|
spec.add_dependency 'virtus', '~> 1.0'
|
23
23
|
|
24
24
|
spec.add_development_dependency 'bundler', '~> 1.7'
|
@@ -0,0 +1,94 @@
|
|
1
|
+
GEM
|
2
|
+
remote: https://rubygems.org/
|
3
|
+
specs:
|
4
|
+
actionpack (4.2.7)
|
5
|
+
actionview (= 4.2.7)
|
6
|
+
activesupport (= 4.2.7)
|
7
|
+
rack (~> 1.6)
|
8
|
+
rack-test (~> 0.6.2)
|
9
|
+
rails-dom-testing (~> 1.0, >= 1.0.5)
|
10
|
+
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
11
|
+
actionview (4.2.7)
|
12
|
+
activesupport (= 4.2.7)
|
13
|
+
builder (~> 3.1)
|
14
|
+
erubis (~> 2.7.0)
|
15
|
+
rails-dom-testing (~> 1.0, >= 1.0.5)
|
16
|
+
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
17
|
+
activemodel (4.2.7)
|
18
|
+
activesupport (= 4.2.7)
|
19
|
+
builder (~> 3.1)
|
20
|
+
activesupport (4.2.7)
|
21
|
+
i18n (~> 0.7)
|
22
|
+
json (~> 1.7, >= 1.7.7)
|
23
|
+
minitest (~> 5.1)
|
24
|
+
thread_safe (~> 0.3, >= 0.3.4)
|
25
|
+
tzinfo (~> 1.1)
|
26
|
+
axiom-types (0.1.1)
|
27
|
+
descendants_tracker (~> 0.0.4)
|
28
|
+
ice_nine (~> 0.11.0)
|
29
|
+
thread_safe (~> 0.3, >= 0.3.1)
|
30
|
+
builder (3.2.2)
|
31
|
+
coercible (1.0.0)
|
32
|
+
descendants_tracker (~> 0.0.1)
|
33
|
+
descendants_tracker (0.0.4)
|
34
|
+
thread_safe (~> 0.3, >= 0.3.1)
|
35
|
+
diff-lcs (1.2.5)
|
36
|
+
equalizer (0.0.11)
|
37
|
+
erubis (2.7.0)
|
38
|
+
i18n (0.7.0)
|
39
|
+
ice_nine (0.11.2)
|
40
|
+
json (1.8.3)
|
41
|
+
loofah (2.0.3)
|
42
|
+
nokogiri (>= 1.5.9)
|
43
|
+
mini_portile2 (2.1.0)
|
44
|
+
minitest (5.9.0)
|
45
|
+
nokogiri (1.6.8)
|
46
|
+
mini_portile2 (~> 2.1.0)
|
47
|
+
pkg-config (~> 1.1.7)
|
48
|
+
pkg-config (1.1.7)
|
49
|
+
rack (1.6.4)
|
50
|
+
rack-test (0.6.3)
|
51
|
+
rack (>= 1.0)
|
52
|
+
rails-deprecated_sanitizer (1.0.3)
|
53
|
+
activesupport (>= 4.2.0.alpha)
|
54
|
+
rails-dom-testing (1.0.7)
|
55
|
+
activesupport (>= 4.2.0.beta, < 5.0)
|
56
|
+
nokogiri (~> 1.6.0)
|
57
|
+
rails-deprecated_sanitizer (>= 1.0.1)
|
58
|
+
rails-html-sanitizer (1.0.3)
|
59
|
+
loofah (~> 2.0)
|
60
|
+
rake (10.5.0)
|
61
|
+
rspec (3.5.0)
|
62
|
+
rspec-core (~> 3.5.0)
|
63
|
+
rspec-expectations (~> 3.5.0)
|
64
|
+
rspec-mocks (~> 3.5.0)
|
65
|
+
rspec-core (3.5.1)
|
66
|
+
rspec-support (~> 3.5.0)
|
67
|
+
rspec-expectations (3.5.0)
|
68
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
69
|
+
rspec-support (~> 3.5.0)
|
70
|
+
rspec-mocks (3.5.0)
|
71
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
72
|
+
rspec-support (~> 3.5.0)
|
73
|
+
rspec-support (3.5.0)
|
74
|
+
thread_safe (0.3.5)
|
75
|
+
tzinfo (1.2.2)
|
76
|
+
thread_safe (~> 0.1)
|
77
|
+
virtus (1.0.5)
|
78
|
+
axiom-types (~> 0.1)
|
79
|
+
coercible (~> 1.0)
|
80
|
+
descendants_tracker (~> 0.0, >= 0.0.3)
|
81
|
+
equalizer (~> 0.0, >= 0.0.9)
|
82
|
+
|
83
|
+
PLATFORMS
|
84
|
+
ruby
|
85
|
+
|
86
|
+
DEPENDENCIES
|
87
|
+
actionpack (~> 4.2.0)
|
88
|
+
activemodel (~> 4.2.0)
|
89
|
+
rake (~> 10.0)
|
90
|
+
rspec (~> 3.0)
|
91
|
+
virtus (~> 1.0)
|
92
|
+
|
93
|
+
BUNDLED WITH
|
94
|
+
1.12.3
|
@@ -0,0 +1,89 @@
|
|
1
|
+
GEM
|
2
|
+
remote: https://rubygems.org/
|
3
|
+
specs:
|
4
|
+
actionpack (5.0.0)
|
5
|
+
actionview (= 5.0.0)
|
6
|
+
activesupport (= 5.0.0)
|
7
|
+
rack (~> 2.0)
|
8
|
+
rack-test (~> 0.6.3)
|
9
|
+
rails-dom-testing (~> 2.0)
|
10
|
+
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
11
|
+
actionview (5.0.0)
|
12
|
+
activesupport (= 5.0.0)
|
13
|
+
builder (~> 3.1)
|
14
|
+
erubis (~> 2.7.0)
|
15
|
+
rails-dom-testing (~> 2.0)
|
16
|
+
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
17
|
+
activemodel (5.0.0)
|
18
|
+
activesupport (= 5.0.0)
|
19
|
+
activesupport (5.0.0)
|
20
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
21
|
+
i18n (~> 0.7)
|
22
|
+
minitest (~> 5.1)
|
23
|
+
tzinfo (~> 1.1)
|
24
|
+
axiom-types (0.1.1)
|
25
|
+
descendants_tracker (~> 0.0.4)
|
26
|
+
ice_nine (~> 0.11.0)
|
27
|
+
thread_safe (~> 0.3, >= 0.3.1)
|
28
|
+
builder (3.2.2)
|
29
|
+
coercible (1.0.0)
|
30
|
+
descendants_tracker (~> 0.0.1)
|
31
|
+
concurrent-ruby (1.0.2)
|
32
|
+
descendants_tracker (0.0.4)
|
33
|
+
thread_safe (~> 0.3, >= 0.3.1)
|
34
|
+
diff-lcs (1.2.5)
|
35
|
+
equalizer (0.0.11)
|
36
|
+
erubis (2.7.0)
|
37
|
+
i18n (0.7.0)
|
38
|
+
ice_nine (0.11.2)
|
39
|
+
loofah (2.0.3)
|
40
|
+
nokogiri (>= 1.5.9)
|
41
|
+
mini_portile2 (2.1.0)
|
42
|
+
minitest (5.9.0)
|
43
|
+
nokogiri (1.6.8)
|
44
|
+
mini_portile2 (~> 2.1.0)
|
45
|
+
pkg-config (~> 1.1.7)
|
46
|
+
pkg-config (1.1.7)
|
47
|
+
rack (2.0.1)
|
48
|
+
rack-test (0.6.3)
|
49
|
+
rack (>= 1.0)
|
50
|
+
rails-dom-testing (2.0.1)
|
51
|
+
activesupport (>= 4.2.0, < 6.0)
|
52
|
+
nokogiri (~> 1.6.0)
|
53
|
+
rails-html-sanitizer (1.0.3)
|
54
|
+
loofah (~> 2.0)
|
55
|
+
rake (10.5.0)
|
56
|
+
rspec (3.5.0)
|
57
|
+
rspec-core (~> 3.5.0)
|
58
|
+
rspec-expectations (~> 3.5.0)
|
59
|
+
rspec-mocks (~> 3.5.0)
|
60
|
+
rspec-core (3.5.1)
|
61
|
+
rspec-support (~> 3.5.0)
|
62
|
+
rspec-expectations (3.5.0)
|
63
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
64
|
+
rspec-support (~> 3.5.0)
|
65
|
+
rspec-mocks (3.5.0)
|
66
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
67
|
+
rspec-support (~> 3.5.0)
|
68
|
+
rspec-support (3.5.0)
|
69
|
+
thread_safe (0.3.5)
|
70
|
+
tzinfo (1.2.2)
|
71
|
+
thread_safe (~> 0.1)
|
72
|
+
virtus (1.0.5)
|
73
|
+
axiom-types (~> 0.1)
|
74
|
+
coercible (~> 1.0)
|
75
|
+
descendants_tracker (~> 0.0, >= 0.0.3)
|
76
|
+
equalizer (~> 0.0, >= 0.0.9)
|
77
|
+
|
78
|
+
PLATFORMS
|
79
|
+
ruby
|
80
|
+
|
81
|
+
DEPENDENCIES
|
82
|
+
actionpack (~> 5.0.0)
|
83
|
+
activemodel (~> 5.0.0)
|
84
|
+
rake (~> 10.0)
|
85
|
+
rspec (~> 3.0)
|
86
|
+
virtus (~> 1.0)
|
87
|
+
|
88
|
+
BUNDLED WITH
|
89
|
+
1.12.3
|
data/lib/explicit_parameters.rb
CHANGED
@@ -65,8 +65,9 @@ module ExplicitParameters
|
|
65
65
|
end
|
66
66
|
|
67
67
|
def initialize(attributes = {})
|
68
|
+
attributes = attributes.to_unsafe_h if IS_RAILS5 && attributes.respond_to?(:to_unsafe_h)
|
68
69
|
@original_attributes = attributes.stringify_keys
|
69
|
-
super
|
70
|
+
super(attributes)
|
70
71
|
end
|
71
72
|
|
72
73
|
def validate!
|
data/spec/controller_spec.rb
CHANGED
@@ -13,11 +13,11 @@ class DummyController < ActionController::Base
|
|
13
13
|
|
14
14
|
def error
|
15
15
|
param_error!(:page_size, "Out of bound")
|
16
|
-
render
|
16
|
+
render body: 'OK'
|
17
17
|
end
|
18
18
|
|
19
19
|
def no_declaration
|
20
|
-
render
|
20
|
+
render body: 'OK'
|
21
21
|
end
|
22
22
|
|
23
23
|
end
|
@@ -60,12 +60,26 @@ RSpec.describe DummyController do
|
|
60
60
|
request(action, 'GET', query: parameters)
|
61
61
|
end
|
62
62
|
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
63
|
+
if ActionController::Base.instance_method(:dispatch).arity > 2
|
64
|
+
def request(action, method, query: {}, body: '')
|
65
|
+
request = ActionDispatch::Request.new(
|
66
|
+
'REQUEST_METHOD' => method,
|
67
|
+
'QUERY_STRING' => query.to_query,
|
68
|
+
'rack.input' => StringIO.new(body)
|
69
|
+
)
|
70
|
+
@response = ActionDispatch::Response.create.tap do |res|
|
71
|
+
res.request = request
|
72
|
+
end
|
73
|
+
subject.dispatch(action, request, @response)
|
74
|
+
end
|
75
|
+
else
|
76
|
+
def request(action, method, query: {}, body: '')
|
77
|
+
rack_response = subject.dispatch(action, ActionDispatch::Request.new(
|
78
|
+
'REQUEST_METHOD' => method,
|
79
|
+
'QUERY_STRING' => query.to_query,
|
80
|
+
'rack.input' => StringIO.new(body)
|
81
|
+
))
|
82
|
+
@response = ActionDispatch::Response.new(*rack_response)
|
83
|
+
end
|
70
84
|
end
|
71
85
|
end
|
metadata
CHANGED
@@ -1,43 +1,55 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: explicit-parameters
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jean Boussier
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-07-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: actionpack
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '4.2'
|
20
|
+
- - "<"
|
18
21
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
22
|
+
version: '5.1'
|
20
23
|
type: :runtime
|
21
24
|
prerelease: false
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
23
26
|
requirements:
|
24
|
-
- - "
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '4.2'
|
30
|
+
- - "<"
|
25
31
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
32
|
+
version: '5.1'
|
27
33
|
- !ruby/object:Gem::Dependency
|
28
34
|
name: activemodel
|
29
35
|
requirement: !ruby/object:Gem::Requirement
|
30
36
|
requirements:
|
31
|
-
- - "
|
37
|
+
- - ">="
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '4.2'
|
40
|
+
- - "<"
|
32
41
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
42
|
+
version: '5.1'
|
34
43
|
type: :runtime
|
35
44
|
prerelease: false
|
36
45
|
version_requirements: !ruby/object:Gem::Requirement
|
37
46
|
requirements:
|
38
|
-
- - "
|
47
|
+
- - ">="
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '4.2'
|
50
|
+
- - "<"
|
39
51
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
52
|
+
version: '5.1'
|
41
53
|
- !ruby/object:Gem::Dependency
|
42
54
|
name: virtus
|
43
55
|
requirement: !ruby/object:Gem::Requirement
|
@@ -109,6 +121,10 @@ files:
|
|
109
121
|
- README.md
|
110
122
|
- Rakefile
|
111
123
|
- explicit-parameters.gemspec
|
124
|
+
- gemfiles/Gemfile.rails-4.2
|
125
|
+
- gemfiles/Gemfile.rails-4.2.lock
|
126
|
+
- gemfiles/Gemfile.rails-5.0
|
127
|
+
- gemfiles/Gemfile.rails-5.0.lock
|
112
128
|
- lib/explicit-parameters.rb
|
113
129
|
- lib/explicit_parameters.rb
|
114
130
|
- lib/explicit_parameters/controller.rb
|
@@ -138,7 +154,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
138
154
|
version: '0'
|
139
155
|
requirements: []
|
140
156
|
rubyforge_project:
|
141
|
-
rubygems_version: 2.
|
157
|
+
rubygems_version: 2.5.1
|
142
158
|
signing_key:
|
143
159
|
specification_version: 4
|
144
160
|
summary: Explicit parameters validation and casting for Rails APIs
|