Permalink
Browse files

Support for adding in the action to the url function.

  • Loading branch information...
1 parent 3831997 commit 2610b7b7450acb84a49c2258e295e45c5dc7ebe3 @jshirley committed Mar 13, 2012
@@ -259,7 +259,7 @@ RESTSync.prototype = {
sync : function (action, options, callback) {
options || (options = {});
- var url = this._getURL(),
+ var url = this._getURL(action),
method = RESTSync.HTTP_METHODS[action],
headers = Y.merge(RESTSync.HTTP_HEADERS, options.headers),
timeout = options.timeout || RESTSync.HTTP_TIMEOUT,
@@ -314,15 +314,16 @@ RESTSync.prototype = {
This method correctly handles variations of the `url` property/method.
@method _getURL
+ @param {String} action Sync action to perform.
@return {String} the URL for the XHR
@protected
**/
- _getURL : function () {
+ _getURL : function (action) {
var url = this.url,
data;
if (isFunction(url)) {
- return this.url();
+ return this.url(action);
}
if (this instanceof Y.Model) {
@@ -177,6 +177,13 @@ suite.add(new Y.Test.Case({
model.root = '/model/';
Assert.areSame('/model/123/', model.url());
+ },
+ 'url() should return a URL determined from the sync action' : function () {
+ var model = new this.TestModel({ id: 123 });
+
+ model.url = function(action) { return '/model/' + action; };
+
+ Assert.areSame('/model/read', model._getURL('read'));
}
}));

0 comments on commit 2610b7b

Please sign in to comment.