Skip to content

Commit

Permalink
Merge pull request #3022 from wecc/build-url-mixin-updateRecord
Browse files Browse the repository at this point in the history
Add missing urlForUpdateRecord to BuildURLMixin
  • Loading branch information
fivetanley committed Apr 24, 2015
2 parents 0f5f777 + e3cc90f commit 9b4e2aa
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
13 changes: 13 additions & 0 deletions packages/ember-data/lib/adapters/build-url-mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ export default Ember.Mixin.create({
return this.urlForFindBelongsTo(id, type);
case 'createRecord':
return this.urlForCreateRecord(type, snapshot);
case 'updateRecord':
return this.urlForUpdateRecord(id, type, snapshot);
case 'deleteRecord':
return this.urlForDeleteRecord(id, type, snapshot);
default:
Expand Down Expand Up @@ -171,6 +173,17 @@ export default Ember.Mixin.create({
return this._buildURL(type);
},

/**
* @method urlForUpdateRecord
* @param {String} id
* @param {String} type
* @param {DS.Snapshot} snapshot
* @return {String} url
*/
urlForUpdateRecord: function(id, type, snapshot) {
return this._buildURL(type, id);
},

/**
* @method urlForDeleteRecord
* @param {String} id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ test('buildURL - findBelongsTo requestType delegates to urlForFindBelongsTo', fu
equal(adapter.buildURL('super-user', 1, null, 'findBelongsTo'), '/superUsers/1');
});

test('buildURL - createRecord requestType delegates to urlForFindBelongsTo', function() {
test('buildURL - createRecord requestType delegates to urlForCreateRecord', function() {
expect(3);
var snapshotStub = { snapshot: true };
var originalMethod = adapter.urlForCreateRecord;
Expand All @@ -118,6 +118,19 @@ test('buildURL - createRecord requestType delegates to urlForFindBelongsTo', fun
equal(adapter.buildURL('super-user', null, snapshotStub, 'createRecord'), '/superUsers');
});

test('buildURL - updateRecord requestType delegates to urlForUpdateRecord', function() {
expect(4);
var snapshotStub = { snapshot: true };
var originalMethod = adapter.urlForUpdateRecord;
adapter.urlForUpdateRecord = function(id, type, snapshot) {
equal(id, 1);
equal(type, 'super-user');
equal(snapshot, snapshotStub);
return originalMethod.apply(this, arguments);
};
equal(adapter.buildURL('super-user', 1, snapshotStub, 'updateRecord'), '/superUsers/1');
});

test('buildURL - deleteRecord requestType delegates to urlForDeleteRecord', function() {
expect(4);
var snapshotStub = { snapshot: true };
Expand Down

0 comments on commit 9b4e2aa

Please sign in to comment.