rack-jsonp-tools 0.3.4 → 0.3.5
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/rack/jsonp/status_wrapper.rb +1 -1
- data/rack-jsonp-tools.gemspec +1 -1
- data/test/callback_test.rb +4 -7
- data/test/status_wrapper_test.rb +1 -1
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.5
|
@@ -12,7 +12,7 @@ module Rack
|
|
12
12
|
status, headers, @body = @app.call(env)
|
13
13
|
|
14
14
|
if headers["Content-Type"] == "application/json"
|
15
|
-
@pre, @post = '{"body":
|
15
|
+
@pre, @post = '{"body":', ', "status":' + status.to_s + '}'
|
16
16
|
headers["Content-Length"] = (@pre.size + headers["Content-Length"].to_i + @post.size).to_s
|
17
17
|
[status, headers, self]
|
18
18
|
else
|
data/rack-jsonp-tools.gemspec
CHANGED
data/test/callback_test.rb
CHANGED
@@ -37,18 +37,15 @@ class CallbackTest < Test::Unit::TestCase
|
|
37
37
|
assert_equal expected_body, body
|
38
38
|
end
|
39
39
|
|
40
|
-
test "doesn't touch response if
|
40
|
+
test "doesn't touch response if content type is not application/json" do
|
41
41
|
env = Rack::MockRequest.env_for("/?_callback=callback")
|
42
|
-
app = Rack::JSONP::Callback.new(lambda { |env| [301,
|
42
|
+
app = Rack::JSONP::Callback.new(lambda { |env| [301, {}, [""]] })
|
43
43
|
|
44
44
|
status, headers, iterable = app.call(env)
|
45
45
|
body = ""; iterable.each { |l| body << l }
|
46
46
|
|
47
47
|
assert_equal 301, status
|
48
|
-
assert_equal
|
49
|
-
|
50
|
-
"Content-Length" => @body.size.to_s
|
51
|
-
}
|
52
|
-
assert_equal @body, body
|
48
|
+
assert_equal Hash.new, headers
|
49
|
+
assert_equal "", body
|
53
50
|
end
|
54
51
|
end
|
data/test/status_wrapper_test.rb
CHANGED
@@ -33,7 +33,7 @@ class StatusWrapperTest < Test::Unit::TestCase
|
|
33
33
|
status, headers, iterable = app.call(env)
|
34
34
|
body = ""; iterable.each { |l| body << l }
|
35
35
|
|
36
|
-
expected_body = 'callback({"body":
|
36
|
+
expected_body = 'callback({"body":' + @body + ', "status":' + @status.to_s + '})'
|
37
37
|
|
38
38
|
assert_equal 200, status
|
39
39
|
assert_equal @headers, {
|