Skip to content

Commit

Permalink
[BUGFIX] controller replaceRoute considers engine
Browse files Browse the repository at this point in the history
  • Loading branch information
spencer516 committed Apr 26, 2017
1 parent ebdc828 commit 3a98489
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/ember-routing/lib/ext/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ ControllerMixin.reopen({
// target may be either another controller or a router
let target = get(this, 'target');
let method = target.replaceRoute || target.replaceWith;
return method.apply(target, prefixRouteNameArg(target, args));
return method.apply(target, prefixRouteNameArg(this, args));
}
});

Expand Down
27 changes: 27 additions & 0 deletions packages/ember-routing/tests/ext/controller_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,30 @@ QUnit.test('transitionToRoute considers an engine\'s mountPoint', function() {
let queryParams = {};
strictEqual(controller.transitionToRoute(queryParams), queryParams, 'passes query param only transitions through');
});

QUnit.test('replaceRoute considers an engine\'s mountPoint', function() {
expect(4);

let router = {
replaceWith(route) {
return route;
}
};

let engineInstance = buildOwner({
ownerOptions: {
routable: true,
mountPoint: 'foo.bar'
}
});

let controller = Controller.create({ target: router });
setOwner(controller, engineInstance);

strictEqual(controller.replaceRoute('application'), 'foo.bar.application', 'properly prefixes application route');
strictEqual(controller.replaceRoute('posts'), 'foo.bar.posts', 'properly prefixes child routes');
throws(() => controller.replaceRoute('/posts'), 'throws when trying to use a url');

let queryParams = {};
strictEqual(controller.replaceRoute(queryParams), queryParams, 'passes query param only transitions through');
});

0 comments on commit 3a98489

Please sign in to comment.