I changed the semantics of the i18n fallback to not hit 'text' for other properties, so updated a test.

This commit is contained in:
Nick Winter 2014-03-13 18:50:52 -07:00
parent 795bd8f63b
commit 4f0805ce1e
2 changed files with 7 additions and 5 deletions

View file

@ -16,7 +16,7 @@ sendwithus = require '../sendwithus'
module.exports.setup = (app) ->
app.all config.mail.mailchimpWebhook, handleMailchimpWebHook
app.get '/mail/cron/ladder-update', handleLadderUpdate
getAllLadderScores = (next) ->
query = Level.find({type: 'ladder'})
.select('levelID')
@ -28,6 +28,8 @@ getAllLadderScores = (next) ->
for level in levels
for team in ['humans', 'ogres']
'I ... am not doing this.'
# Query to get sessions to make histogram
# db.level.sessions.find({"submitted":true,"levelID":"brawlwood",team:"ogres"},{"_id":0,"totalScore":1})
isRequestFromDesignatedCronHandler = (req, res) ->
if req.ip isnt config.mail.cronHandlerPublicIP and req.ip isnt config.mail.cronHandlerPrivateIP
@ -36,13 +38,13 @@ isRequestFromDesignatedCronHandler = (req, res) ->
res.end()
return false
return true
handleLadderUpdate = (req, res) ->
log.info("Going to see about sending ladder update emails.")
requestIsFromDesignatedCronHandler = isRequestFromDesignatedCronHandler req, res
unless requestIsFromDesignatedCronHandler then return
res.send('Great work, Captain Cron! I can take it from here.')
res.end()
# TODO: somehow fetch the histograms

View file

@ -40,7 +40,7 @@ describe 'utils library', ->
expect(util.i18n(this.fixture1, 'text', 'en')).toEqual(this.fixture1.text)
expect(util.i18n(this.fixture1, 'blurb', 'en')).toEqual(this.fixture1.blurb)
delete this.fixture1.blurb
expect(util.i18n(this.fixture1, 'blurb', 'en')).toEqual(this.fixture1.text)
expect(util.i18n(this.fixture1, 'blurb', 'en')).toEqual(null)
it 'i18n can fall forward if a general language is not found', ->
expect(util.i18n(this.fixture1, 'text', 'pt')).toEqual(this.fixture1.i18n['pt-BR'].text)