Merge branch 'master' into production

This commit is contained in:
Scott Erickson 2016-04-07 15:00:43 -07:00
commit df571c6d11
6 changed files with 28 additions and 4 deletions

View file

@ -34,7 +34,7 @@ block content
.col-md-4.col-sm-6
#email-form-group.form-group
label.control-label(data-i18n="general.email")
input.form-control(disabled=true value=me.get('email'))
input.form-control(name='email' disabled=true value=me.get('email'))
.row.m-y-2
.col-md-offset-2.col-md-4.col-sm-6

View file

@ -40,7 +40,8 @@
"nodemon": "nodemon",
"jasmine-node": "jasmine-node",
"multicore": "coffee multicore.coffee",
"jasmine": "jasmine"
"jasmine": "jasmine",
"proxy": "COCO_PROXY='true' nodemon"
},
"main": "index.js",
"keywords": [
@ -99,6 +100,7 @@
"compressible": "~1.0.1",
"css-brunch": "^1.7.0",
"fs-extra": "^0.26.2",
"http-proxy": "^1.13.2",
"jade-brunch": "1.7.5",
"jasmine": "^2.4.1",
"javascript-brunch": "> 1.0 < 1.8",

View file

@ -140,7 +140,7 @@ class MongoQueueClient
_createMongoConnection: ->
@mongooseConnection = mongoose.createConnection @databaseAddress
@mongooseConnection.on 'error', -> log.error 'There was an error connecting to the queue in MongoDB'
@mongooseConnection.on 'error', -> log.error 'There was an error connecting to the queue in MongoDB' unless config.proxy
@mongooseConnection.once 'open', -> log.info 'Successfully connected to MongoDB queue!'
_generateMessageModel: ->

View file

@ -1,6 +1,7 @@
config = {}
config.unittest = global.testing
config.proxy = process.env.COCO_PROXY
config.tokyo = process.env.TOKYO or false
config.saoPaulo = process.env.SAOPAULO or false

View file

@ -48,7 +48,9 @@ developmentLogging = (tokens, req, res) ->
else if status >= 300 then color = 36
elapsed = (new Date()) - req._startTime
elapsedColor = if elapsed < 500 then 90 else 31
"\x1b[90m#{req.method} #{req.originalUrl} \x1b[#{color}m#{res.statusCode} \x1b[#{elapsedColor}m#{elapsed}ms\x1b[0m"
s = "\x1b[90m#{req.method} #{req.originalUrl} \x1b[#{color}m#{res.statusCode} \x1b[#{elapsedColor}m#{elapsed}ms\x1b[0m"
s += ' (proxied)' if req.proxied
return s
setupErrorMiddleware = (app) ->
app.use (err, req, res, next) ->
@ -86,6 +88,8 @@ setupExpressMiddleware = (app) ->
express.logger.format('dev', developmentLogging)
app.use(express.logger('dev'))
app.use(express.static(path.join(__dirname, 'public'), maxAge: 0)) # CloudFlare overrides maxAge, and we don't want local development caching.
setupProxyMiddleware app # TODO: Flatten setup into one function. This doesn't fit its function name.
app.use(useragent.express())
app.use(express.favicon())
@ -216,6 +220,7 @@ exports.setupLogging = ->
logging.setup()
exports.connectToDatabase = ->
return if config.proxy
database.connect()
exports.setupMailchimp = ->
@ -230,3 +235,18 @@ exports.setExpressConfigurationOptions = (app) ->
app.set('view options', { layout: false })
app.set('env', if config.isProduction then 'production' else 'development')
app.set('json spaces', 0) if config.isProduction
setupProxyMiddleware = (app) ->
return if config.isProduction
return unless config.proxy
httpProxy = require 'http-proxy'
proxy = httpProxy.createProxyServer({
target: 'https://direct.codecombat.com'
secure: false
})
log.info 'Using dev proxy server'
app.use (req, res, next) ->
req.proxied = true
proxy.web req, res, (e) ->
console.warn("Failed to proxy: ", e)
next()

View file

@ -136,6 +136,7 @@ describe 'ConvertToTeacherAccountView (/teachers/update-account)', ->
attrs = JSON.parse(request.params)
expect(attrs.properties?.firstName).toBe('Mr')
expect(attrs.properties?.siteOrigin).toBe('convert teacher')
expect(attrs.properties?.email).toBe('some@email.com')
it 'redirects to /teachers/classes', ->
request = jasmine.Ajax.requests.mostRecent()