Created
February 11, 2016 15:18
-
-
Save olivierchatry/d61f083b65b0e1b3fe02 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| test("A hasMany updated link should not remove new children when the parent record has children already with feedback from the server after save", function(assert) { | |
| Post.reopen({ | |
| comments: DS.hasMany('comment', { async: true }) | |
| }); | |
| Comment.reopen({ | |
| message: DS.belongsTo('post', { async: true }) | |
| }); | |
| env.adapter.createRecord = function(store, snapshot, link, relationship) { | |
| return Ember.RSVP.resolve({ | |
| id: 5 | |
| }); | |
| }; | |
| env.adapter.findHasMany = function(store, snapshot, link, relationship) { | |
| return Ember.RSVP.resolve([{ id: 5 }]); | |
| }; | |
| run(function() { | |
| var post = env.store.createRecord('post', {}); | |
| env.store.createRecord('comment', { id: 5, message: post }); | |
| post.get('comments') | |
| .then(function(comments) { | |
| assert.equal(comments.get('length'), 1); | |
| return post.save(); | |
| }) | |
| .then(function() { | |
| return env.store.push({ | |
| data: { | |
| type: "post", | |
| id: 5, | |
| relationships: { | |
| comments: { | |
| data: [ | |
| { | |
| id: 5, | |
| type: "comment" | |
| } | |
| ] | |
| } | |
| } | |
| } | |
| }); | |
| }) | |
| .then(function() { | |
| return post.get('comments'); | |
| }) | |
| .then(function(comments) { | |
| assert.equal(comments.get('length'), 1); | |
| }); | |
| }); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment