Search code examples
ember.jsember-dataember-cli

How do I get ember-qunit to use my ApplicationAdapter instead of DS.FixtureAdapter


I'm trying to use http-mock as suggested by the ember-cli documentation instead of fixtures. I generated a mock and can verify (using curl) that my ember app serves it.

However, in testing, the adapter is set to DS.FixtureAdapter and I think this is the source of the problem. If I could do something like the following:

container.register('adapter:application', ApplicationAdapter)

I think it moduleForModel() would find my adapter, where I would import ApplicationAdapter from the adapter I want to use:

import ApplicationAdapter from 'myapp/adapters/application'

But I don't know where I can put this code. I tried hooking into the delegate callback, but it wasn't getting called by moduleForModel().

Ideas about how this is supposed to be done?


Solution

  • I was having the exact same problem, and thanks to the comments here I figured it out. :) Add the adapter to the needs property in the test:

    moduleForModel('post', 'Post', {
      needs: ['adapter:application', ... ]
    });