Skip to content

Commit 6ac4ccf

Browse files
committed
Added a test.
1 parent 3b5f589 commit 6ac4ccf

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

test/integration/datastore/async_methods/save.test.js

+21
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,27 @@ describe('DS.save(resourceName, id[, options])', function () {
8080
assert.equal(lifecycle.serialize.callCount, 1, 'serialize should have been called');
8181
assert.equal(lifecycle.deserialize.callCount, 1, 'deserialize should have been called');
8282
});
83+
it('should save an item to the server and inject the result when using a custom http method', function () {
84+
$httpBackend.expectPATCH('http://test.angular-cache.com/posts/5').respond(200, {
85+
author: 'Jake',
86+
id: 5,
87+
age: 30
88+
});
89+
90+
DS.inject('post', p1);
91+
92+
DS.get('post', 5).author = 'Jake';
93+
94+
DS.save('post', 5, { method: 'PATCH' }).then(function (post) {
95+
assert.deepEqual(post, DS.get('post', 5), 'post 5 should have been saved');
96+
assert.equal(post.author, 'Jake');
97+
}, function (err) {
98+
console.error(err.stack);
99+
fail('should not have rejected');
100+
});
101+
102+
$httpBackend.flush();
103+
});
83104
it('should save an item to the server and inject the result via the instance method', function () {
84105
$httpBackend.expectPUT('http://test.angular-cache.com/posts/5').respond(200, {
85106
author: 'Jake',

0 commit comments

Comments
 (0)