From fdb3ca81672d4c9b5f01ea85c8bfb2d5926e88a6 Mon Sep 17 00:00:00 2001 From: Austin Burdine Date: Wed, 9 Sep 2015 08:19:45 -0500 Subject: [PATCH] fix bug with config service interpreting rare client secret strings as exponential numbers closes #5815 - replaces isNaN function call with isFinite in config service - adds config service unit test --- core/client/app/services/config.js | 2 +- .../client/tests/unit/services/config-test.js | 34 +++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 core/client/tests/unit/services/config-test.js diff --git a/core/client/app/services/config.js b/core/client/app/services/config.js index 0d554de5b3..9260b93d6a 100644 --- a/core/client/app/services/config.js +++ b/core/client/app/services/config.js @@ -1,7 +1,7 @@ import Ember from 'ember'; function isNumeric(num) { - return !isNaN(num); + return Ember.$.isNumeric(num); } function _mapType(val) { diff --git a/core/client/tests/unit/services/config-test.js b/core/client/tests/unit/services/config-test.js new file mode 100644 index 0000000000..51e13d90dc --- /dev/null +++ b/core/client/tests/unit/services/config-test.js @@ -0,0 +1,34 @@ +/* jshint expr:true */ +import { expect } from 'chai'; +import { + describeModule, + it +} from 'ember-mocha'; + +import Ember from 'ember'; + +describeModule( + 'service:config', + 'ConfigService', + { + // Specify the other units that are required for this test. + // needs: ['service:foo'] + }, + function () { + // Replace this with your real tests. + it('exists', function () { + var service = this.subject(); + expect(service).to.be.ok; + }); + + it('correctly parses a client secret', function () { + Ember.$('').attr('name', 'env-clientSecret') + .attr('content', '23e435234423') + .appendTo('head'); + + var service = this.subject(); + + expect(service.get('clientSecret')).to.equal('23e435234423'); + }); + } +);