restrack 1.5.1 → 1.6.0
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.
data/lib/restrack/response.rb
CHANGED
@@ -83,6 +83,8 @@ module RESTRack
|
|
83
83
|
def package(data)
|
84
84
|
if mime_type.like?( RESTRack.mime_type_for( :JSON ) )
|
85
85
|
output = data.to_json
|
86
|
+
elsif mime_type.like?( RESTRack.mime_type_for( :JS ) ) and !@request.get_params['callback'].nil?
|
87
|
+
output = @request.get_params['callback'] + "(#{data.to_json});"
|
86
88
|
elsif mime_type.like?( RESTRack.mime_type_for( :XML ) )
|
87
89
|
if File.exists? builder_file
|
88
90
|
output = builder_up(data)
|
data/lib/restrack/version.rb
CHANGED
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'test/unit'
|
3
|
+
require 'rack/test'
|
4
|
+
require File.expand_path(File.join(File.dirname(__FILE__),'..','loader'))
|
5
|
+
require 'pp'
|
6
|
+
|
7
|
+
class SampleApp::TestCallback < Test::Unit::TestCase
|
8
|
+
|
9
|
+
def setup
|
10
|
+
@ws = SampleApp::WebService.new
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_show
|
14
|
+
env = Rack::MockRequest.env_for('/foo_bar/144.js?callback=my_function', {
|
15
|
+
:method => 'GET'
|
16
|
+
})
|
17
|
+
output = ''
|
18
|
+
assert_nothing_raised do
|
19
|
+
output = @ws.call(env)
|
20
|
+
end
|
21
|
+
test_val = 'my_function('+ { :foo => 'bar', :baz => 123 }.to_json + ');'
|
22
|
+
assert_equal test_val, output[2][0]
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
@@ -105,7 +105,7 @@ class SampleApp::TestResourceRequest < Test::Unit::TestCase
|
|
105
105
|
assert_nothing_raised do
|
106
106
|
output = @ws.call(env)
|
107
107
|
end
|
108
|
-
assert_equal
|
108
|
+
assert_equal 200, output[0]
|
109
109
|
|
110
110
|
RESTRack::CONFIG[:ROOT_RESOURCE_DENY] = nil
|
111
111
|
env = Rack::MockRequest.env_for('/foo_bar/144', {
|
@@ -115,7 +115,7 @@ class SampleApp::TestResourceRequest < Test::Unit::TestCase
|
|
115
115
|
assert_nothing_raised do
|
116
116
|
output = @ws.call(env)
|
117
117
|
end
|
118
|
-
assert_equal
|
118
|
+
assert_equal 200, output[0]
|
119
119
|
|
120
120
|
RESTRack::CONFIG[:ROOT_RESOURCE_DENY] = ['']
|
121
121
|
# it should handle this, although it is incorrect
|
@@ -126,7 +126,7 @@ class SampleApp::TestResourceRequest < Test::Unit::TestCase
|
|
126
126
|
assert_nothing_raised do
|
127
127
|
output = @ws.call(env)
|
128
128
|
end
|
129
|
-
assert_equal
|
129
|
+
assert_equal 200, output[0]
|
130
130
|
|
131
131
|
RESTRack::CONFIG[:ROOT_RESOURCE_DENY] = [ 'baz' ]
|
132
132
|
end
|
@@ -207,7 +207,7 @@ class SampleApp::TestResourceRequest < Test::Unit::TestCase
|
|
207
207
|
assert_nothing_raised do
|
208
208
|
output = @ws.call(env)
|
209
209
|
end
|
210
|
-
assert_equal
|
210
|
+
assert_equal 200, output[0]
|
211
211
|
end
|
212
212
|
|
213
213
|
def test_force_encoding_defined
|
@@ -241,7 +241,7 @@ class SampleApp::TestResourceRequest < Test::Unit::TestCase
|
|
241
241
|
assert_nothing_raised do
|
242
242
|
output = @ws.call(env)
|
243
243
|
end
|
244
|
-
assert_equal
|
244
|
+
assert_equal 200, output[0]
|
245
245
|
end
|
246
246
|
|
247
247
|
def test_force_encoding_not_defined
|
@@ -274,7 +274,7 @@ class SampleApp::TestResourceRequest < Test::Unit::TestCase
|
|
274
274
|
assert_nothing_raised do
|
275
275
|
output = @ws.call(env)
|
276
276
|
end
|
277
|
-
assert_equal
|
277
|
+
assert_equal 200, output[0]
|
278
278
|
end
|
279
279
|
|
280
280
|
end
|
@@ -66,7 +66,7 @@ class SampleApp::TestResourceRequest < Test::Unit::TestCase
|
|
66
66
|
assert_nothing_raised do
|
67
67
|
output = @ws.call(env)
|
68
68
|
end
|
69
|
-
assert_equal
|
69
|
+
assert_equal 200, output[0]
|
70
70
|
|
71
71
|
# the following request should hit the default controller's index method (BazuController)
|
72
72
|
env = Rack::MockRequest.env_for('', {
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: restrack
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.6.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-05
|
12
|
+
date: 2012-07-05 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rack
|
@@ -189,6 +189,7 @@ files:
|
|
189
189
|
- test/sample_app_1/controllers/errors_controller.rb
|
190
190
|
- test/sample_app_1/controllers/foo_bar_controller.rb
|
191
191
|
- test/sample_app_1/loader.rb
|
192
|
+
- test/sample_app_1/test/test_callback.rb
|
192
193
|
- test/sample_app_1/test/test_controller_actions.rb
|
193
194
|
- test/sample_app_1/test/test_controller_inputs.rb
|
194
195
|
- test/sample_app_1/test/test_controller_modifiers.rb
|