sinatra 0.9.0.1 → 0.9.0.2
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of sinatra might be problematic. Click here for more details.
- data/lib/sinatra/base.rb +8 -3
- data/sinatra.gemspec +1 -1
- data/test/filter_test.rb +16 -1
- metadata +1 -1
data/lib/sinatra/base.rb
CHANGED
@@ -4,7 +4,7 @@ require 'rack'
|
|
4
4
|
require 'rack/builder'
|
5
5
|
|
6
6
|
module Sinatra
|
7
|
-
VERSION = '0.9.0.
|
7
|
+
VERSION = '0.9.0.2'
|
8
8
|
|
9
9
|
class Request < Rack::Request
|
10
10
|
def user_agent
|
@@ -328,7 +328,11 @@ module Sinatra
|
|
328
328
|
|
329
329
|
private
|
330
330
|
def dispatch!
|
331
|
-
self.class.filters.each
|
331
|
+
self.class.filters.each do |block|
|
332
|
+
res = catch(:halt) { instance_eval(&block) ; :continue }
|
333
|
+
return unless res == :continue
|
334
|
+
end
|
335
|
+
|
332
336
|
if routes = self.class.routes[@request.request_method]
|
333
337
|
path = @request.path_info
|
334
338
|
original_params = nested_params(@request.params)
|
@@ -408,6 +412,7 @@ module Sinatra
|
|
408
412
|
when (100...599) === res
|
409
413
|
@response.status = res
|
410
414
|
end
|
415
|
+
|
411
416
|
res
|
412
417
|
end
|
413
418
|
|
@@ -522,7 +527,7 @@ module Sinatra
|
|
522
527
|
end
|
523
528
|
|
524
529
|
def before(&block)
|
525
|
-
@filters <<
|
530
|
+
@filters << block
|
526
531
|
end
|
527
532
|
|
528
533
|
def condition(&block)
|
data/sinatra.gemspec
CHANGED
@@ -3,7 +3,7 @@ Gem::Specification.new do |s|
|
|
3
3
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
4
4
|
|
5
5
|
s.name = 'sinatra'
|
6
|
-
s.version = '0.9.0.
|
6
|
+
s.version = '0.9.0.2'
|
7
7
|
s.date = '2009-01-18'
|
8
8
|
|
9
9
|
s.description = "Classy web-development dressed in a DSL"
|
data/test/filter_test.rb
CHANGED
@@ -33,15 +33,30 @@ describe "Filters" do
|
|
33
33
|
assert_equal 'bar', body
|
34
34
|
end
|
35
35
|
|
36
|
+
it "can modify instance variables available to routes" do
|
37
|
+
mock_app {
|
38
|
+
before { @foo = 'bar' }
|
39
|
+
get('/foo') { @foo }
|
40
|
+
}
|
41
|
+
|
42
|
+
get '/foo'
|
43
|
+
assert ok?
|
44
|
+
assert_equal 'bar', body
|
45
|
+
end
|
46
|
+
|
36
47
|
it "allows redirects in filters" do
|
37
48
|
mock_app {
|
38
49
|
before { redirect '/bar' }
|
39
|
-
get('/foo')
|
50
|
+
get('/foo') do
|
51
|
+
fail 'before block should have halted processing'
|
52
|
+
'ORLY?!'
|
53
|
+
end
|
40
54
|
}
|
41
55
|
|
42
56
|
get '/foo'
|
43
57
|
assert redirect?
|
44
58
|
assert_equal '/bar', response['Location']
|
59
|
+
assert_equal '', body
|
45
60
|
end
|
46
61
|
|
47
62
|
it "does not modify the response with its return value" do
|