Skip to content

Commit

Permalink
Add some JSONP tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
benpickles committed Sep 27, 2010
1 parent dcc7169 commit 70b1160
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
1 change: 1 addition & 0 deletions lib/bundler.rb
Expand Up @@ -33,6 +33,7 @@ def files
model_class_methods model_class_methods
model_errors model_errors
model_instance_methods model_instance_methods
model_jsonp
model_local_storage model_local_storage
model_log model_log
model_rest model_rest
Expand Down
22 changes: 22 additions & 0 deletions test/app.rb
@@ -1,8 +1,13 @@
require 'rubygems' require 'rubygems'
require 'sinatra' require 'sinatra'
require 'rack/contrib'
require 'json' require 'json'
require 'erb' require 'erb'

require File.expand_path('../../lib/bundler', __FILE__) require File.expand_path('../../lib/bundler', __FILE__)
require File.expand_path('../../lib/jsonp', __FILE__)

use Rack::JSONP


def json! def json!
content_type 'application/json' content_type 'application/json'
Expand Down Expand Up @@ -115,3 +120,20 @@ def json!
:title => ['must do something else before deleting'] :title => ['must do something else before deleting']
}) })
end 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
3 changes: 2 additions & 1 deletion test/views/index.erb
Expand Up @@ -21,9 +21,10 @@
<script src="tests/model_callbacks.js"></script> <script src="tests/model_callbacks.js"></script>
<script src="tests/model_class_methods.js"></script> <script src="tests/model_class_methods.js"></script>
<script src="tests/model_errors.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_rest.js"></script>
<script src="tests/model_uid.js"></script> <script src="tests/model_uid.js"></script>
<script src="tests/model_local_storage.js"></script>
</head> </head>
<body> <body>
<h1 id="qunit-header">js-model Tests</h1> <h1 id="qunit-header">js-model Tests</h1>
Expand Down

0 comments on commit 70b1160

Please sign in to comment.