Skip to content

Commit

Permalink
[BUGFIX release] Fix cacheValuePrefix Error
Browse files Browse the repository at this point in the history
Fixed an issue where cacheValuePrefix would incorrectly check "valA in valB" where valB would be null

Resolves Issue #11857
  • Loading branch information
jmurphyau committed Aug 10, 2015
1 parent 52b55ac commit bfd52f0
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 5 deletions.
12 changes: 7 additions & 5 deletions packages/ember-routing/lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,13 @@ export function calculateCacheKey(prefix, _parts, values) {
var part = parts[i];
var cacheValuePrefix = _calculateCacheValuePrefix(prefix, part);
var value;
if (cacheValuePrefix && cacheValuePrefix in values) {
var partRemovedPrefix = (part.indexOf(cacheValuePrefix) === 0) ? part.substr(cacheValuePrefix.length + 1) : part;
value = get(values[cacheValuePrefix], partRemovedPrefix);
} else {
value = get(values, part);
if (values) {
if (cacheValuePrefix && cacheValuePrefix in values) {
var partRemovedPrefix = (part.indexOf(cacheValuePrefix) === 0) ? part.substr(cacheValuePrefix.length + 1) : part;
value = get(values[cacheValuePrefix], partRemovedPrefix);
} else {
value = get(values, part);
}
}
suffixes += '::' + part + ':' + value;
}
Expand Down
48 changes: 48 additions & 0 deletions packages/ember/tests/routing/substates_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,54 @@ QUnit.test('Default error event moves into nested route', function() {
equal(appController.get('currentPath'), 'grandma.error', 'Initial route fully loaded');
});

QUnit.test('Setting a query param during a slow transition should work', function() {
var deferred = Ember.RSVP.defer();

Router.map(function() {
this.route('grandma', { path: '/grandma/:seg' }, function() { });
});

templates['grandma/loading'] = 'GMONEYLOADING';

App.ApplicationController = Ember.Controller.extend();

App.IndexRoute = Ember.Route.extend({
beforeModel: function() {
this.transitionTo('grandma', 1);
}
});

App.GrandmaRoute = Ember.Route.extend({
queryParams: {
test: { defaultValue: 1 }
}
});

App.GrandmaIndexRoute = Ember.Route.extend({
model() {
return deferred.promise;
}
});

bootApplication('/');

var appController = container.lookup('controller:application');
var grandmaController = container.lookup('controller:grandma');

equal(appController.get('currentPath'), 'grandma.loading', 'Initial route should be loading');

Ember.run(function() {
grandmaController.set('test', 3);
});

equal(appController.get('currentPath'), 'grandma.loading', 'Route should still be loading');
equal(grandmaController.get('test'), 3, 'Controller query param value should have changed');

Ember.run(deferred, 'resolve', {});

equal(appController.get('currentPath'), 'grandma.index', 'Transition should be complete');
});

if (isEnabled('ember-routing-named-substates')) {
QUnit.test('Slow promises returned from ApplicationRoute#model enter ApplicationLoadingRoute if present', function() {
expect(2);
Expand Down

0 comments on commit bfd52f0

Please sign in to comment.