padrino-core 0.12.9 → 0.13.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -13
- data/bin/padrino +1 -2
- data/lib/padrino-core/application/application_setup.rb +10 -6
- data/lib/padrino-core/application/params_protection.rb +7 -1
- data/lib/padrino-core/application/routing.rb +88 -50
- data/lib/padrino-core/application/show_exceptions.rb +29 -0
- data/lib/padrino-core/application.rb +0 -19
- data/lib/padrino-core/caller.rb +1 -2
- data/lib/padrino-core/cli/base.rb +7 -11
- data/lib/padrino-core/cli/rake_tasks.rb +8 -21
- data/lib/padrino-core/loader.rb +13 -12
- data/lib/padrino-core/logger.rb +4 -32
- data/lib/padrino-core/mounter.rb +62 -21
- data/lib/padrino-core/path_router/compiler.rb +110 -0
- data/lib/padrino-core/path_router/error_handler.rb +8 -0
- data/lib/padrino-core/path_router/matcher.rb +123 -0
- data/lib/padrino-core/path_router/route.rb +169 -0
- data/lib/padrino-core/path_router.rb +119 -0
- data/lib/padrino-core/reloader/rack.rb +1 -4
- data/lib/padrino-core/reloader/storage.rb +3 -31
- data/lib/padrino-core/reloader.rb +12 -17
- data/lib/padrino-core/version.rb +1 -1
- data/lib/padrino-core.rb +0 -2
- data/padrino-core.gemspec +8 -2
- data/test/fixtures/apps/helpers/support.rb +1 -0
- data/test/fixtures/apps/{rack_apps.rb → mountable_apps/rack_apps.rb} +0 -4
- data/test/fixtures/apps/{static.html → mountable_apps/static.html} +0 -0
- data/test/fixtures/apps/precompiled_app.rb +19 -0
- data/test/fixtures/apps/system.rb +0 -2
- data/test/helper.rb +1 -1
- data/test/test_application.rb +18 -6
- data/test/test_csrf_protection.rb +6 -7
- data/test/test_filters.rb +18 -1
- data/test/test_logger.rb +1 -49
- data/test/test_mounter.rb +2 -4
- data/test/test_params_protection.rb +15 -15
- data/test/test_reloader_simple.rb +2 -2
- data/test/test_reloader_system.rb +0 -30
- data/test/test_restful_routing.rb +4 -4
- data/test/test_routing.rb +176 -54
- metadata +109 -49
- data/lib/padrino-core/cli/binstub.rb +0 -27
- data/lib/padrino-core/configuration.rb +0 -40
- data/lib/padrino-core/ext/http_router.rb +0 -201
- data/lib/padrino-core/mounter/application_extension.rb +0 -55
- data/test/fixtures/apps/custom_dependencies/custom_dependencies.rb +0 -11
- data/test/fixtures/apps/custom_dependencies/my_dependencies/my_dependency.rb +0 -0
- data/test/fixtures/apps/stealthy/app.rb +0 -7
- data/test/fixtures/apps/stealthy/helpers/stealthy_class_helpers.rb +0 -13
- data/test/test_configuration.rb +0 -29
- data/test/test_reloader_storage.rb +0 -51
@@ -73,9 +73,8 @@ module Padrino
|
|
73
73
|
# We lock dependencies sets to prevent reloading of protected constants
|
74
74
|
#
|
75
75
|
def lock!
|
76
|
-
klasses =
|
77
|
-
|
78
|
-
original_klass_name.split('::').first if original_klass_name
|
76
|
+
klasses = ObjectSpace.classes do |klass|
|
77
|
+
klass._orig_klass_name.split('::').first
|
79
78
|
end
|
80
79
|
klasses |= Padrino.mounted_apps.map(&:app_class)
|
81
80
|
exclude_constants.merge(klasses)
|
@@ -222,9 +221,7 @@ module Padrino
|
|
222
221
|
#
|
223
222
|
def files_for_rotation
|
224
223
|
files = Set.new
|
225
|
-
Padrino.
|
226
|
-
files += Dir.glob(path)
|
227
|
-
end
|
224
|
+
files += Dir.glob("#{Padrino.root}/{lib,models,shared}/**/*.rb")
|
228
225
|
reloadable_apps.each do |app|
|
229
226
|
files << app.app_file
|
230
227
|
files += Dir.glob(app.app_obj.prerequisites)
|
@@ -254,13 +251,18 @@ module Padrino
|
|
254
251
|
#
|
255
252
|
def external_constant?(const)
|
256
253
|
sources = object_sources(const)
|
257
|
-
|
258
|
-
|
254
|
+
begin
|
255
|
+
if sample = ObjectSpace.each_object(const).first
|
256
|
+
sources += object_sources(sample)
|
257
|
+
end
|
258
|
+
rescue RuntimeError => error # JRuby 1.7.12 fails to ObjectSpace.each_object
|
259
|
+
raise unless RUBY_PLATFORM =='java' && error.message.start_with?("ObjectSpace is disabled")
|
260
|
+
end
|
259
261
|
!sources.any?{ |source| source.start_with?(Padrino.root) }
|
260
262
|
end
|
261
263
|
|
262
264
|
##
|
263
|
-
# Gets all the sources in which target class
|
265
|
+
# Gets all the sources in which target's class or instance methods are defined.
|
264
266
|
#
|
265
267
|
# Note: Method#source_location is for Ruby 1.9.3+ only.
|
266
268
|
#
|
@@ -269,14 +271,7 @@ module Padrino
|
|
269
271
|
target.methods.each do |method_name|
|
270
272
|
next unless method_name.kind_of?(Symbol)
|
271
273
|
method_object = target.method(method_name)
|
272
|
-
if method_object.owner == target.singleton_class
|
273
|
-
sources << method_object.source_location.first
|
274
|
-
end
|
275
|
-
end
|
276
|
-
target.instance_methods.each do |method_name|
|
277
|
-
next unless method_name.kind_of?(Symbol)
|
278
|
-
method_object = target.instance_method(method_name)
|
279
|
-
if method_object.owner == target
|
274
|
+
if method_object.owner == (target.class == Class ? target.singleton_class : target.class)
|
280
275
|
sources << method_object.source_location.first
|
281
276
|
end
|
282
277
|
end
|
data/lib/padrino-core/version.rb
CHANGED
data/lib/padrino-core.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
require 'sinatra/base'
|
2
2
|
require 'padrino-core/version'
|
3
3
|
require 'padrino-support'
|
4
|
-
require 'padrino-core/configuration'
|
5
4
|
require 'padrino-core/application'
|
6
5
|
|
7
6
|
require 'padrino-core/caller'
|
@@ -26,7 +25,6 @@ module Padrino
|
|
26
25
|
class ApplicationLoadError < RuntimeError # @private
|
27
26
|
end
|
28
27
|
|
29
|
-
extend Configuration
|
30
28
|
extend Loader
|
31
29
|
|
32
30
|
class << self
|
data/padrino-core.gemspec
CHANGED
@@ -24,8 +24,14 @@ Gem::Specification.new do |s|
|
|
24
24
|
s.rdoc_options = ["--charset=UTF-8"]
|
25
25
|
|
26
26
|
s.add_dependency("padrino-support", Padrino.version)
|
27
|
-
|
28
|
-
|
27
|
+
if ENV["SINATRA_EDGE"]
|
28
|
+
s.add_dependency("sinatra")
|
29
|
+
else
|
30
|
+
# remove this rack dependency after Sinatra > 1.4.5
|
31
|
+
s.add_dependency("rack", "< 1.6.0")
|
32
|
+
s.add_dependency("sinatra", "~> 1.4.2")
|
33
|
+
end
|
34
|
+
s.add_dependency("mustermann19")
|
29
35
|
s.add_dependency("thor", "~> 0.18")
|
30
36
|
s.add_dependency("activesupport", ">= 3.1")
|
31
37
|
s.add_dependency("rack-protection", ">= 1.5.0")
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'active_support/logger_silence'
|
File without changes
|
@@ -0,0 +1,19 @@
|
|
1
|
+
PADRINO_ROOT = File.dirname(__FILE__) unless defined? PADRINO_ROOT
|
2
|
+
|
3
|
+
Padrino.configure_apps do
|
4
|
+
set :precompile_routes, true
|
5
|
+
end
|
6
|
+
|
7
|
+
module PrecompiledApp
|
8
|
+
class App < Padrino::Application
|
9
|
+
10.times{|n| get("/#{n}"){} }
|
10
|
+
end
|
11
|
+
class SubApp < Padrino::Application
|
12
|
+
10.times{|n| get("/#{n}"){} }
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
Padrino.mount("PrecompiledApp::SubApp").to("/subapp")
|
17
|
+
Padrino.mount("PrecompiledApp::App").to("/")
|
18
|
+
|
19
|
+
Padrino.load!
|
data/test/helper.rb
CHANGED
@@ -9,10 +9,10 @@ require 'builder'
|
|
9
9
|
require 'rack/test'
|
10
10
|
require 'yaml'
|
11
11
|
require 'padrino-core'
|
12
|
-
require 'tilt/haml'
|
13
12
|
|
14
13
|
require 'ext/minitest-spec'
|
15
14
|
require 'ext/rack-test-methods'
|
15
|
+
require 'ext/rack-test-utils'
|
16
16
|
|
17
17
|
class MiniTest::Spec
|
18
18
|
include Rack::Test::Methods
|
data/test/test_application.rb
CHANGED
@@ -86,16 +86,16 @@ describe "Application" do
|
|
86
86
|
end
|
87
87
|
|
88
88
|
it 'should have different session values in different session management' do
|
89
|
-
class
|
89
|
+
class PadrinoTestApp4 < Padrino::Application
|
90
90
|
enable :sessions
|
91
91
|
end
|
92
|
-
class
|
92
|
+
class PadrinoTestApp5 < Padrino::Application
|
93
93
|
set :sessions, :use => Rack::Session::Pool
|
94
94
|
end
|
95
|
-
Padrino.mount("
|
96
|
-
Padrino.mount("
|
97
|
-
|
98
|
-
|
95
|
+
Padrino.mount("PadrinoTestApp4").to("/write")
|
96
|
+
Padrino.mount("PadrinoTestApp5").to("/read")
|
97
|
+
PadrinoTestApp4.get('/') { session[:foo] = "cookie" }
|
98
|
+
PadrinoTestApp5.get('/') { session[:foo] }
|
99
99
|
@app = Padrino.application
|
100
100
|
get '/write'
|
101
101
|
get '/read'
|
@@ -158,6 +158,18 @@ describe "Application" do
|
|
158
158
|
end
|
159
159
|
end
|
160
160
|
|
161
|
+
describe "pre-compile routes" do
|
162
|
+
it "should compile routes before first request if enabled the :precompile_routes option" do
|
163
|
+
require File.expand_path(File.dirname(__FILE__) + '/fixtures/apps/precompiled_app')
|
164
|
+
assert_instance_of Padrino::PathRouter::Compiler, PrecompiledApp::App.compiled_router.engine
|
165
|
+
assert_instance_of Padrino::PathRouter::Compiler, PrecompiledApp::SubApp.compiled_router.engine
|
166
|
+
assert_equal true, PrecompiledApp::App.compiled_router.engine.compiled?
|
167
|
+
assert_equal true, PrecompiledApp::SubApp.compiled_router.engine.compiled?
|
168
|
+
assert_equal 20, PrecompiledApp::App.compiled_router.engine.regexps.length
|
169
|
+
assert_equal 20, PrecompiledApp::SubApp.compiled_router.engine.regexps.length
|
170
|
+
end
|
171
|
+
end
|
172
|
+
|
161
173
|
describe 'global prerequisites' do
|
162
174
|
after do
|
163
175
|
Padrino::Application.prerequisites.clear
|
@@ -6,7 +6,6 @@ describe "Application" do
|
|
6
6
|
describe 'CSRF protection' do
|
7
7
|
describe "with CSRF protection on" do
|
8
8
|
before do
|
9
|
-
@token = Rack::Protection::AuthenticityToken.random_token rescue "a_token"
|
10
9
|
mock_app do
|
11
10
|
enable :sessions
|
12
11
|
enable :protect_from_csrf
|
@@ -20,24 +19,25 @@ describe "Application" do
|
|
20
19
|
end
|
21
20
|
|
22
21
|
it 'should allow requests with correct tokens' do
|
23
|
-
post "/", {"authenticity_token" =>
|
22
|
+
post "/", {"authenticity_token" => "a"}, 'rack.session' => {:csrf => "a"}
|
24
23
|
assert_equal 200, status
|
25
24
|
end
|
26
25
|
|
27
26
|
it 'should not allow requests with incorrect tokens' do
|
28
|
-
post "/", {"authenticity_token" => "
|
27
|
+
post "/", {"authenticity_token" => "a"}, 'rack.session' => {:csrf => "b"}
|
29
28
|
assert_equal 403, status
|
30
29
|
end
|
31
30
|
|
32
31
|
it 'should allow requests with correct X-CSRF-TOKEN' do
|
33
|
-
post "/", {}, 'rack.session' => {:csrf =>
|
32
|
+
post "/", {}, 'rack.session' => {:csrf => "a"}, 'HTTP_X_CSRF_TOKEN' => "a"
|
34
33
|
assert_equal 200, status
|
35
34
|
end
|
36
35
|
|
37
36
|
it 'should not allow requests with incorrect X-CSRF-TOKEN' do
|
38
|
-
post "/", {}, 'rack.session' => {:csrf =>
|
37
|
+
post "/", {}, 'rack.session' => {:csrf => "a"}, 'HTTP_X_CSRF_TOKEN' => "b"
|
39
38
|
assert_equal 403, status
|
40
39
|
end
|
40
|
+
|
41
41
|
end
|
42
42
|
|
43
43
|
describe "without CSRF protection on" do
|
@@ -142,7 +142,6 @@ describe "Application" do
|
|
142
142
|
|
143
143
|
describe "with custom protection options" do
|
144
144
|
before do
|
145
|
-
@token = Rack::Protection::AuthenticityToken.random_token rescue "a_token"
|
146
145
|
mock_app do
|
147
146
|
enable :sessions
|
148
147
|
set :protect_from_csrf, :authenticity_param => 'foobar', :message => 'sucker!'
|
@@ -151,7 +150,7 @@ describe "Application" do
|
|
151
150
|
end
|
152
151
|
|
153
152
|
it 'should allow configuring protection options' do
|
154
|
-
post "/a", {"foobar" =>
|
153
|
+
post "/a", {"foobar" => "a"}, 'rack.session' => {:csrf => "a"}
|
155
154
|
assert_equal 200, status
|
156
155
|
end
|
157
156
|
|
data/test/test_filters.rb
CHANGED
@@ -300,6 +300,24 @@ describe "Filters" do
|
|
300
300
|
assert_equal 'before', test
|
301
301
|
end
|
302
302
|
|
303
|
+
it 'should ensure the call of before_filter at the first time' do
|
304
|
+
once = ''
|
305
|
+
mock_app do
|
306
|
+
before do
|
307
|
+
once += 'before'
|
308
|
+
end
|
309
|
+
get :index do
|
310
|
+
raise Exception, 'Oops'
|
311
|
+
end
|
312
|
+
post :index do
|
313
|
+
raise Exception, 'Oops'
|
314
|
+
end
|
315
|
+
end
|
316
|
+
|
317
|
+
post '/'
|
318
|
+
assert_equal 'before', once
|
319
|
+
end
|
320
|
+
|
303
321
|
it 'should call before filters only once' do
|
304
322
|
once = ''
|
305
323
|
mock_app do
|
@@ -368,5 +386,4 @@ describe "Filters" do
|
|
368
386
|
assert_equal 'We broke after', body
|
369
387
|
assert_equal 'Been now and after', doodle
|
370
388
|
end
|
371
|
-
|
372
389
|
end
|
data/test/test_logger.rb
CHANGED
@@ -1,7 +1,5 @@
|
|
1
|
-
#coding:utf-8
|
2
1
|
require File.expand_path(File.dirname(__FILE__) + '/helper')
|
3
2
|
require 'logger'
|
4
|
-
require 'tempfile'
|
5
3
|
|
6
4
|
describe "PadrinoLogger" do
|
7
5
|
before do
|
@@ -38,28 +36,6 @@ describe "PadrinoLogger" do
|
|
38
36
|
Padrino::Logger.setup!
|
39
37
|
assert_equal my_stream, Padrino.logger.log
|
40
38
|
end
|
41
|
-
|
42
|
-
it 'should use a custom file path' do
|
43
|
-
tempfile = Tempfile.new('app.txt')
|
44
|
-
path = tempfile.path
|
45
|
-
tempfile.unlink
|
46
|
-
Padrino::Logger::Config[:test][:stream] = :to_file
|
47
|
-
Padrino::Logger::Config[:test][:log_path] = path
|
48
|
-
Padrino::Logger.setup!
|
49
|
-
assert_file_exists path
|
50
|
-
File.unlink(path)
|
51
|
-
end
|
52
|
-
|
53
|
-
it 'should use a custom log directory' do
|
54
|
-
tmpdir = Dir.mktmpdir
|
55
|
-
Padrino::Logger::Config[:test][:stream] = :to_file
|
56
|
-
Padrino::Logger::Config[:test][:log_path] = tmpdir
|
57
|
-
Padrino::Logger.setup!
|
58
|
-
log_path = File.join(tmpdir, 'test.log')
|
59
|
-
assert_file_exists log_path
|
60
|
-
File.unlink(log_path)
|
61
|
-
Dir.rmdir(tmpdir)
|
62
|
-
end
|
63
39
|
end
|
64
40
|
|
65
41
|
it 'should log something' do
|
@@ -82,30 +58,6 @@ describe "PadrinoLogger" do
|
|
82
58
|
assert_match /log via alias/, @log.string
|
83
59
|
end
|
84
60
|
|
85
|
-
it 'should not blow up on mixed or broken encodings' do
|
86
|
-
setup_logger(:log_level => :error, :auto_flush => false)
|
87
|
-
binary_data = "\xD0".force_encoding('BINARY')
|
88
|
-
utf8_data = 'фыв'
|
89
|
-
@logger.error binary_data
|
90
|
-
@logger.error utf8_data
|
91
|
-
@logger.flush
|
92
|
-
assert @log.string.include?(utf8_data)
|
93
|
-
assert @log.string.force_encoding('BINARY').include?(binary_data)
|
94
|
-
end
|
95
|
-
|
96
|
-
it 'should sanitize mixed or broken encodings if said so' do
|
97
|
-
encoding = 'windows-1251'
|
98
|
-
setup_logger(:log_level => :error, :auto_flush => false, :sanitize_encoding => encoding)
|
99
|
-
@log.string.encode! encoding
|
100
|
-
binary_data = "\xD0".force_encoding('BINARY')
|
101
|
-
utf8_data = 'фыв'
|
102
|
-
@logger.error binary_data
|
103
|
-
@logger.error utf8_data
|
104
|
-
@logger.flush
|
105
|
-
assert @log.string.force_encoding(encoding).include?("?\n".encode(encoding))
|
106
|
-
assert @log.string.force_encoding(encoding).include?(utf8_data.encode(encoding))
|
107
|
-
end
|
108
|
-
|
109
61
|
it 'should log an application' do
|
110
62
|
mock_app do
|
111
63
|
enable :logging
|
@@ -310,7 +262,7 @@ describe "options :source_location" do
|
|
310
262
|
|
311
263
|
it 'should output source_location if :source_location is set to true' do
|
312
264
|
stub_root { Padrino.logger.debug("hello world") }
|
313
|
-
assert_match /\[test\/test_logger\.rb
|
265
|
+
assert_match /\[test\/test_logger\.rb:264\] hello world/, Padrino.logger.log.string
|
314
266
|
end
|
315
267
|
|
316
268
|
it 'should output source_location if file path is relative' do
|
data/test/test_mounter.rb
CHANGED
@@ -181,7 +181,7 @@ describe "Mounter" do
|
|
181
181
|
assert_equal "posts show", first_route.identifier.to_s
|
182
182
|
assert_equal "(:posts, :show)", first_route.name
|
183
183
|
assert_equal "GET", first_route.verb
|
184
|
-
assert_equal "/posts/show/:id(.:format)", first_route.path
|
184
|
+
assert_equal "/posts/show/:id(.:format)?", first_route.path
|
185
185
|
another_route = Padrino.mounted_apps[1].named_routes[2]
|
186
186
|
assert_equal "users create", another_route.identifier.to_s
|
187
187
|
assert_equal "(:users, :create)", another_route.name
|
@@ -255,7 +255,7 @@ describe "Mounter" do
|
|
255
255
|
end
|
256
256
|
|
257
257
|
it 'should support the Rack Application' do
|
258
|
-
path = File.expand_path(File.dirname(__FILE__) + '/fixtures/apps/rack_apps')
|
258
|
+
path = File.expand_path(File.dirname(__FILE__) + '/fixtures/apps/mountable_apps/rack_apps')
|
259
259
|
require path
|
260
260
|
Padrino.mount('rack_app', :app_class => 'RackApp', :app_file => path).to('/rack_app')
|
261
261
|
Padrino.mount('rack_app2', :app_class => 'RackApp2', :app_file => path).to('/rack_app2')
|
@@ -269,7 +269,6 @@ describe "Mounter" do
|
|
269
269
|
assert_equal "hello sinatra app", res.body
|
270
270
|
res = Rack::MockRequest.new(app).get("/sinatra_app/static.html")
|
271
271
|
assert_equal "hello static file\n", res.body
|
272
|
-
assert_equal [], RackApp.prerequisites
|
273
272
|
end
|
274
273
|
|
275
274
|
it 'should support the Rack Application inside padrino project' do
|
@@ -288,7 +287,6 @@ describe "Mounter" do
|
|
288
287
|
end
|
289
288
|
|
290
289
|
it "should not load dependency files if app's root isn't started with Padrino.root" do
|
291
|
-
Object.send(:remove_const, :FakeLib) if defined?(FakeLib)
|
292
290
|
path = File.expand_path(File.dirname(__FILE__) + '/fixtures/apps/demo_project/app')
|
293
291
|
fake_path = File.expand_path(File.dirname(__FILE__) + "/fixtures/apps/external_apps/fake_root")
|
294
292
|
require path
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '/helper')
|
2
|
+
require 'active_support/core_ext/hash/conversions'
|
2
3
|
|
3
4
|
describe "Padrino::ParamsProtection" do
|
4
5
|
before do
|
@@ -6,7 +7,6 @@ describe "Padrino::ParamsProtection" do
|
|
6
7
|
@kim = { 'name' => 'Kim Bauer', 'position' => 'daughter', 'child' => @teri }
|
7
8
|
@jack = { 'name' => 'Jack Bauer', 'position' => 'terrorist', 'child' => @kim }
|
8
9
|
@family = { 'name' => 'Bauer', 'persons' => { 1 => @teri, 2 => @kim, 3 => @jack } }
|
9
|
-
@jack_query = Padrino::Utils.build_uri_query(@jack)
|
10
10
|
end
|
11
11
|
|
12
12
|
it 'should drop all parameters except allowed ones' do
|
@@ -17,7 +17,7 @@ describe "Padrino::ParamsProtection" do
|
|
17
17
|
''
|
18
18
|
end
|
19
19
|
end
|
20
|
-
post '/basic?' + @
|
20
|
+
post '/basic?' + @jack.to_query
|
21
21
|
assert_equal({ 'name' => @jack['name'] }, result)
|
22
22
|
end
|
23
23
|
|
@@ -29,7 +29,7 @@ describe "Padrino::ParamsProtection" do
|
|
29
29
|
''
|
30
30
|
end
|
31
31
|
end
|
32
|
-
post '/basic?' + @
|
32
|
+
post '/basic?' + @jack.to_query
|
33
33
|
assert_equal(@jack, result)
|
34
34
|
end
|
35
35
|
|
@@ -41,7 +41,7 @@ describe "Padrino::ParamsProtection" do
|
|
41
41
|
''
|
42
42
|
end
|
43
43
|
end
|
44
|
-
post '/basic?' + @
|
44
|
+
post '/basic?' + @jack.to_query
|
45
45
|
assert_equal(
|
46
46
|
[
|
47
47
|
{ 'name' => @jack['name'], 'child' => { 'name' => @kim['name'], 'child' => { 'name' => @teri['name'] } } },
|
@@ -59,7 +59,7 @@ describe "Padrino::ParamsProtection" do
|
|
59
59
|
''
|
60
60
|
end
|
61
61
|
end
|
62
|
-
post '/basic?' + @
|
62
|
+
post '/basic?' + @jack.to_query
|
63
63
|
assert_equal({ 'name' => @jack['name'], 'position' => 'anti-terrorist' }, result)
|
64
64
|
end
|
65
65
|
|
@@ -71,7 +71,7 @@ describe "Padrino::ParamsProtection" do
|
|
71
71
|
''
|
72
72
|
end
|
73
73
|
end
|
74
|
-
post '/basic/24/42?' + @
|
74
|
+
post '/basic/24/42?' + @jack.to_query
|
75
75
|
assert_equal({ 'name' => @jack['name'], 'id' => '24', 'tag' => '42' }, result)
|
76
76
|
end
|
77
77
|
|
@@ -83,7 +83,7 @@ describe "Padrino::ParamsProtection" do
|
|
83
83
|
''
|
84
84
|
end
|
85
85
|
end
|
86
|
-
post '/basic/24?' + @
|
86
|
+
post '/basic/24?' + @jack.to_query
|
87
87
|
assert_equal({ 'id' => '24' }, result)
|
88
88
|
end
|
89
89
|
|
@@ -99,9 +99,9 @@ describe "Padrino::ParamsProtection" do
|
|
99
99
|
''
|
100
100
|
end
|
101
101
|
end
|
102
|
-
get '/hide/1?' + @
|
102
|
+
get '/hide/1?' + @jack.to_query
|
103
103
|
assert_equal({"id"=>"1"}, result)
|
104
|
-
get '/show/1?' + @
|
104
|
+
get '/show/1?' + @jack.to_query
|
105
105
|
assert_equal({"id"=>"1"}.merge(@jack), result)
|
106
106
|
end
|
107
107
|
|
@@ -133,13 +133,13 @@ describe "Padrino::ParamsProtection" do
|
|
133
133
|
end
|
134
134
|
end
|
135
135
|
end
|
136
|
-
post '/persons/create?' + @
|
136
|
+
post '/persons/create?' + @jack.to_query
|
137
137
|
assert_equal({ 'name' => @jack['name'], 'position' => 'terrorist' }, result)
|
138
138
|
post '/persons/update/1?name=Chloe+O\'Brian&position=hacker'
|
139
139
|
assert_equal({ 'id' => '1', 'name' => 'Chloe O\'Brian' }, result)
|
140
|
-
post '/persons/delete?' + @
|
140
|
+
post '/persons/delete?' + @jack.to_query
|
141
141
|
assert_equal(@jack, result)
|
142
|
-
post '/persons/destroy/1?' + @
|
142
|
+
post '/persons/destroy/1?' + @jack.to_query
|
143
143
|
assert_equal({"id"=>"1"}, result)
|
144
144
|
get '/noparam?a=1;b=2'
|
145
145
|
assert_equal({}, result)
|
@@ -153,7 +153,7 @@ describe "Padrino::ParamsProtection" do
|
|
153
153
|
''
|
154
154
|
end
|
155
155
|
end
|
156
|
-
post '/family?' +
|
156
|
+
post '/family?' + @family.to_query
|
157
157
|
assert_equal({"persons" => {"3" => {"name" => @jack["name"]}, "2" => {"name" => @kim["name"]}, "1" => {"name" => @teri["name"]}}}, result)
|
158
158
|
end
|
159
159
|
|
@@ -165,7 +165,7 @@ describe "Padrino::ParamsProtection" do
|
|
165
165
|
''
|
166
166
|
end
|
167
167
|
end
|
168
|
-
post '/family?' +
|
168
|
+
post '/family?' + { :names => %w{Jack Kim Teri} }.to_query
|
169
169
|
assert_equal({"names" => %w[Jack Kim Teri]}, result)
|
170
170
|
end
|
171
171
|
|
@@ -177,7 +177,7 @@ describe "Padrino::ParamsProtection" do
|
|
177
177
|
''
|
178
178
|
end
|
179
179
|
end
|
180
|
-
post '/i?' +
|
180
|
+
post '/i?' + { :gotta => { :what => 'go', :who => 'self' } }.to_query
|
181
181
|
assert_equal({"gotta" => {"what" => "go"}}, result)
|
182
182
|
end
|
183
183
|
|