Skip to content

Commit

Permalink
Adding controllers to ensure they throw when calling urlFor and contr…
Browse files Browse the repository at this point in the history
…ollers are looked up
  • Loading branch information
scalvert committed Mar 5, 2017
1 parent eccf386 commit 156f5d0
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
4 changes: 2 additions & 2 deletions packages/ember-routing/lib/system/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -411,8 +411,8 @@ const EmberRouter = EmberObject.extend(Evented, {
return this.transitionTo(...arguments).method('replace');
},

generate(...args) {
let url = this._routerMicrolib.generate(...args);
generate() {
let url = this._routerMicrolib.generate(...arguments);
return this.location.formatURL(url);
},

Expand Down
19 changes: 18 additions & 1 deletion packages/ember/tests/routing/router_service_test/urlFor_test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import { inject } from 'ember-runtime';
import {
Controller,
inject,
String
} from 'ember-runtime';
import { Component } from 'ember-glimmer';
import { Route, NoneLocation } from 'ember-routing';
import {
Expand All @@ -12,10 +16,23 @@ import {

import { isFeatureEnabled } from 'ember-metal';

function defineController(app, name) {
let controllerName = `${String.capitalize(name)}Controller`;

Object.defineProperty(app, controllerName, {
get() {
throw new Error(`Generating a URL should not require instantiation of a ${controllerName}.`);
}
});
}

if (isFeatureEnabled('ember-routing-router-service')) {
moduleFor('Router Service - urlFor', class extends RouterTestCase {
constructor() {
super();

['dynamic', 'child']
.forEach((name) => { defineController(this.application, name); });
}

['@test RouterService#urlFor returns URL for simple route'](assert) {
Expand Down

0 comments on commit 156f5d0

Please sign in to comment.