Merge pull request #1699 from mozilla/pb/fix-sentry-6027903

https://github.com/mozilla/fxa/pull/1699
r=vbudhram
This commit is contained in:
Phil Booth 2019-07-08 19:49:37 +00:00 коммит произвёл GitHub
Родитель 4969918478 4719789cab
Коммит 368e30b7dc
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
2 изменённых файлов: 34 добавлений и 1 удалений

Просмотреть файл

@ -49,6 +49,7 @@ module.exports = (log, config) => {
language,
location,
});
client.location = {};
}
}
return client;

Просмотреть файл

@ -18,7 +18,7 @@ const makeClientUtils = (options) => {
earliestSaneTimestamp: EARLIEST_SANE_TIMESTAMP
};
config.i18n = config.i18n || {
supportedLanguages: ['en', 'fr'],
supportedLanguages: ['en', 'fr', 'wibble'],
defaultLanguage: 'en'
};
return require('../../../../lib/routes/utils/clients')(log, config);
@ -108,6 +108,38 @@ describe('clientUtils.formatLocation', () => {
});
assert.equal(log.warn.callCount, 0);
});
it('unsets location if it fails', () => {
request.app.acceptLanguage = 'wibble';
const client = {
location: {
city: 'Bournemouth',
state: 'England',
stateCode: 'EN',
country: 'United Kingdom',
countryCode: 'GB',
},
};
clientUtils.formatLocation(client, request);
assert.deepEqual(client.location, {});
assert.equal(log.warn.callCount, 1);
const args = log.warn.args[0];
assert.lengthOf(args, 2);
assert.equal(args[0], 'attached-clients.formatLocation.warning');
assert.deepEqual(args[1], {
err: "Cannot find module 'cldr-localenames-full/main/wibble/territories.json'",
language: 'wibble',
languages: 'wibble',
location: {
city: 'Bournemouth',
state: 'England',
stateCode: 'EN',
country: 'United Kingdom',
countryCode: 'GB',
}
});
});
});