weak_parameters 0.2.2 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +5 -0
- data/CHANGELOG.md +4 -0
- data/Gemfile +0 -6
- data/README.md +2 -2
- data/Rakefile +4 -0
- data/lib/weak_parameters/base_validator.rb +1 -1
- data/lib/weak_parameters/version.rb +1 -1
- data/spec/dummy/app/controllers/recipes_controller.rb +5 -1
- data/spec/requests/recipes_spec.rb +3 -3
- data/spec/requests/strong_spec.rb +31 -31
- data/spec/spec_helper.rb +10 -2
- data/weak_parameters.gemspec +4 -0
- metadata +59 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 50b0c13f9e3c5697ffe2103ce08be27f4f647d04
|
4
|
+
data.tar.gz: 2d29e0b13db351bfb7149b8a503995ec76ff1ec0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5b2cb7add33324eb6368ed684116d7b9e08d045e59efcd1e70ad9fe9bed2856f06c84401902ff81ba254b4d3d15478cd77ad1b1ed63b1c02ab1a78df731e5225
|
7
|
+
data.tar.gz: 5456a73dbb05f9a45d676d251ce1082034946e0a3c56ed3394b6c59597ee64687f032fd743673ebaa09b7e25840bd43a412d1abdf66a7de6387e09ec678cef49
|
data/.travis.yml
ADDED
data/CHANGELOG.md
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# WeakParameters
|
1
|
+
# WeakParameters [![Build Status](https://travis-ci.org/r7kamura/weak_parameters.svg?branch=master)](https://travis-ci.org/r7kamura/weak_parameters)
|
2
2
|
Validates `params` in your controller.
|
3
3
|
|
4
4
|
## Installation
|
@@ -59,7 +59,7 @@ irb(main):005:0> app.post "/recipes", name: "alice", type: "bob"
|
|
59
59
|
* object
|
60
60
|
* list
|
61
61
|
|
62
|
-
###
|
62
|
+
### Available options
|
63
63
|
* required
|
64
64
|
* only
|
65
65
|
* except
|
data/Rakefile
CHANGED
@@ -11,7 +11,7 @@ class RecipesController < ApplicationController
|
|
11
11
|
file :attachment
|
12
12
|
integer :custom, only: 0..1, handler: :render_error
|
13
13
|
string :zip_code do |value|
|
14
|
-
value
|
14
|
+
zip_pattern(value)
|
15
15
|
end
|
16
16
|
object :nested, required: true do
|
17
17
|
integer :number, only: [0, 1]
|
@@ -36,4 +36,8 @@ class RecipesController < ApplicationController
|
|
36
36
|
def render_error
|
37
37
|
head 403
|
38
38
|
end
|
39
|
+
|
40
|
+
def zip_pattern(value)
|
41
|
+
value =~ /\A\d{3}-\d{4}\z/
|
42
|
+
end
|
39
43
|
end
|
@@ -29,14 +29,14 @@ describe "Recipes", type: :request do
|
|
29
29
|
shared_examples_for "400" do
|
30
30
|
it "returns 400" do
|
31
31
|
post "/recipes", params
|
32
|
-
response.status.
|
32
|
+
expect(response.status).to eq(400)
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
36
36
|
shared_examples_for "201" do
|
37
37
|
it "creates a new recipe" do
|
38
38
|
post "/recipes", params
|
39
|
-
response.status.
|
39
|
+
expect(response.status).to eq(201)
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
@@ -142,7 +142,7 @@ describe "Recipes", type: :request do
|
|
142
142
|
end
|
143
143
|
it "delegates to specified method" do
|
144
144
|
post "/recipes", params
|
145
|
-
response.status.
|
145
|
+
expect(response.status).to eq(403)
|
146
146
|
end
|
147
147
|
end
|
148
148
|
|
@@ -49,52 +49,52 @@ describe "Strong", type: :request do
|
|
49
49
|
describe "#permitted_params" do
|
50
50
|
it "returns permitted_params" do
|
51
51
|
post "/strongs", params
|
52
|
-
controller.permitted_params.
|
53
|
-
controller.permitted_params.
|
52
|
+
expect(controller.permitted_params).to have_key "strong_object"
|
53
|
+
expect(controller.permitted_params).not_to have_key "object"
|
54
54
|
|
55
|
-
controller.permitted_params.
|
56
|
-
controller.permitted_params.
|
55
|
+
expect(controller.permitted_params).to have_key "strong_name"
|
56
|
+
expect(controller.permitted_params).not_to have_key "name"
|
57
57
|
|
58
|
-
controller.permitted_params.
|
59
|
-
controller.permitted_params.
|
58
|
+
expect(controller.permitted_params).to have_key "strong_number"
|
59
|
+
expect(controller.permitted_params).not_to have_key "number"
|
60
60
|
|
61
|
-
controller.permitted_params.
|
62
|
-
controller.permitted_params.
|
61
|
+
expect(controller.permitted_params).to have_key "strong_type"
|
62
|
+
expect(controller.permitted_params).not_to have_key "type"
|
63
63
|
|
64
|
-
controller.permitted_params.
|
65
|
-
controller.permitted_params.
|
64
|
+
expect(controller.permitted_params).to have_key "strong_flag"
|
65
|
+
expect(controller.permitted_params).not_to have_key "flag"
|
66
66
|
|
67
|
-
controller.permitted_params.
|
68
|
-
controller.permitted_params.
|
67
|
+
expect(controller.permitted_params).to have_key "strong_config"
|
68
|
+
expect(controller.permitted_params).not_to have_key "config"
|
69
69
|
|
70
|
-
controller.permitted_params.
|
71
|
-
controller.permitted_params.
|
70
|
+
expect(controller.permitted_params).to have_key "strong_tags"
|
71
|
+
expect(controller.permitted_params).not_to have_key "tags"
|
72
72
|
|
73
|
-
controller.permitted_params.
|
74
|
-
controller.permitted_params.
|
73
|
+
expect(controller.permitted_params).not_to have_key "strong_rate"
|
74
|
+
expect(controller.permitted_params).not_to have_key "rate"
|
75
75
|
|
76
|
-
controller.permitted_params.
|
77
|
-
controller.permitted_params.
|
76
|
+
expect(controller.permitted_params).to have_key "strong_attachment"
|
77
|
+
expect(controller.permitted_params).not_to have_key "attachment"
|
78
78
|
|
79
|
-
controller.permitted_params.
|
80
|
-
controller.permitted_params.
|
79
|
+
expect(controller.permitted_params).to have_key "strong_zip_code"
|
80
|
+
expect(controller.permitted_params).not_to have_key "zip_code"
|
81
81
|
|
82
|
-
controller.permitted_params.
|
83
|
-
controller.permitted_params.
|
82
|
+
expect(controller.permitted_params).to have_key "strong_custom"
|
83
|
+
expect(controller.permitted_params).not_to have_key "custom"
|
84
84
|
|
85
|
-
controller.permitted_params.
|
86
|
-
controller.permitted_params.
|
85
|
+
expect(controller.permitted_params).to have_key "strong_nested"
|
86
|
+
expect(controller.permitted_params).not_to have_key "nested"
|
87
87
|
|
88
|
-
controller.permitted_params.
|
89
|
-
controller.permitted_params.
|
88
|
+
expect(controller.permitted_params).to have_key "strong_numbers"
|
89
|
+
expect(controller.permitted_params).not_to have_key "numbers"
|
90
90
|
|
91
|
-
controller.permitted_params.
|
92
|
-
controller.permitted_params.
|
91
|
+
expect(controller.permitted_params).to have_key "strong_body"
|
92
|
+
expect(controller.permitted_params).not_to have_key "body"
|
93
93
|
|
94
|
-
controller.permitted_params[:strong_body].
|
94
|
+
expect(controller.permitted_params[:strong_body]).to have_key "items"
|
95
95
|
|
96
|
-
controller.permitted_params[:strong_body][:items].first.
|
97
|
-
controller.permitted_params[:strong_body][:items].first.
|
96
|
+
expect(controller.permitted_params[:strong_body][:items].first).to have_key "strong_price"
|
97
|
+
expect(controller.permitted_params[:strong_body][:items].first).not_to have_key "name"
|
98
98
|
end
|
99
99
|
end
|
100
100
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
ENV["RAILS_ENV"] ||= "test"
|
2
2
|
require File.expand_path("../../spec/dummy/config/environment", __FILE__)
|
3
3
|
require "rspec/rails"
|
4
|
-
require "rspec/autorun"
|
5
4
|
|
6
5
|
RSpec.configure do |config|
|
7
6
|
# If you"re not using ActiveRecord, or you"d prefer not to run each of your
|
@@ -14,5 +13,14 @@ RSpec.configure do |config|
|
|
14
13
|
# rspec-rails.
|
15
14
|
config.infer_base_class_for_anonymous_controllers = false
|
16
15
|
|
17
|
-
|
16
|
+
# rspec-rails 3 will no longer automatically infer an example group's spec type
|
17
|
+
# from the file location. You can explicitly opt-in to the feature using this
|
18
|
+
# config option.
|
19
|
+
# To explicitly tag specs without using automatic inference, set the `:type`
|
20
|
+
# metadata manually:
|
21
|
+
#
|
22
|
+
# describe ThingsController, :type => :controller do
|
23
|
+
# # Equivalent to being in spec/controllers
|
24
|
+
# end
|
25
|
+
config.infer_spec_type_from_file_location!
|
18
26
|
end
|
data/weak_parameters.gemspec
CHANGED
@@ -18,7 +18,11 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.require_paths = ["lib"]
|
19
19
|
|
20
20
|
spec.add_dependency "rails", ">= 3.2.11"
|
21
|
+
spec.add_development_dependency "autodoc"
|
21
22
|
spec.add_development_dependency "bundler", "~> 1.3"
|
23
|
+
spec.add_development_dependency "pry-rails"
|
22
24
|
spec.add_development_dependency "rake"
|
25
|
+
spec.add_development_dependency "rspec-rails"
|
23
26
|
spec.add_development_dependency "sqlite3"
|
27
|
+
spec.add_development_dependency "test-unit"
|
24
28
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: weak_parameters
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryo Nakamura
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-01-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 3.2.11
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: autodoc
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: bundler
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -38,6 +52,20 @@ dependencies:
|
|
38
52
|
- - "~>"
|
39
53
|
- !ruby/object:Gem::Version
|
40
54
|
version: '1.3'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: pry-rails
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
41
69
|
- !ruby/object:Gem::Dependency
|
42
70
|
name: rake
|
43
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -52,6 +80,20 @@ dependencies:
|
|
52
80
|
- - ">="
|
53
81
|
- !ruby/object:Gem::Version
|
54
82
|
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rspec-rails
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
55
97
|
- !ruby/object:Gem::Dependency
|
56
98
|
name: sqlite3
|
57
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -66,6 +108,20 @@ dependencies:
|
|
66
108
|
- - ">="
|
67
109
|
- !ruby/object:Gem::Version
|
68
110
|
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: test-unit
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
69
125
|
description:
|
70
126
|
email:
|
71
127
|
- r7kamura@gmail.com
|
@@ -74,6 +130,7 @@ extensions: []
|
|
74
130
|
extra_rdoc_files: []
|
75
131
|
files:
|
76
132
|
- ".gitignore"
|
133
|
+
- ".travis.yml"
|
77
134
|
- CHANGELOG.md
|
78
135
|
- Gemfile
|
79
136
|
- LICENSE.txt
|