Skip to content

Commit 33aaccf

Browse files
committed
1 parent a69f39b commit 33aaccf

2 files changed

Lines changed: 34 additions & 0 deletions

File tree

‎Core/JavaScript/RouteManager.js‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,7 @@
247247
/// <param name="dataType" mayBeNull="true" optional="true" type="String" parameterArray="false" integer="false" domElement="false">POST request data type</param>
248248

249249
$.post(this.toUrl(), getData(data), success, dataType);
250+
return this;
250251
};
251252

252253
this.get = function (data, success, dataType) {
@@ -256,6 +257,7 @@
256257
/// <param name="dataType" mayBeNull="true" optional="true" type="String" parameterArray="false" integer="false" domElement="false">GET request data type</param>
257258

258259
$.get(this.toUrl(), getData(data), success, dataType);
260+
return this;
259261
};
260262
};
261263

‎Test/JavaScript/RouteManagerTests.js‎

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,4 +341,36 @@ test("mapControllerAction adds action with different name when action already ex
341341
$.routeManager.mapControllerAction(controller, action, fn2);
342342
same(fn, $.routeManager.controllers[controller][action]);
343343
same(fn2, $.routeManager.controllers[controller][action + "1"]);
344+
});
345+
346+
test("action returns result with get that is chainable", function () {
347+
expect(1);
348+
$.routeManager.mapRoute('{controller}/{action}', '', { id: 5 });
349+
350+
$.mockjax({
351+
url: '/foo/bar',
352+
response: function (data) {
353+
start();
354+
return "";
355+
}
356+
});
357+
358+
stop();
359+
equal($.routeManager.action({ controller: "foo", action: "bar" }).get().toUrl(), "/foo/bar");
360+
});
361+
362+
test("action returns result with post that is chainable", function () {
363+
expect(1);
364+
$.routeManager.mapRoute('{controller}/{action}', '', { id: 5 });
365+
366+
$.mockjax({
367+
url: '/foo/bar',
368+
response: function (data) {
369+
start();
370+
return "";
371+
}
372+
});
373+
374+
stop();
375+
equal($.routeManager.action({ controller: "foo", action: "bar" }).post().toUrl(), "/foo/bar");
344376
});

0 commit comments

Comments
 (0)