Skip to content

Commit

Permalink
Merge pull request #11957 from rwjblue/rebase-10513
Browse files Browse the repository at this point in the history
[BUGFIX beta] Ember.DefaultResolver resolves with hyphens.
  • Loading branch information
rwjblue committed Aug 2, 2015
2 parents b9b7c5b + 1744ed3 commit 221beec
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
6 changes: 6 additions & 0 deletions packages/ember-application/lib/system/resolver.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,12 @@ export default EmberObject.extend({
});
}

if (name.indexOf('-') > -1) {
result = result.replace(/-(.)/g, function(m) {
return m.charAt(1).toUpperCase();
});
}

return type + ':' + result;
} else {
return fullName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,12 @@ QUnit.test('the default resolver resolves helpers on the namespace', function()
equal(resolvedLegacyHandlebars, LegacyHandlebarsBoundHelper, 'resolves legacy Handlebars bound helper');
});

QUnit.test('the default resolver resolves to the same instance no matter the notation ', function() {
application.NestedPostController = Controller.extend({});

equal(locator.lookup('controller:nested-post'), locator.lookup('controller:nested_post'), 'looks up NestedPost controller on application');
});

QUnit.test('the default resolver throws an error if the fullName to resolve is invalid', function() {
throws(function() { registry.resolve(undefined);}, TypeError, /Invalid fullName/ );
throws(function() { registry.resolve(null); }, TypeError, /Invalid fullName/ );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,18 @@ QUnit.test('normalization', function() {
equal(registry.normalize('controller:posts'), 'controller:posts');
equal(registry.normalize('controller:posts_index'), 'controller:postsIndex');
equal(registry.normalize('controller:posts.index'), 'controller:postsIndex');
equal(registry.normalize('controller:posts-index'), 'controller:postsIndex');
equal(registry.normalize('controller:posts.post.index'), 'controller:postsPostIndex');
equal(registry.normalize('controller:posts_post.index'), 'controller:postsPostIndex');
equal(registry.normalize('controller:posts.post_index'), 'controller:postsPostIndex');
equal(registry.normalize('controller:posts.post-index'), 'controller:postsPostIndex');
equal(registry.normalize('controller:postsIndex'), 'controller:postsIndex');
equal(registry.normalize('controller:blogPosts.index'), 'controller:blogPostsIndex');
equal(registry.normalize('controller:blog/posts.index'), 'controller:blog/postsIndex');
equal(registry.normalize('controller:blog/posts-index'), 'controller:blog/postsIndex');
equal(registry.normalize('controller:blog/posts.post.index'), 'controller:blog/postsPostIndex');
equal(registry.normalize('controller:blog/posts_post.index'), 'controller:blog/postsPostIndex');
equal(registry.normalize('controller:blog/posts_post-index'), 'controller:blog/postsPostIndex');

equal(registry.normalize('template:blog/posts_index'), 'template:blog/posts_index');
});
Expand Down

0 comments on commit 221beec

Please sign in to comment.