Skip to content

Commit

Permalink
Merge pull request #13218 from raytiley/qp-initial-refresh
Browse files Browse the repository at this point in the history
[BUGFIX RELEASE] Do not refresh routes on initial transition
  • Loading branch information
rwjblue committed Mar 31, 2016
2 parents 44d930c + 92cd0a2 commit dd58346
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/ember-routing/lib/system/route.js
Original file line number Diff line number Diff line change
Expand Up @@ -759,7 +759,7 @@ var Route = EmberObject.extend(ActionHandler, Evented, {
var totalChanged = Object.keys(changed).concat(Object.keys(removed));
for (var i = 0, len = totalChanged.length; i < len; ++i) {
var qp = qpMap[totalChanged[i]];
if (qp && get(this._optionsForQueryParam(qp), 'refreshModel')) {
if (qp && get(this._optionsForQueryParam(qp), 'refreshModel') && this.router.currentState) {
this.refresh();
}
}
Expand Down
54 changes: 54 additions & 0 deletions packages/ember/tests/routing/query_params_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,33 @@ if (isEnabled('ember-routing-route-configured-query-params')) {
equal(indexModelCount, 2);
});

QUnit.test('refreshModel does not cause a second transition during app boot ', function() {
expect(0);

App.ApplicationRoute = Route.extend({
queryParams: {
appomg: {
defaultValue: 'applol'
}
}
});

App.IndexRoute = Route.extend({
queryParams: {
omg: {
defaultValue: 'lol',
refreshModel: true
}
},
refresh: function() {
ok(false);
}
});

startingURL = '/?appomg=hello&omg=world';
bootApplication();
});

QUnit.test('can use refreshModel even w URL changes that remove QPs from address bar when QP configured on route', function() {
expect(4);

Expand Down Expand Up @@ -2438,6 +2465,33 @@ if (isEnabled('ember-routing-route-configured-query-params')) {
equal(indexModelCount, 2);
});

QUnit.test('refreshModel does not cause a second transition during app boot ', function() {
expect(0);
App.ApplicationController = Controller.extend({
queryParams: ['appomg'],
appomg: 'applol'
});

App.IndexController = Controller.extend({
queryParams: ['omg'],
omg: 'lol'
});

App.IndexRoute = Route.extend({
queryParams: {
omg: {
refreshModel: true
}
},
refresh: function() {
ok(false);
}
});

startingURL = '/?appomg=hello&omg=world';
bootApplication();
});

QUnit.test('Use Ember.get to retrieve query params \'refreshModel\' configuration', function() {
expect(6);
App.ApplicationController = Controller.extend({
Expand Down

0 comments on commit dd58346

Please sign in to comment.