Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Make that test a bit more reliable.

I think slow responses from the server were causing these tests to fail because ajax:after is called after the ajax request is sent and it didn't look like it was guaranteed that the request had completed by the time ajax:after was called.

Instead, call the start() method when the ajax:complete callback is triggered because in this case we know the ajax has completed and the other callbacks have already been run (their assertions were triggered)
  • Loading branch information...
commit eff8d30bd21dc6c665a2ba971fd26593abf0ae24 1 parent 95f3fde
Alex Crichton alexcrichton authored josevalim committed
Showing with 4 additions and 4 deletions.
  1. +4 −4 test/public/test/call-remote-callbacks.js
8 test/public/test/call-remote-callbacks.js
View
@@ -52,8 +52,8 @@ test('before, loading, success, complete and after callbacks should be called',
.bind('ajax:before', function() { ok(true, 'ajax:before'); return true; })
.bind('ajax:loading', function(arg) { ok(true, 'ajax:loading'); })
.bind('ajax:success', function(arg) { ok(true, 'ajax:success'); })
- .bind('ajax:complete', function(arg) { ok(true, 'ajax:complete'); })
- .bind('ajax:after', function() { ok(true, 'ajax:after'); start(); });
+ .bind('ajax:complete', function(arg) { ok(true, 'ajax:complete'); start(); })
+ .bind('ajax:after', function() { ok(true, 'ajax:after'); });
$('form[data-remote]').trigger('submit');
});
@@ -70,8 +70,8 @@ test('before, loading, error, complete and after callbacks should be called in c
ok(true, 'ajax:failure');
equals(xhr.status, 403, 'status code should be 403');
})
- .bind('ajax:complete', function(arg) { ok(true, 'ajax:complete'); })
- .bind('ajax:after', function() { ok(true, 'ajax:after'); start(); });
+ .bind('ajax:complete', function(arg) { ok(true, 'ajax:complete'); start(); })
+ .bind('ajax:after', function() { ok(true, 'ajax:after'); });
$('form[data-remote]').trigger('submit');
});
Please sign in to comment.
Something went wrong with that request. Please try again.