Permalink
Browse files

AjaxFuture#triggerSuccess now calls beforeEvents and afterEvents arou…

…nd the nonexistent events.

This just gives the future a more consistent interface.
  • Loading branch information...
1 parent 1437aa5 commit 885a81ede45bd16782ecf9384a2fb2e798dbde51 @nathansobo committed Jan 12, 2011
Showing with 5 additions and 3 deletions.
  1. +2 −0 lib/monarch/http/ajax_future.js
  2. +3 −3 spec/monarch/http/ajax_future_spec.js
@@ -38,6 +38,8 @@ _.constructor("Monarch.Http.AjaxFuture", {
this.triggered = true;
this.successful = true;
this.data = data;
+ this.beforeEventsNode.publish(data);
+ this.afterEventsNode.publish(data);
this.onSuccessNode.publish(data);
this.onCompleteNode.publish(data);
},
@@ -56,7 +56,7 @@ Screw.Unit(function(c) { with(c) {
});
context("when the response does not include a dataset", function() {
- it("invokes only success callbacks with the response's 'data' hash and does not invoke failure, beforeEvents, or afterEvents callbacks", function() {
+ it("invokes beforeEvents, afterEvents, and success callbacks with the response's 'data' hash and does not invoke failure callbacks", function() {
var beforeEventsCallback = mockFunction("before events callback");
var afterEventsCallback = mockFunction("after events callback");
var successCallback = mockFunction("success callback");
@@ -73,9 +73,9 @@ Screw.Unit(function(c) { with(c) {
data: data
});
+ expect(beforeEventsCallback).to(haveBeenCalled, withArgs(data));
+ expect(afterEventsCallback).to(haveBeenCalled, withArgs(data));
expect(successCallback).to(haveBeenCalled, withArgs(data));
- expect(beforeEventsCallback).toNot(haveBeenCalled);
- expect(afterEventsCallback).toNot(haveBeenCalled);
expect(failureCallback).toNot(haveBeenCalled);
});
});

0 comments on commit 885a81e

Please sign in to comment.