Permalink
Browse files

Finally tracked down that testing bug.

git-svn-id: https://svn.thoughtbot.com/jester/trunk@109 d7758119-aa2c-0410-afcd-b700fbd0d0b3
  • Loading branch information...
1 parent 6162024 commit 1fe5406d7f220c41127cbcf47997233e92f51119 emill committed Oct 9, 2007
Showing with 37 additions and 35 deletions.
  1. +37 −35 test/jester_test.html
View
@@ -93,6 +93,41 @@
'created_at' : { '@type' : 'datetime' }
}
+ Resource.requestAndParse = function (format, callback, url, options, user_callback, remote) {
+ if (remote && format == "json") {
+ jesterCallback = function(json){
+ result = callback(json);
+ if (user_callback && typeof(user_callback) == "function") {
+ changed = true;
+ user_callback(result);
+ }
+ }
+ eval('var result = ' + Internet[url]);
+ return result;
+ }
+
+ var result = Internet[url];
+
+ if (format == "json")
+ eval('result = ' + result);
+
+ if (callback)
+ result = callback(result);
+
+ if (user_callback) {
+ changed = true;
+ if (typeof(user_callback) == "function")
+ result = user_callback(result);
+ else {
+ user_callback = user_callback.on200 || user_callback.onComplete;
+ if (user_callback)
+ result = user_callback(result);
+ }
+ }
+
+ return result;
+ }
+
// JSON callback
jesterCallback = null;
@@ -118,7 +153,7 @@
// Path prefixed models
Resource.model("Post", {prefix: "/users/:user_id"})
- Internet[Post._show_url(1, {user_id: 1})] = {'post': postDetails1};
+ Internet[Post._show_url({id: 1, user_id: 1})] = {'post': postDetails1};
// XML models
Resource.model("User")
@@ -142,40 +177,7 @@
changed = false;
assert_changed = function() {assert(changed); changed = false;}
- Resource.requestAndParse = function (format, callback, url, options, user_callback, remote) {
- if (remote && format == "json") {
- jesterCallback = function(json){
- result = callback(json);
- if (user_callback && typeof(user_callback) == "function") {
- changed = true;
- user_callback(result);
- }
- }
- eval('var result = ' + Internet[url]);
- return result;
- }
-
- var result = Internet[url];
-
- if (format == "json")
- eval('result = ' + result);
-
- if (callback)
- result = callback(result);
-
- if (user_callback) {
- changed = true;
- if (typeof(user_callback) == "function")
- result = user_callback(result);
- else {
- user_callback = user_callback.on200 || user_callback.onComplete;
- if (user_callback)
- result = user_callback(result);
- }
- }
-
- return result;
- }
+ return true;
}

0 comments on commit 1fe5406

Please sign in to comment.