Skip to content
Browse files

Add some JSONP tests.

  • Loading branch information...
1 parent dcc7169 commit 70b116062916ffaf8ae9786b95c3468bfd027ee1 @benpickles committed
Showing with 25 additions and 1 deletion.
  1. +1 −0 lib/bundler.rb
  2. +22 −0 test/app.rb
  3. +2 −1 test/views/index.erb
View
1 lib/bundler.rb
@@ -33,6 +33,7 @@ def files
model_class_methods
model_errors
model_instance_methods
+ model_jsonp
model_local_storage
model_log
model_rest
View
22 test/app.rb
@@ -1,8 +1,13 @@
require 'rubygems'
require 'sinatra'
+require 'rack/contrib'
require 'json'
require 'erb'
+
require File.expand_path('../../lib/bundler', __FILE__)
+require File.expand_path('../../lib/jsonp', __FILE__)
+
+use Rack::JSONP
def json!
content_type 'application/json'
@@ -115,3 +120,20 @@ def json!
:title => ['must do something else before deleting']
})
end
+
+get '/jsonp/posts' do
+ json!
+ JSON.generate([
+ { :title => 'a' },
+ { :title => 'b' }
+ ])
+end
+
+get '/jsonp/posts-slooow' do
+ sleep 2
+ json!
+ JSON.generate([
+ { :title => 'a' },
+ { :title => 'b' }
+ ])
+end
View
3 test/views/index.erb
@@ -21,9 +21,10 @@
<script src="tests/model_callbacks.js"></script>
<script src="tests/model_class_methods.js"></script>
<script src="tests/model_errors.js"></script>
+<script src="tests/model_jsonp.js"></script>
+<script src="tests/model_local_storage.js"></script>
<script src="tests/model_rest.js"></script>
<script src="tests/model_uid.js"></script>
-<script src="tests/model_local_storage.js"></script>
</head>
<body>
<h1 id="qunit-header">js-model Tests</h1>

0 comments on commit 70b1160

Please sign in to comment.
Something went wrong with that request. Please try again.