spec/javascripts/backbone-nested-attributes/ModelSpec.js in backbone-nested-attributes-0.4.4 vs spec/javascripts/backbone-nested-attributes/ModelSpec.js in backbone-nested-attributes-0.5.0

- old
+ new

@@ -310,9 +310,25 @@ expect(model.get('comments').at(0)).toBe(comments.at(0)) expect(model.get('comments').at(1)).toBe(comments.at(1)) }) }) + describe('passing a model in a collection with { _destroy: true }', function () { + beforeEach(function() { + model = new Post({ title: 'Some Title', comments: [{ body: 'some content' }, { id: '123', body: 'other content', _destroy: true }] }) + }) + + it('do not add the model with { _destroy: true } to the relation collection', function () { + expect(model.get('comments').length).toBe(1) + expect(model.get('comments').at(0).get('body')).toBe('some content') + }) + + it('adds them to the deletedModels collection inside the relation collection', function () { + expect(model.get('comments').deletedModels.length).toBe(1) + expect(model.get('comments').deletedModels.at(0).get('body')).toBe('other content') + }) + }) + describe("passing a deleted_<collection> attribute", function() { var comments beforeEach(function() { model = new Post({ title: 'Some Title', deleted_comments: [{ id: 123, body: "some deleted comment", _destroy: true }] })