Skip to content

Commit

Permalink
[BUGFIX beta] Fix link-to throwing in integration tests
Browse files Browse the repository at this point in the history
Fixes #15831

Fixes a regression introduced by #15788 by returning early again from `routing.generateURL()` when `router._routerMicrolib` is not present.
  • Loading branch information
simonihmig committed Nov 30, 2017
1 parent 76c4383 commit 3f46b8b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { moduleFor, ApplicationTest } from '../../utils/test-case';
import { moduleFor, ApplicationTest, RenderingTest } from '../../utils/test-case';
import { Controller } from 'ember-runtime';
import { set } from 'ember-metal';
import { LinkComponent } from '../../utils/helpers';
Expand Down Expand Up @@ -176,3 +176,17 @@ moduleFor('Link-to component with query-params', class extends ApplicationTest {
});
}
});

moduleFor('Link-to component', class extends RenderingTest {
['@test should be able to be inserted in DOM when the router is not present - block']() {
this.render('{{#link-to \'index\'}}Go to Index{{/link-to}}');

this.assertText('Go to Index');
}

['@test should be able to be inserted in DOM when the router is not present - inline']() {
this.render(`{{link-to 'Go to Index' 'index'}}`);

this.assertText('Go to Index');
}
});
6 changes: 5 additions & 1 deletion packages/ember-routing/lib/services/routing.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,17 @@ export default Service.extend({
},

generateURL(routeName, models, queryParams) {
let router = get(this, 'router');
// return early when the router microlib is not present, which is the case for {{link-to}} in integration tests
if (!router._routerMicrolib) { return; }

let visibleQueryParams = {};
if (queryParams) {
assign(visibleQueryParams, queryParams);
this.normalizeQueryParams(routeName, models, visibleQueryParams);
}

return get(this, 'router').generate(routeName, ...models, { queryParams: visibleQueryParams });
return router.generate(routeName, ...models, { queryParams: visibleQueryParams });
},

isActiveForRoute(contexts, queryParams, routeName, routerState, isCurrentWhenSpecified) {
Expand Down

0 comments on commit 3f46b8b

Please sign in to comment.