Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failing test for https://github.com/ebryn/ember-model/issues/245 #363

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ test("new records should remain after parent is saved", function() {
resolve(json);
});
};

var article = Article.create({
title: 'bar'
});
Expand Down Expand Up @@ -77,7 +77,7 @@ test("saving child objects", function() {
});
Article.adapter = Ember.RESTAdapter.create();
Article.url = '/articles';

var article = Article.create();
var comment = Comment.create();

Expand All @@ -92,3 +92,50 @@ test("saving child objects", function() {
});
stop();
});

test("parent should not be dirty after new child created", function() {
expect(3);

var articleJSON = {
id: 76,
title: '?',
comment_ids: []
};

var commentJSON = {
id:111,
title:':}}'
};

var Comment = Ember.Model.extend({
id: attr(),
text: attr()
});
Comment.adapter = Ember.RESTAdapter.create();
Comment.url = '/comments';
Comment.adapter._ajax = function() {
return new Ember.RSVP.Promise(function(resolve) {
resolve(commentJSON);
});
};

var Article = Ember.Model.extend({
id: attr(),
title: attr(),
comments: Ember.hasMany(Comment, { key: 'comment_ids' })
});
Article.adapter = Ember.RESTAdapter.create();
Article.url = '/articles';

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

Comment.create().save().then(function(record){
start();
equal(article.get('isDirty'), false);
equal(record.get('isDirty'), false);
article.get('comments').addObject(record);
equal(article.get('isDirty'), false);
});
stop();
});