rpflorence/ember-qunit — pull request #34 by mixonic (2014-04-10 22:50:04+00:00)
Title: Add adapter to module for model

See https://github.com/emberjs/data/pull/1859 for some context.

`moduleForModel` is kinda lame. It limits you to the fixture adapter, which many of the more experienced Ember devs would not recommend, but we still tell people it is awesome and they should check it out.

This makes it a bit better. With `DS._setupContainer` in Ember-Data, `moduleForModel` will be able to setup an isolated container to have all of Ember-Data. You can again use RESTAdapter and custom adapters without jumping through more hoops than you already do for model relations.

```JavaScript
var App = Ember.Application.create();
App.ApplicationAdapter = DS.RESTAdapter.extend();
App.WhapModel = DS.Model.extend({ nut: DS.attr('number') });

moduleForModel('whap', {
needs: ['adapter:application'],
setup: function(){ fakehr.start() },
teardown: function(){ fakehr.reset() }
});
test('saves to ajax', function(){
var whap = this.subject();
whap.set('nut', 5);
// with expect from https://github.com/trek/fakehr/pull/6
fakehr.expect('post', '/whaps').respond(
200, {'Content-Type': 'application/javascript'}, '{"id": "3e23", "nut": 5}');
return whap.save().then(function(){
ok(true, 'TRUUUEEEE!!!');
});
});
```

Welcome to your brave new fixture-adapter-less future. For pre-`DS._setupContainer` users, behavior is unchanged. Fixture adapter is still default if you do not inject an application adapter yourself.