Skip to content

Commit

Permalink
Merge pull request #2337 from viki-org/explicit-index
Browse files Browse the repository at this point in the history
Avoid parent's implicit index route clobbering child's explicit index.
  • Loading branch information
tomdale committed Mar 28, 2013
2 parents 2cf2548 + 3c53bcb commit 887f789
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/ember-routing/lib/system/dsl.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ DSL.prototype = {
},

push: function(url, name, callback) {
if (url === "" || url === "/") { this.explicitIndex = true; }
var parts = name.split('.');
if (url === "" || url === "/" || parts[parts.length-1] === "index") { this.explicitIndex = true; }

this.matches.push([url, name, callback]);
},
Expand Down
22 changes: 22 additions & 0 deletions packages/ember/tests/routing/basic_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1572,3 +1572,25 @@ test("Generated route should be an instance of App.Route if provided", function(
ok(generatedRoute instanceof App.Route, 'should extend the correct route');

});

test("Nested index route is not overriden by parent's implicit index route", function() {
Router.map(function() {
this.resource('posts', function() {
this.route('index', { path: ':category' } );
});
});

App.Route = Ember.Route.extend({
serialize: function(model) {
return { category: model.category };
}
});

bootApplication();

Ember.run(function() {
router.transitionTo('posts', { category: 'emberjs' });
});

deepEqual(router.location.path, '/posts/emberjs');
});

0 comments on commit 887f789

Please sign in to comment.