Skip to content

Instantly share code, notes, and snippets.

@kurko
Last active December 23, 2015 19:09
Show Gist options
  • Save kurko/6680239 to your computer and use it in GitHub Desktop.
Save kurko/6680239 to your computer and use it in GitHub Desktop.
Testing Ember models in a Rails app with QUnit
//= require admin/application
module("Model/Campaign");
test("simple test now", function() {
expect(1);
var store = Admin.__container__.lookup("store:main"),
campaign = store.createRecord('campaign', {id: 1}),
ad1 = store.createRecord('ad', {name: 'ad 1'}),
ad2 = store.createRecord('ad', {name: 'ad 2'}),
ad3 = store.createRecord('ad', {name: 'ad 3'});
stop();
Ember.RSVP.all([campaign, ad1, ad2, ad3]).then(function() {
// without this, next block doesn't work
return campaign.get('ads');
}).then(function() {
return campaign.get('ads').pushObject(adGroup2);
}).then(function() {
campaign.get('ads').forEach(function(template) {
equal(template.get('name'), 'group 2'); // green
});
});
start();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment