diff --git a/lib/ember-test-helpers/build-registry.js b/lib/ember-test-helpers/build-registry.js index 30fa7f12f..c2591510e 100644 --- a/lib/ember-test-helpers/build-registry.js +++ b/lib/ember-test-helpers/build-registry.js @@ -47,6 +47,15 @@ export default function(resolver) { registry = new Ember.Registry({ fallback: fallbackRegistry }); + + // these properties are set on the fallback registry by `buildRegistry` + // and on the primary registry within the ApplicationInstance constructor + // but we need to manually recreate them since ApplicationInstance's are not + // exposed externally + registry.normalizeFullName = fallbackRegistry.normalizeFullName; + registry.makeToString = fallbackRegistry.makeToString; + registry.describe = fallbackRegistry.describe; + container = registry.container(); exposeRegistryMethodsWithoutDeprecations(container); } else { diff --git a/tests/test-module-test.js b/tests/test-module-test.js index 64f7247a3..09c264405 100644 --- a/tests/test-module-test.js +++ b/tests/test-module-test.js @@ -15,7 +15,11 @@ function setupRegistry() { 'component:not-the-subject': Ember.Component.extend(), 'foo:thing': Ember.Object.extend({ fromDefaultRegistry: true + }), + 'service:other-thing': Ember.Object.extend({ + fromDefaultRegistry: true }) + }); } @@ -203,4 +207,31 @@ if (hasEmberVersion(1,11)) { ok(!thing.fromDefaultRegistry, 'should not be found from the default registry'); ok(thing.notTheDefault, 'found from the overridden factory'); }); + + test('gets the default with fullName normalization by default', function() { + this.register('foo:needs-service', Ember.Object.extend({ + otherThing: Ember.inject.service() + })); + + var foo = this.container.lookup('foo:needs-service'); + var thing = foo.get('otherThing'); + + ok(thing.fromDefaultRegistry, 'found from the default registry'); + }); + + test('can override the default with fullName normalization', function() { + this.register('service:other-thing', Ember.Object.extend({ + notTheDefault: true + })); + + this.register('foo:needs-service', Ember.Object.extend({ + otherThing: Ember.inject.service() + })); + + var foo = this.container.lookup('foo:needs-service'); + var thing = foo.get('otherThing'); + + ok(!thing.fromDefaultRegistry, 'should not be found from the default registry'); + ok(thing.notTheDefault, 'found from the overridden factory'); + }); }