mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-30 10:56:53 -05:00
Update teacher surveys
Gives 2 course headcount too.
This commit is contained in:
parent
3c62b5b39e
commit
9189adcff0
2 changed files with 23 additions and 3 deletions
|
@ -10,6 +10,8 @@ TrialRequestSchema = new mongoose.Schema {}, {strict: false, minimize: false, re
|
|||
|
||||
TrialRequestSchema.pre 'save', (next) ->
|
||||
return next() unless @get('status') is 'approved'
|
||||
|
||||
# Add subscription
|
||||
Prepaid.generateNewCode (code) =>
|
||||
unless code
|
||||
log.error "Trial request pre save prepaid gen new code failure"
|
||||
|
@ -24,8 +26,20 @@ TrialRequestSchema.pre 'save', (next) ->
|
|||
prepaid.save (err) =>
|
||||
if err
|
||||
log.error "Trial request prepaid creation error: #{err}"
|
||||
return next()
|
||||
@set('prepaidCode', code)
|
||||
next()
|
||||
|
||||
# Add 2 course headcount
|
||||
prepaid = new Prepaid
|
||||
creator: @get('applicant')
|
||||
type: 'course'
|
||||
maxRedeemers: 2
|
||||
properties:
|
||||
trialRequestID: @get('_id')
|
||||
prepaid.save (err) =>
|
||||
if err
|
||||
log.error "Trial request prepaid creation error: #{err}"
|
||||
next()
|
||||
|
||||
TrialRequestSchema.post 'save', (doc) ->
|
||||
if doc.get('status') is 'submitted'
|
||||
|
|
|
@ -110,7 +110,7 @@ describe 'Trial Requests', ->
|
|||
createTrialRequest user, 'subscription', properties, (trialRequest) ->
|
||||
loginNewUser (admin) ->
|
||||
admin.set('permissions', ['admin'])
|
||||
admin.save (err, user) ->
|
||||
admin.save (err, admin) ->
|
||||
requestBody = trialRequest.toObject()
|
||||
requestBody.status = 'approved'
|
||||
request.put {uri: URL, json: requestBody }, (err, res, body) ->
|
||||
|
@ -128,7 +128,13 @@ describe 'Trial Requests', ->
|
|||
expect(new Date(doc.get('reviewDate'))).toBeLessThan(new Date())
|
||||
expect(doc.get('reviewer')).toEqual(admin._id)
|
||||
expect(doc.get('prepaidCode')).toBeDefined()
|
||||
done()
|
||||
Prepaid.findOne {'properties.trialRequestID': doc.get('_id')}, (err, doc) ->
|
||||
expect(err).toBeNull()
|
||||
return done(err) if err
|
||||
expect(doc.get('type')).toEqual('course')
|
||||
expect(doc.get('creator')).toEqual(user.get('_id'))
|
||||
expect(doc.get('maxRedeemers')).toEqual(2)
|
||||
done()
|
||||
|
||||
it 'Deny trial request', (done) ->
|
||||
loginNewUser (user) ->
|
||||
|
|
Loading…
Reference in a new issue