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] {{link-to}} before application boot #11522

Merged
merged 1 commit into from
Jun 21, 2015
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
2 changes: 2 additions & 0 deletions packages/ember-routing-views/lib/views/link.js
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,8 @@ var LinkComponent = EmberComponent.extend({
*/
active: computed('attrs.params', '_routing.currentState', function computeLinkComponentActive() {
var currentState = get(this, '_routing.currentState');
if (!currentState) { return false; }

return computeActive(this, currentState);
}),

Expand Down
25 changes: 25 additions & 0 deletions packages/ember/tests/helpers/link_to_test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'ember';
import Ember from 'ember-metal/core';
import ComponentLookup from 'ember-views/component_lookup';
import isEnabled from 'ember-metal/features';

import { objectControllerDeprecation } from 'ember-runtime/controllers/object_controller';
Expand Down Expand Up @@ -95,6 +96,30 @@ 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,
// 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() {
this.route('about');
});

registry.register('component-lookup:main', ComponentLookup);

let component = Ember.Component.extend({
layout: compile('{{#link-to "about"}}Go to About{{/link-to}}'),
container: container
}).create();

let router = container.lookup('router:main');
router.setupRouter();

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