var attr = Ember.attr;

module("Ember.EmbeddedHasManyArray - embedded objects saving");

test("derp", function() {
  var json = {
    id: 1,
    title: 'foo',
    comments: [
      {id: 1, text: 'uno'},
      {id: 2, text: 'dos'},
      {id: 3, text: 'tres'}
    ]
  };

  var Comment = Ember.Model.extend({
    id: attr(),
    text: attr()
  });

  var Article = Ember.Model.extend({
    title: attr(),

    comments: Ember.hasMany(Comment, { key: 'comments', embedded: true })
  });

  Comment.adapter = {

    createRecord: function(record) {
      return new Ember.RSVP.Promise(function(resolve, reject) {
        Ember.run.later(function() {
          record.load(4, {text: 'quattro'});
          record.didCreateRecord();
          resolve(record);
        }, 1);
      });
    },

    saveRecord: function(record) {
      return new Ember.RSVP.Promise(function(resolve, reject) {
        Ember.run.later(function() {
          record.didSaveRecord();
          resolve(record);
        }, 1);
      });
    }
  };

  var article = Article.create();
  Ember.run(article, article.load, json.id, json);

  var comments = article.get('comments');
  var newComment = Ember.run(comments, comments.create, {text: 'quattro'});

  equal(comments.get('length'), 4);
  ok(newComment instanceof Comment);
  deepEqual(Ember.run(comments, comments.mapProperty, 'text'), ['uno', 'dos', 'tres', 'quattro']);

  Ember.run(function() {
    stop();
    comments.save().then(function(record) {
      start();
      debugger;
      ok(!newComment.get('isDirty'), "New comment is not dirty");
      equal(newComment.get('id'), 4, "New comment has an ID");
    });
  });
});

@@ -1493,24 +1493,8 @@
 ();%0A
-      debugger;%0A
     

Remove debugger statement