weak_parameters 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +21 -0
- data/Gemfile +8 -0
- data/LICENSE.txt +22 -0
- data/README.md +46 -0
- data/Rakefile +1 -0
- data/lib/weak_parameters.rb +48 -0
- data/lib/weak_parameters/base_validator.rb +37 -0
- data/lib/weak_parameters/controller.rb +11 -0
- data/lib/weak_parameters/integer_validator.rb +22 -0
- data/lib/weak_parameters/validation_error.rb +4 -0
- data/lib/weak_parameters/validator.rb +28 -0
- data/lib/weak_parameters/version.rb +3 -0
- data/spec/dummy/README.rdoc +261 -0
- data/spec/dummy/Rakefile +7 -0
- data/spec/dummy/app/assets/javascripts/application.js +15 -0
- data/spec/dummy/app/assets/stylesheets/application.css +13 -0
- data/spec/dummy/app/controllers/application_controller.rb +9 -0
- data/spec/dummy/app/controllers/recipes_controller.rb +14 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/mailers/.gitkeep +0 -0
- data/spec/dummy/app/models/.gitkeep +0 -0
- data/spec/dummy/app/models/recipe.rb +3 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/config/application.rb +65 -0
- data/spec/dummy/config/boot.rb +10 -0
- data/spec/dummy/config/database.yml +25 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +37 -0
- data/spec/dummy/config/environments/production.rb +67 -0
- data/spec/dummy/config/environments/test.rb +37 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/inflections.rb +15 -0
- data/spec/dummy/config/initializers/mime_types.rb +5 -0
- data/spec/dummy/config/initializers/secret_token.rb +7 -0
- data/spec/dummy/config/initializers/session_store.rb +8 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/en.yml +5 -0
- data/spec/dummy/config/routes.rb +3 -0
- data/spec/dummy/db/migrate/20130607060944_create_recipes.rb +10 -0
- data/spec/dummy/db/schema.rb +23 -0
- data/spec/dummy/lib/assets/.gitkeep +0 -0
- data/spec/dummy/log/.gitkeep +0 -0
- data/spec/dummy/public/404.html +26 -0
- data/spec/dummy/public/422.html +26 -0
- data/spec/dummy/public/500.html +25 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/script/rails +6 -0
- data/spec/requests/recipes_spec.rb +56 -0
- data/spec/spec_helper.rb +16 -0
- data/weak_parameters.gemspec +24 -0
- metadata +189 -0
@@ -0,0 +1,23 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
# This file is auto-generated from the current state of the database. Instead
|
3
|
+
# of editing this file, please use the migrations feature of Active Record to
|
4
|
+
# incrementally modify your database, and then regenerate this schema definition.
|
5
|
+
#
|
6
|
+
# Note that this schema.rb definition is the authoritative source for your
|
7
|
+
# database schema. If you need to create the application database on another
|
8
|
+
# system, you should be using db:schema:load, not running all the migrations
|
9
|
+
# from scratch. The latter is a flawed and unsustainable approach (the more migrations
|
10
|
+
# you'll amass, the slower it'll run and the greater likelihood for issues).
|
11
|
+
#
|
12
|
+
# It's strongly recommended to check this file into your version control system.
|
13
|
+
|
14
|
+
ActiveRecord::Schema.define(:version => 20130607060944) do
|
15
|
+
|
16
|
+
create_table "recipes", :force => true do |t|
|
17
|
+
t.string "name"
|
18
|
+
t.integer "type"
|
19
|
+
t.datetime "created_at", :null => false
|
20
|
+
t.datetime "updated_at", :null => false
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
File without changes
|
File without changes
|
@@ -0,0 +1,26 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>The page you were looking for doesn't exist (404)</title>
|
5
|
+
<style type="text/css">
|
6
|
+
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
|
7
|
+
div.dialog {
|
8
|
+
width: 25em;
|
9
|
+
padding: 0 4em;
|
10
|
+
margin: 4em auto 0 auto;
|
11
|
+
border: 1px solid #ccc;
|
12
|
+
border-right-color: #999;
|
13
|
+
border-bottom-color: #999;
|
14
|
+
}
|
15
|
+
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
|
16
|
+
</style>
|
17
|
+
</head>
|
18
|
+
|
19
|
+
<body>
|
20
|
+
<!-- This file lives in public/404.html -->
|
21
|
+
<div class="dialog">
|
22
|
+
<h1>The page you were looking for doesn't exist.</h1>
|
23
|
+
<p>You may have mistyped the address or the page may have moved.</p>
|
24
|
+
</div>
|
25
|
+
</body>
|
26
|
+
</html>
|
@@ -0,0 +1,26 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>The change you wanted was rejected (422)</title>
|
5
|
+
<style type="text/css">
|
6
|
+
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
|
7
|
+
div.dialog {
|
8
|
+
width: 25em;
|
9
|
+
padding: 0 4em;
|
10
|
+
margin: 4em auto 0 auto;
|
11
|
+
border: 1px solid #ccc;
|
12
|
+
border-right-color: #999;
|
13
|
+
border-bottom-color: #999;
|
14
|
+
}
|
15
|
+
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
|
16
|
+
</style>
|
17
|
+
</head>
|
18
|
+
|
19
|
+
<body>
|
20
|
+
<!-- This file lives in public/422.html -->
|
21
|
+
<div class="dialog">
|
22
|
+
<h1>The change you wanted was rejected.</h1>
|
23
|
+
<p>Maybe you tried to change something you didn't have access to.</p>
|
24
|
+
</div>
|
25
|
+
</body>
|
26
|
+
</html>
|
@@ -0,0 +1,25 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>We're sorry, but something went wrong (500)</title>
|
5
|
+
<style type="text/css">
|
6
|
+
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
|
7
|
+
div.dialog {
|
8
|
+
width: 25em;
|
9
|
+
padding: 0 4em;
|
10
|
+
margin: 4em auto 0 auto;
|
11
|
+
border: 1px solid #ccc;
|
12
|
+
border-right-color: #999;
|
13
|
+
border-bottom-color: #999;
|
14
|
+
}
|
15
|
+
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
|
16
|
+
</style>
|
17
|
+
</head>
|
18
|
+
|
19
|
+
<body>
|
20
|
+
<!-- This file lives in public/500.html -->
|
21
|
+
<div class="dialog">
|
22
|
+
<h1>We're sorry, but something went wrong.</h1>
|
23
|
+
</div>
|
24
|
+
</body>
|
25
|
+
</html>
|
File without changes
|
@@ -0,0 +1,6 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
|
3
|
+
|
4
|
+
APP_PATH = File.expand_path('../../config/application', __FILE__)
|
5
|
+
require File.expand_path('../../config/boot', __FILE__)
|
6
|
+
require 'rails/commands'
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe "Recipes" do
|
4
|
+
let(:env) do
|
5
|
+
{ "HTTP_ACCEPT" => "application/json" }
|
6
|
+
end
|
7
|
+
|
8
|
+
let(:params) do
|
9
|
+
{
|
10
|
+
name: "name",
|
11
|
+
type: 1,
|
12
|
+
}
|
13
|
+
end
|
14
|
+
|
15
|
+
describe "POST /recipes" do
|
16
|
+
context "without required param" do
|
17
|
+
before do
|
18
|
+
params.delete(:name)
|
19
|
+
end
|
20
|
+
|
21
|
+
it "returns 400" do
|
22
|
+
post "/recipes", params, env
|
23
|
+
response.status.should == 400
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
context "with other typed param" do
|
28
|
+
before do
|
29
|
+
params[:type] = "x"
|
30
|
+
end
|
31
|
+
|
32
|
+
it "returns 400" do
|
33
|
+
post "/recipes", params, env
|
34
|
+
response.status.should == 400
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
context "without non-required param" do
|
39
|
+
before do
|
40
|
+
params.delete(:type)
|
41
|
+
end
|
42
|
+
|
43
|
+
it "creates a new recipe" do
|
44
|
+
post "/recipes", params, env
|
45
|
+
response.status.should == 201
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
context "with valid condition" do
|
50
|
+
it "creates a new recipe" do
|
51
|
+
post "/recipes", params, env
|
52
|
+
response.status.should == 201
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
ENV["RAILS_ENV"] ||= "test"
|
2
|
+
require File.expand_path("../../spec/dummy/config/environment", __FILE__)
|
3
|
+
require "rspec/rails"
|
4
|
+
require "rspec/autorun"
|
5
|
+
|
6
|
+
RSpec.configure do |config|
|
7
|
+
# If you"re not using ActiveRecord, or you"d prefer not to run each of your
|
8
|
+
# examples within a transaction, remove the following line or assign false
|
9
|
+
# instead of true.
|
10
|
+
config.use_transactional_fixtures = true
|
11
|
+
|
12
|
+
# If true, the base class of anonymous controllers will be inferred
|
13
|
+
# automatically. This will be the default behavior in future versions of
|
14
|
+
# rspec-rails.
|
15
|
+
config.infer_base_class_for_anonymous_controllers = false
|
16
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "weak_parameters/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "weak_parameters"
|
8
|
+
spec.version = WeakParameters::VERSION
|
9
|
+
spec.authors = ["Ryo Nakamura"]
|
10
|
+
spec.email = ["r7kamura@gmail.com"]
|
11
|
+
spec.summary = "Add a validation filter to your controller."
|
12
|
+
spec.homepage = "https://github.com/r7kamura/weak_parameters"
|
13
|
+
spec.license = "MIT"
|
14
|
+
|
15
|
+
spec.files = `git ls-files`.split($/)
|
16
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
17
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
|
+
spec.require_paths = ["lib"]
|
19
|
+
|
20
|
+
spec.add_dependency "rails", ">= 3.2.11"
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
spec.add_development_dependency "sqlite3"
|
24
|
+
end
|
metadata
ADDED
@@ -0,0 +1,189 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: weak_parameters
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ryo Nakamura
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-06-07 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rails
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 3.2.11
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 3.2.11
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.3'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.3'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: sqlite3
|
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'
|
69
|
+
description:
|
70
|
+
email:
|
71
|
+
- r7kamura@gmail.com
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- .gitignore
|
77
|
+
- Gemfile
|
78
|
+
- LICENSE.txt
|
79
|
+
- README.md
|
80
|
+
- Rakefile
|
81
|
+
- lib/weak_parameters.rb
|
82
|
+
- lib/weak_parameters/base_validator.rb
|
83
|
+
- lib/weak_parameters/controller.rb
|
84
|
+
- lib/weak_parameters/integer_validator.rb
|
85
|
+
- lib/weak_parameters/validation_error.rb
|
86
|
+
- lib/weak_parameters/validator.rb
|
87
|
+
- lib/weak_parameters/version.rb
|
88
|
+
- spec/dummy/README.rdoc
|
89
|
+
- spec/dummy/Rakefile
|
90
|
+
- spec/dummy/app/assets/javascripts/application.js
|
91
|
+
- spec/dummy/app/assets/stylesheets/application.css
|
92
|
+
- spec/dummy/app/controllers/application_controller.rb
|
93
|
+
- spec/dummy/app/controllers/recipes_controller.rb
|
94
|
+
- spec/dummy/app/helpers/application_helper.rb
|
95
|
+
- spec/dummy/app/mailers/.gitkeep
|
96
|
+
- spec/dummy/app/models/.gitkeep
|
97
|
+
- spec/dummy/app/models/recipe.rb
|
98
|
+
- spec/dummy/app/views/layouts/application.html.erb
|
99
|
+
- spec/dummy/config.ru
|
100
|
+
- spec/dummy/config/application.rb
|
101
|
+
- spec/dummy/config/boot.rb
|
102
|
+
- spec/dummy/config/database.yml
|
103
|
+
- spec/dummy/config/environment.rb
|
104
|
+
- spec/dummy/config/environments/development.rb
|
105
|
+
- spec/dummy/config/environments/production.rb
|
106
|
+
- spec/dummy/config/environments/test.rb
|
107
|
+
- spec/dummy/config/initializers/backtrace_silencers.rb
|
108
|
+
- spec/dummy/config/initializers/inflections.rb
|
109
|
+
- spec/dummy/config/initializers/mime_types.rb
|
110
|
+
- spec/dummy/config/initializers/secret_token.rb
|
111
|
+
- spec/dummy/config/initializers/session_store.rb
|
112
|
+
- spec/dummy/config/initializers/wrap_parameters.rb
|
113
|
+
- spec/dummy/config/locales/en.yml
|
114
|
+
- spec/dummy/config/routes.rb
|
115
|
+
- spec/dummy/db/migrate/20130607060944_create_recipes.rb
|
116
|
+
- spec/dummy/db/schema.rb
|
117
|
+
- spec/dummy/lib/assets/.gitkeep
|
118
|
+
- spec/dummy/log/.gitkeep
|
119
|
+
- spec/dummy/public/404.html
|
120
|
+
- spec/dummy/public/422.html
|
121
|
+
- spec/dummy/public/500.html
|
122
|
+
- spec/dummy/public/favicon.ico
|
123
|
+
- spec/dummy/script/rails
|
124
|
+
- spec/requests/recipes_spec.rb
|
125
|
+
- spec/spec_helper.rb
|
126
|
+
- weak_parameters.gemspec
|
127
|
+
homepage: https://github.com/r7kamura/weak_parameters
|
128
|
+
licenses:
|
129
|
+
- MIT
|
130
|
+
metadata: {}
|
131
|
+
post_install_message:
|
132
|
+
rdoc_options: []
|
133
|
+
require_paths:
|
134
|
+
- lib
|
135
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
136
|
+
requirements:
|
137
|
+
- - '>='
|
138
|
+
- !ruby/object:Gem::Version
|
139
|
+
version: '0'
|
140
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
141
|
+
requirements:
|
142
|
+
- - '>='
|
143
|
+
- !ruby/object:Gem::Version
|
144
|
+
version: '0'
|
145
|
+
requirements: []
|
146
|
+
rubyforge_project:
|
147
|
+
rubygems_version: 2.0.2
|
148
|
+
signing_key:
|
149
|
+
specification_version: 4
|
150
|
+
summary: Add a validation filter to your controller.
|
151
|
+
test_files:
|
152
|
+
- spec/dummy/README.rdoc
|
153
|
+
- spec/dummy/Rakefile
|
154
|
+
- spec/dummy/app/assets/javascripts/application.js
|
155
|
+
- spec/dummy/app/assets/stylesheets/application.css
|
156
|
+
- spec/dummy/app/controllers/application_controller.rb
|
157
|
+
- spec/dummy/app/controllers/recipes_controller.rb
|
158
|
+
- spec/dummy/app/helpers/application_helper.rb
|
159
|
+
- spec/dummy/app/mailers/.gitkeep
|
160
|
+
- spec/dummy/app/models/.gitkeep
|
161
|
+
- spec/dummy/app/models/recipe.rb
|
162
|
+
- spec/dummy/app/views/layouts/application.html.erb
|
163
|
+
- spec/dummy/config.ru
|
164
|
+
- spec/dummy/config/application.rb
|
165
|
+
- spec/dummy/config/boot.rb
|
166
|
+
- spec/dummy/config/database.yml
|
167
|
+
- spec/dummy/config/environment.rb
|
168
|
+
- spec/dummy/config/environments/development.rb
|
169
|
+
- spec/dummy/config/environments/production.rb
|
170
|
+
- spec/dummy/config/environments/test.rb
|
171
|
+
- spec/dummy/config/initializers/backtrace_silencers.rb
|
172
|
+
- spec/dummy/config/initializers/inflections.rb
|
173
|
+
- spec/dummy/config/initializers/mime_types.rb
|
174
|
+
- spec/dummy/config/initializers/secret_token.rb
|
175
|
+
- spec/dummy/config/initializers/session_store.rb
|
176
|
+
- spec/dummy/config/initializers/wrap_parameters.rb
|
177
|
+
- spec/dummy/config/locales/en.yml
|
178
|
+
- spec/dummy/config/routes.rb
|
179
|
+
- spec/dummy/db/migrate/20130607060944_create_recipes.rb
|
180
|
+
- spec/dummy/db/schema.rb
|
181
|
+
- spec/dummy/lib/assets/.gitkeep
|
182
|
+
- spec/dummy/log/.gitkeep
|
183
|
+
- spec/dummy/public/404.html
|
184
|
+
- spec/dummy/public/422.html
|
185
|
+
- spec/dummy/public/500.html
|
186
|
+
- spec/dummy/public/favicon.ico
|
187
|
+
- spec/dummy/script/rails
|
188
|
+
- spec/requests/recipes_spec.rb
|
189
|
+
- spec/spec_helper.rb
|