weak_parameters 0.0.6 → 0.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile +2 -0
- data/README.md +7 -0
- data/lib/weak_parameters/integer_validator.rb +1 -1
- data/lib/weak_parameters/version.rb +1 -1
- data/spec/dummy/app/controllers/recipes_controller.rb +2 -1
- data/spec/dummy/app/models/recipe.rb +0 -1
- data/spec/dummy/config/application.rb +5 -17
- data/spec/dummy/config/environments/development.rb +0 -16
- data/spec/dummy/config/environments/production.rb +4 -0
- data/spec/dummy/config/environments/test.rb +2 -6
- data/spec/dummy/config/initializers/secret_token.rb +1 -0
- data/spec/requests/recipes_spec.rb +13 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f1eda85eff3c4bef895416ca359efa1dd90db8f7
|
4
|
+
data.tar.gz: 8ef1d0d971591b665066b042a32b88c530353ade
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8c15d0bcf364fb6dc89be768bd71bb9e6d3c96be1b2cd24b7d32f04749ef774b74741a6d6b606ee525734cf759768ac7882a0588be5b9b965ea1aeb7991b65fb
|
7
|
+
data.tar.gz: d505f087124d6e89059dd9941e1a438e4d58527bda9d86e2b7ee6b158cbd81a9c9caae42b4f43c3f6c8bbb190e19324c147670bc58adacb604e1d9dec3bae5d4
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -34,6 +34,13 @@ irb(main):005:0> app.post "/recipes", name: "alice", type: "bob"
|
|
34
34
|
=> 400
|
35
35
|
```
|
36
36
|
|
37
|
+
### Available validators
|
38
|
+
* array
|
39
|
+
* hash
|
40
|
+
* integer
|
41
|
+
* string
|
42
|
+
* boolean (= 0, 1, false, true)
|
43
|
+
|
37
44
|
## Tips
|
38
45
|
WeakParameters.stats returns its validation metadata, and this is useful for auto-generating API documents.
|
39
46
|
With [autodoc](https://github.com/r7kamura/autodoc), you can auto-generate API documents with params information.
|
@@ -1,14 +1,11 @@
|
|
1
1
|
require File.expand_path('../boot', __FILE__)
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
require
|
7
|
-
|
8
|
-
require "sprockets/railtie"
|
9
|
-
# require "rails/test_unit/railtie"
|
3
|
+
require "rails/all"
|
4
|
+
|
5
|
+
if defined?(Bundler)
|
6
|
+
Bundler.require(:default, Rails.env)
|
7
|
+
end
|
10
8
|
|
11
|
-
Bundler.require(*Rails.groups)
|
12
9
|
require "weak_parameters"
|
13
10
|
|
14
11
|
module Dummy
|
@@ -49,15 +46,6 @@ module Dummy
|
|
49
46
|
# like if you have constraints or database-specific column types
|
50
47
|
# config.active_record.schema_format = :sql
|
51
48
|
|
52
|
-
# Enforce whitelist mode for mass assignment.
|
53
|
-
# This will create an empty whitelist of attributes available for mass-assignment for all models
|
54
|
-
# in your app. As such, your models will need to explicitly whitelist or blacklist accessible
|
55
|
-
# parameters by using an attr_accessible or attr_protected declaration.
|
56
|
-
config.active_record.whitelist_attributes = true
|
57
|
-
|
58
|
-
# Enable the asset pipeline
|
59
|
-
config.assets.enabled = true
|
60
|
-
|
61
49
|
# Version of your assets, change this if you want to expire all your assets
|
62
50
|
config.assets.version = '1.0'
|
63
51
|
end
|
@@ -6,9 +6,6 @@ Dummy::Application.configure do
|
|
6
6
|
# since you don't have to restart the web server when you make code changes.
|
7
7
|
config.cache_classes = false
|
8
8
|
|
9
|
-
# Log error messages when you accidentally call methods on nil.
|
10
|
-
config.whiny_nils = true
|
11
|
-
|
12
9
|
# Show full error reports and disable caching
|
13
10
|
config.consider_all_requests_local = true
|
14
11
|
config.action_controller.perform_caching = false
|
@@ -19,19 +16,6 @@ Dummy::Application.configure do
|
|
19
16
|
# Print deprecation notices to the Rails logger
|
20
17
|
config.active_support.deprecation = :log
|
21
18
|
|
22
|
-
# Only use best-standards-support built into browsers
|
23
|
-
config.action_dispatch.best_standards_support = :builtin
|
24
|
-
|
25
|
-
# Raise exception on mass assignment protection for Active Record models
|
26
|
-
config.active_record.mass_assignment_sanitizer = :strict
|
27
|
-
|
28
|
-
# Log the query plan for queries taking more than this (works
|
29
|
-
# with SQLite, MySQL, and PostgreSQL)
|
30
|
-
config.active_record.auto_explain_threshold_in_seconds = 0.5
|
31
|
-
|
32
|
-
# Do not compress assets
|
33
|
-
config.assets.compress = false
|
34
|
-
|
35
19
|
# Expands the lines which load the assets
|
36
20
|
config.assets.debug = true
|
37
21
|
end
|
@@ -64,4 +64,8 @@ Dummy::Application.configure do
|
|
64
64
|
# Log the query plan for queries taking more than this (works
|
65
65
|
# with SQLite, MySQL, and PostgreSQL)
|
66
66
|
# config.active_record.auto_explain_threshold_in_seconds = 0.5
|
67
|
+
|
68
|
+
config.eager_load = true
|
69
|
+
|
70
|
+
config.assets.js_compressor = :uglifier
|
67
71
|
end
|
@@ -11,9 +11,6 @@ Dummy::Application.configure do
|
|
11
11
|
config.serve_static_assets = true
|
12
12
|
config.static_cache_control = "public, max-age=3600"
|
13
13
|
|
14
|
-
# Log error messages when you accidentally call methods on nil
|
15
|
-
config.whiny_nils = true
|
16
|
-
|
17
14
|
# Show full error reports and disable caching
|
18
15
|
config.consider_all_requests_local = true
|
19
16
|
config.action_controller.perform_caching = false
|
@@ -29,9 +26,8 @@ Dummy::Application.configure do
|
|
29
26
|
# ActionMailer::Base.deliveries array.
|
30
27
|
config.action_mailer.delivery_method = :test
|
31
28
|
|
32
|
-
# Raise exception on mass assignment protection for Active Record models
|
33
|
-
config.active_record.mass_assignment_sanitizer = :strict
|
34
|
-
|
35
29
|
# Print deprecation notices to the stderr
|
36
30
|
config.active_support.deprecation = :stderr
|
31
|
+
|
32
|
+
config.eager_load = true
|
37
33
|
end
|
@@ -5,3 +5,4 @@
|
|
5
5
|
# Make sure the secret is at least 30 characters and all random,
|
6
6
|
# no regular words or you'll be exposed to dictionary attacks.
|
7
7
|
Dummy::Application.config.secret_token = '2bc71f32e8d9d76cbdf4c01f3e959bb186b372ae67429c06fc88d82073e7e54170ca2b6e92f5487cb0dfaba18783a5f266cb5d50d13fee05021f46049b33fa0c'
|
8
|
+
Dummy::Application.config.secret_key_base = '24b191b073b60770ff32d8c0096a6786c8aa0c5f7c0968838f5321a0fbda49da3a567984ca3862f353b4cc408e1e23fedd1f3d808ae91965758239f19642a2e6'
|
@@ -4,6 +4,7 @@ describe "Recipes" do
|
|
4
4
|
let(:params) do
|
5
5
|
{
|
6
6
|
name: "name",
|
7
|
+
number: 0,
|
7
8
|
type: 1,
|
8
9
|
flag: true,
|
9
10
|
config: {},
|
@@ -34,6 +35,17 @@ describe "Recipes" do
|
|
34
35
|
end
|
35
36
|
end
|
36
37
|
|
38
|
+
context "with exceptional interger param" do
|
39
|
+
before do
|
40
|
+
params[:number] = true
|
41
|
+
end
|
42
|
+
|
43
|
+
it "returns 400" do
|
44
|
+
post "/recipes", params
|
45
|
+
response.status.should == 400
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
37
49
|
context "with wrong boolean param" do
|
38
50
|
before do
|
39
51
|
params[:flag] = "x"
|
@@ -80,7 +92,7 @@ describe "Recipes" do
|
|
80
92
|
|
81
93
|
context "with invalid param to :only condition" do
|
82
94
|
before do
|
83
|
-
params[:type] =
|
95
|
+
params[:type] = 4
|
84
96
|
end
|
85
97
|
|
86
98
|
it "returns 400" do
|
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.0.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryo Nakamura
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-08-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -147,7 +147,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
147
147
|
version: '0'
|
148
148
|
requirements: []
|
149
149
|
rubyforge_project:
|
150
|
-
rubygems_version: 2.0.
|
150
|
+
rubygems_version: 2.0.3
|
151
151
|
signing_key:
|
152
152
|
specification_version: 4
|
153
153
|
summary: Add a validation filter to your controller.
|