Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUGFIX beta] Fix link-to throwing in integration tests #15902

Merged
merged 1 commit into from
Dec 1, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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