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 RELEASE] Do not refresh routes on initial transition #13218

Merged
merged 1 commit into from
Mar 31, 2016
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
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