Skip to content

Commit

Permalink
Merge pull request #14791 from efx/fix-14560
Browse files Browse the repository at this point in the history
[BUGFIX beta] exempt routes that share a controller from duplicate assertion
  • Loading branch information
rwjblue authored Jan 11, 2017
2 parents 5df51f8 + f751930 commit 3a6bdc7
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/ember-routing/lib/system/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -858,8 +858,9 @@ const EmberRouter = EmberObject.extend(Evented, {
for (let i = 0; i < qpMeta.qps.length; i++) {
let qp = qpMeta.qps[i];
let urlKey = qp.urlKey;
let qpOther = qpsByUrlKey[urlKey];

if (qpsByUrlKey[urlKey]) {
if (qpOther && qpOther.controllerName !== qp.controllerName) {
let otherQP = qpsByUrlKey[urlKey];
assert(`You're not allowed to have more than one controller property map to the same query param key, but both \`${otherQP.scopedPropertyName}\` and \`${qp.scopedPropertyName}\` map to \`${urlKey}\`. You can fix this by mapping one of the controller properties to a different query param key via the \`as\` config option, e.g. \`${otherQP.prop}: { as: \'other-${otherQP.prop}\' }\``, false);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Controller } from 'ember-runtime';
import { Route } from 'ember-routing';
import { run, Mixin } from 'ember-metal';
import { QueryParamTestCase, moduleFor } from 'internal-test-helpers';

Expand Down Expand Up @@ -106,6 +107,20 @@ moduleFor('Query Params - overlapping query param property names', class extends
});
}

['@test query params does not error when a query parameter exists for route instances that share a controller'](assert) {
assert.expect(1);

let parentController = Controller.extend({
queryParams: { page: 'page' }
});
this.registerController('parent', parentController);
this.registerRoute('parent.child', Route.extend({controllerName: 'parent'}));

return this.setupBase('/parent').then(() => {
this.transitionTo('parent.child', { queryParams: { page: 2 } });
this.assertCurrentPath('/parent/child?page=2');
});
}
['@test query params in the same route hierarchy with the same url key get auto-scoped'](assert) {
assert.expect(1);

Expand Down

0 comments on commit 3a6bdc7

Please sign in to comment.