Skip to content

Commit

Permalink
[BUGFIX beta] Ensure factoryFor does validation.
Browse files Browse the repository at this point in the history
  • Loading branch information
rwjblue committed Apr 30, 2017
1 parent 3e16dce commit 077eace
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
4 changes: 4 additions & 0 deletions packages/container/lib/container.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,10 @@ Container.prototype = {
return;
}

if (DEBUG && factory && typeof factory._onLookup === 'function') {
factory._onLookup(fullName);
}

let manager = new FactoryManager(this, factory, fullName, normalizedName);

if (DEBUG) {
Expand Down
6 changes: 2 additions & 4 deletions packages/ember-runtime/tests/controllers/controller_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,12 +159,10 @@ if (!EmberDev.runningProdBuild) {
foo: inject.controller('bar')
});

owner.register('controller:bar', EmberObject.extend());
owner.register('foo:main', AnObject);

expectDeprecation(() => {
owner._lookupFactory('foo:main');
}, /Using "_lookupFactory" is deprecated. Please use container.factoryFor instead./);

owner.lookup('foo:main');
}, /Defining an injected controller property on a non-controller is not allowed./);
});
}
Expand Down
8 changes: 4 additions & 4 deletions packages/ember-runtime/tests/inject_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ if (!EmberDev.runningProdBuild) {
});

owner.register('foo:main', AnObject);
owner.register('foo:bar', EmberObject.extend());
owner.register('foo:baz', EmberObject.extend());

expect(2);
expectDeprecation(() => {
owner._lookupFactory('foo:main');
}, /Using "_lookupFactory" is deprecated. Please use container.factoryFor instead./);
expect(1);
owner.lookup('foo:main');
});

QUnit.test('attempting to inject a nonexistent container key should error', function() {
Expand Down

0 comments on commit 077eace

Please sign in to comment.