Skip to content
This repository has been archived by the owner on Dec 10, 2024. It is now read-only.

In model unit tests this.subject().store and this.store() are different #42

Closed
YoranBrondsema opened this issue Feb 7, 2015 · 2 comments
Labels

Comments

@YoranBrondsema
Copy link

I first posted this issue on the ember.js repository (emberjs/ember.js#10367 (comment)) but was told that it's almost certainly a bug in ember-cli-qunit.

See this discussion on StackOverflow: http://stackoverflow.com/a/25945287/1269194. In a model unit test, the Store objects returned by this.subject().store and this.store() are not the same, resulting in an error when trying to assign a model to a relationship.

For instance, say you have Parent and Child as follows:

Parent = DS.Model.extend({
    child: belongsTo('child')
});

Child = DS.Model.extend();

and in a unit test for Parent you do

this.subject().set('child', this.store().createRecord('child'));

then you get an error Error: Assertion Failed: You can only add a 'child' record to this relationship.

I encountered this bug when upgrading our non-ember-cli project to ember-cli 0.1.11.

@stefanpenner
Copy link
Contributor

sounds like a bug

@YoranBrondsema
Copy link
Author

Ok, it now seems that after upgrading from ember-data b12 to b14.1, the issue is resolved...

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants