fix(locale): Fix merge conflicts (#1794)

This commit is contained in:
Vijay Budhram 2017-04-05 13:44:48 -07:00 коммит произвёл Vlad Filippov
Родитель 1158477084
Коммит 5406b56053
5 изменённых файлов: 3 добавлений и 19 удалений

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

@ -152,7 +152,7 @@ module.exports = log => {
return request.gatherMetricsContext({
event: event,
locale: marshallLocale(request),
locale: request.app && request.app.locale,
userAgent: request.headers['user-agent']
}).then(data => {
if (data.flow_id) {
@ -187,12 +187,6 @@ function optionallySetService (data, request) {
(request.query && request.query.service)
}
function marshallLocale (request) {
if (request.app && request.app.locale) {
return `${request.app.locale}${request.app.isLocaleAcceptable ? '' : '.default'}`
}
}
function coalesceUid (data, request) {
if (data && data.uid) {
return Buffer.isBuffer(data.uid) ? data.uid.toString('hex') : data.uid

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

@ -287,9 +287,7 @@ function create(log, error, config, routes, db, translator) {
const acceptLanguage = trimLocale(request.headers['accept-language'])
request.app.acceptLanguage = acceptLanguage
const locale = translator.getLocale(acceptLanguage)
request.app.locale = locale
request.app.isLocaleAcceptable = isLocaleAcceptable(locale, acceptLanguage)
request.app.locale = translator.getLocale(acceptLanguage)
if (request.headers.authorization) {
// Log some helpful details for debugging authentication problems.
@ -346,10 +344,6 @@ function create(log, error, config, routes, db, translator) {
return server
}
function isLocaleAcceptable (locale, acceptLanguage) {
return RegExp(`^(?:.+, *)*${locale}(?:[,-].+)*$`, 'i').test(acceptLanguage)
}
module.exports = {
create: create,
// Functions below exported for testing

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

@ -190,7 +190,6 @@ describe('metrics/events', () => {
const metricsContext = mocks.mockMetricsContext()
const request = {
app: {
isLocaleAcceptable: false,
locale: 'en'
},
auth: null,
@ -219,7 +218,7 @@ describe('metrics/events', () => {
flow_id: 'bar',
flow_time: 1000,
flowCompleteSignal: 'account.signed',
locale: 'en.default',
locale: 'en',
time,
userAgent: 'foo'
}, 'argument was event data')

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

@ -114,7 +114,6 @@ describe('lib/server', () => {
assert.ok(args[1])
assert.equal(args[1].path, '/account/create')
assert.equal(args[1].app.locale, 'en')
assert.equal(args[1].app.isLocaleAcceptable, true)
})
it('called log.summary correctly', () => {
@ -152,7 +151,6 @@ describe('lib/server', () => {
assert.equal(log.begin.callCount, 1)
const args = log.begin.args[0]
assert.equal(args[1].app.locale, 'en')
assert.equal(args[1].app.isLocaleAcceptable, false)
})
it('called log.summary once', () => {

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

@ -358,7 +358,6 @@ function mockRequest (data) {
app: {
acceptLanguage: 'en-US',
clientAddress: data.clientAddress || '63.245.221.32',
isLocaleAcceptable: true,
locale: data.locale || 'en-US'
},
auth: {