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

container used in unit tests doesn't normalize model names #119

Closed
kbullaughey opened this issue Jan 25, 2015 · 3 comments
Closed

container used in unit tests doesn't normalize model names #119

kbullaughey opened this issue Jan 25, 2015 · 3 comments

Comments

@kbullaughey
Copy link

I ran into a problem writing unit tests that I detailed in a StackOverflow question:

http://stackoverflow.com/questions/28130262/how-do-i-use-a-multi-word-model-name-when-using-ember-cli

I found a workaround that might suggest at the root cause. In my moduleForModel callbacks, I override the container's normalizeFullName method to dasherize strings:

setup: function(container) {
  container.normalizeFullName = function(fullName) { return fullName.dasherize(); }
}

The function I overrode is the default Ember implementation, which just returns fullName. This isn't necessary in in my actual app because the implementation looks like this:

function (fullName) {
  if (resolver.normalize) {
    return resolver.normalize(fullName);
  } else {
    Ember.deprecate('The Resolver should now provide a \'normalize\' function', false);
    return fullName;
  }
}

In my case I'm using the ActiveModelAdapter, which expects incoming json roots to be underscored. This is then converted to a camelCase name that is passed around in Ember Data, and then re-normalized to a dasherized name during resolution on the container. But in unit tests, it's never converted to the dasherized name and a lookup using the camelCase name fails.

@rwjblue
Copy link
Member

rwjblue commented Jan 31, 2015

This should be resolved in 0.2.0.

@rwjblue rwjblue closed this as completed Jan 31, 2015
@kbullaughey
Copy link
Author

Great. Thanks. I upgraded and I can confirm that I no longer have the problem.

@rwjblue
Copy link
Member

rwjblue commented Feb 2, 2015

Awesome, glad to hear it!

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

No branches or pull requests

2 participants