Skip to content

Commit

Permalink
Guard against trying to use a non-setup router.js instance.
Browse files Browse the repository at this point in the history
  • Loading branch information
Nathan Hammond committed Jul 3, 2015
1 parent b96d097 commit e60c73e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
1 change: 1 addition & 0 deletions packages/ember-routing/lib/services/routing.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ var RoutingService = Service.extend({

generateURL(routeName, models, queryParams) {
var router = get(this, 'router');
if (!router.router) { return; }

var visibleQueryParams = {};
merge(visibleQueryParams, queryParams);
Expand Down
17 changes: 16 additions & 1 deletion packages/ember/tests/helpers/link_to_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ QUnit.module("The {{link-to}} helper", {
teardown: sharedTeardown
});

// This test is designed to simulate the context of an ember-qunit/ember-test-helpers component integration test,
// These two tests are designed to simulate the context of an ember-qunit/ember-test-helpers component integration test,
// so the container is available but it does not boot the entire app
QUnit.test('Using {{link-to}} does not cause an exception if it is rendered before the router has started routing', function(assert) {
Router.map(function() {
Expand All @@ -118,6 +118,21 @@ QUnit.test('Using {{link-to}} does not cause an exception if it is rendered befo
assert.strictEqual(component.$('a').length, 1, 'the link is rendered');
});

QUnit.test('Using {{link-to}} does not cause an exception if it is rendered without a router.js instance', function(assert) {
registry.register('component-lookup:main', ComponentLookup);

let component = Ember.Component.extend({
layout: compile('{{#link-to "nonexistent"}}Does not work.{{/link-to}}'),
container: container
}).create();

Ember.run(function() {
component.appendTo('#qunit-fixture');
});

assert.strictEqual(component.$('a').length, 1, 'the link is rendered');
});

QUnit.test("The {{link-to}} helper moves into the named route", function() {
Router.map(function(match) {
this.route("about");
Expand Down

0 comments on commit e60c73e

Please sign in to comment.