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] exempt routes that share a controller from duplicate assertion #14791

Merged
merged 1 commit into from Jan 11, 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
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) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick: Need a newline before and after the test block

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