Skip to content

Commit

Permalink
if a default query paramater is null, that paramater shouldbe able to…
Browse files Browse the repository at this point in the history
… be set to a string of "null"
  • Loading branch information
webark committed Jul 23, 2016
1 parent bba09bd commit c7bc19c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
2 changes: 2 additions & 0 deletions packages/ember-routing/lib/system/route.js
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,8 @@ let Route = EmberObject.extend(ActionHandler, Evented, {
// to a certain query param.
if (defaultValueType === 'array') {
return JSON.stringify(value);
} else if (defaultValueType === 'null' && value === null) {
return null;
}
return `${value}`;
},
Expand Down
14 changes: 14 additions & 0 deletions packages/ember/tests/routing/query_params_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2337,6 +2337,20 @@ if (isEnabled('ember-routing-route-configured-query-params')) {
bootApplication();
});

QUnit.test('query paramater with a default value of null should be able to get set to a string of null', function() {
expect(1);

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

startingURL = '/';
bootApplication();
run(router, 'transitionTo', { queryParams: { foo: 'null' } });
equal(router.get('location.path'), '/?foo=null', 'foo can be set to a string of null');
});

QUnit.test('model hook can query prefix-less application params (overridden by incoming url value)', function() {
App.ApplicationController = Controller.extend({
queryParams: ['appomg'],
Expand Down

0 comments on commit c7bc19c

Please sign in to comment.