Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge branch 'master' of https://github.com/mkelly12/backbone
  • Loading branch information
jashkenas committed Dec 10, 2010
2 parents 17602c3 + 5249010 commit 03aa12a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion backbone.js
Expand Up @@ -291,7 +291,7 @@
// using Backbone's restful methods, override this to change the endpoint
// that will be called.
url : function() {
var base = getUrl(this.collection);
var base = this.urlBase || getUrl(this.collection);
if (this.isNew()) return base;
return base + (base.charAt(base.length - 1) == '/' ? '' : '/') + this.id;
},
Expand Down
10 changes: 10 additions & 0 deletions test/model.js
Expand Up @@ -65,6 +65,16 @@ $(document).ready(function() {
equals(failed, true);
doc.collection = collection;
});

test("Model: url when using urlBase", function() {
var Model = Backbone.Model.extend({
urlBase: '/collection'
});
var model = new Model();
equals(model.url(), '/collection');
model.set({id: '1'});
equals(model.url(), '/collection/1');
});

test("Model: clone", function() {
attrs = { 'foo': 1, 'bar': 2, 'baz': 3};
Expand Down

0 comments on commit 03aa12a

Please sign in to comment.