Skip to content

Commit

Permalink
Merge pull request #14607 from daibhin/dn/params-refresh-break
Browse files Browse the repository at this point in the history
[ISSUEFIX] Break loop after one refresh in queryParamsDidChange
  • Loading branch information
rwjblue authored Dec 21, 2016
2 parents 3e8a347 + 54e4cae commit 746fb91
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/ember-routing/lib/system/route.js
Original file line number Diff line number Diff line change
Expand Up @@ -826,6 +826,7 @@ let Route = EmberObject.extend(ActionHandler, Evented, {
let qp = qpMap[totalChanged[i]];
if (qp && get(this._optionsForQueryParam(qp), 'refreshModel') && this.router.currentState) {
this.refresh();
break;
}
}

Expand Down
28 changes: 28 additions & 0 deletions packages/ember/tests/routing/query_params_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,34 @@ moduleFor('Query Params - main', class extends QueryParamTestCase {
});
}

['@test multiple QP value changes only cause a single model refresh'](assert) {
assert.expect(2);

this.setSingleQPController('index', 'alex', 'lol');
this.setSingleQPController('index', 'steely', 'lel');

let refreshCount = 0;
this.registerRoute('index', Route.extend({
queryParams: {
alex: {
refreshModel: true
},
steely: {
refreshModel: true
}
},
refresh() {
refreshCount++;
}
}));

return this.visitAndAssert('/').then(() => {
let indexController = this.getController('index');
run(indexController, 'setProperties', { alex: 'fran', steely: 'david' });
assert.equal(refreshCount, 1, 'index refresh hook only run once');
});
}

['@test refreshModel does not cause a second transition during app boot '](assert) {
assert.expect(1);

Expand Down

0 comments on commit 746fb91

Please sign in to comment.