Skip to content

Commit

Permalink
Merge pull request #89 from workmanw/isolated-container-normalize-needs
Browse files Browse the repository at this point in the history
`isolated-container` should  call `resolver.normalize(fullName)` when resolving needs values.
  • Loading branch information
rwjblue committed Sep 23, 2014
2 parents a773872 + 42c5986 commit f3f8527
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 7 deletions.
3 changes: 2 additions & 1 deletion dist/amd/isolated-container.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ define(
container.register('component-lookup:main', Ember.ComponentLookup);
for (var i = fullNames.length; i > 0; i--) {
var fullName = fullNames[i - 1];
container.register(fullName, resolver.resolve(fullName));
var normalizedFullName = resolver.normalize(fullName);
container.register(fullName, resolver.resolve(normalizedFullName));
}
return container;
}
Expand Down
3 changes: 2 additions & 1 deletion dist/cjs/isolated-container.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ exports["default"] = function isolatedContainer(fullNames) {
container.register('component-lookup:main', Ember.ComponentLookup);
for (var i = fullNames.length; i > 0; i--) {
var fullName = fullNames[i - 1];
container.register(fullName, resolver.resolve(fullName));
var normalizedFullName = resolver.normalize(fullName);
container.register(fullName, resolver.resolve(normalizedFullName));
}
return container;
}
3 changes: 2 additions & 1 deletion dist/globals/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ exports["default"] = function isolatedContainer(fullNames) {
container.register('component-lookup:main', Ember.ComponentLookup);
for (var i = fullNames.length; i > 0; i--) {
var fullName = fullNames[i - 1];
container.register(fullName, resolver.resolve(fullName));
var normalizedFullName = resolver.normalize(fullName);
container.register(fullName, resolver.resolve(normalizedFullName));
}
return container;
}
Expand Down
3 changes: 2 additions & 1 deletion dist/named-amd/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ define("ember-qunit/isolated-container",
container.register('component-lookup:main', Ember.ComponentLookup);
for (var i = fullNames.length; i > 0; i--) {
var fullName = fullNames[i - 1];
container.register(fullName, resolver.resolve(fullName));
var normalizedFullName = resolver.normalize(fullName);
container.register(fullName, resolver.resolve(normalizedFullName));
}
return container;
}
Expand Down
3 changes: 2 additions & 1 deletion lib/isolated-container.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ export default function isolatedContainer(fullNames) {
container.register('component-lookup:main', Ember.ComponentLookup);
for (var i = fullNames.length; i > 0; i--) {
var fullName = fullNames[i - 1];
container.register(fullName, resolver.resolve(fullName));
var normalizedFullName = resolver.normalize(fullName);
container.register(fullName, resolver.resolve(normalizedFullName));
}
return container;
}
12 changes: 10 additions & 2 deletions test/main.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,9 @@ var registry = {
'template:components/pretty-color': 'Pretty Color: <span class="color-name">{{name}}</span>'.compile(),
'route:foo': Ember.Route.extend(),
'controller:foos': Ember.ArrayController.extend(),
'controller:hello-world': Ember.ObjectController.extend(),
'controller:bar': Ember.Controller.extend({
needs: ['foos']
needs: ['foos', 'helloWorld']
}),
'model:post': Post,
'model:comment': Comment,
Expand All @@ -48,6 +49,9 @@ var registry = {
var Resolver = Ember.DefaultResolver.extend({
resolve: function(fullName) {
return registry[fullName] || this._super.apply(this, arguments);
},
normalize: function(fullName) {
return Ember.String.dasherize(fullName);
}
});

Expand Down Expand Up @@ -84,27 +88,31 @@ test("root element is auto-added before moduleFor callback", function() {
//});

moduleFor('controller:bar', 'moduleFor with bar controller', {
needs: ['controller:foos']
needs: ['controller:foos', 'controller:helloWorld']
});

test('exists', function() {
var bar = this.subject();

var foos = bar.get('controllers.foos');
var helloWorld = bar.get('controllers.helloWorld');

ok(bar);
ok(bar instanceof Ember.Controller);
ok(foos instanceof Ember.ArrayController);
ok(helloWorld instanceof Ember.ObjectController);
});

test('exists again', function() {
var bar = this.subject();

var foos = bar.get('controllers.foos');
var helloWorld = bar.get('controllers.helloWorld');

ok(bar);
ok(bar instanceof Ember.Controller);
ok(foos instanceof Ember.ArrayController);
ok(helloWorld instanceof Ember.ObjectController);
});

moduleForModel('whazzit', 'moduleForModel whazzit without adapter');
Expand Down

0 comments on commit f3f8527

Please sign in to comment.