Skip to content

Commit d98c091

Browse files
committed
test: add case for multiple saves
1 parent 2d7fdfc commit d98c091

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

tests/integration/adapters/pouch-basics-test.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,27 @@ test('create a new record', function (assert) {
263263
}).finally(done);
264264
});
265265

266+
test('update a newly created record before it has finished saving', function (assert) {
267+
assert.expect(2);
268+
269+
const done = assert.async();
270+
Promise.resolve().then(() => {
271+
var newSoup = this.store().createRecord('taco-soup', { id: 'E', flavor: 'oops-wrong-flavor' });
272+
newSoup.save();
273+
newSoup.set('flavor', 'balsamic');
274+
return newSoup.save();
275+
}).then(() => {
276+
return this.db().get('tacoSoup_2_E');
277+
}).then((newDoc) => {
278+
assert.equal(newDoc.data.flavor, 'balsamic', 'should have saved the attribute');
279+
280+
var recordInStore = this.store().peekRecord('tacoSoup', 'E');
281+
assert.equal(newDoc._rev, recordInStore.get('rev'),
282+
'should have associated the ember-data record with the rev for the new record');
283+
284+
}).finally(done);
285+
});
286+
266287
test('creating an associated record stores a reference to it in the parent', function (assert) {
267288
assert.expect(1);
268289

0 commit comments

Comments
 (0)