Skip to content

Commit

Permalink
Add sunburst referral test, fix spelling
Browse files Browse the repository at this point in the history
  • Loading branch information
sderickson committed Apr 7, 2017
1 parent a621adb commit 91d40b8
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
2 changes: 1 addition & 1 deletion server/middleware/trial-requests.coffee
Expand Up @@ -32,7 +32,7 @@ module.exports =
trialRequest = yield trialRequest.save()
if trialRequest.get('properties')?.referredBy is 'sunburst'
context =
email_id: sendwithus.templates.sunburst_referrral
email_id: sendwithus.templates.sunburst_referral
recipient:
address: config.sunburst.email
email_data:
Expand Down
2 changes: 1 addition & 1 deletion server/sendwithus.coffee
Expand Up @@ -43,4 +43,4 @@ module.exports.templates =
teacher_drip_day_4: 'tem_phWmBHqdJG4bSD4dPMCF3vVM'
teacher_drip_day_5: 'tem_7Xh9HwxyQDrVRYTK37JgMXYF'
teacher_drip_day_7: 'tem_SRcvbYCd9QXRDvr68qWhD66d'
sunburst_referrral: 'tem_MWgdKKv7JwD8c6WdbRyRSG89'
sunburst_referral: 'tem_MWgdKKv7JwD8c6WdbRyRSG89'
16 changes: 16 additions & 0 deletions spec/server/functional/trial_request.spec.coffee
Expand Up @@ -7,6 +7,7 @@ TrialRequest = require '../../../server/models/TrialRequest'
Prepaid = require '../../../server/models/Prepaid'
request = require '../request'
delighted = require '../../../server/delighted'
sendwithus = require '../../../server/sendwithus'

fixture = {
type: 'subscription'
Expand Down Expand Up @@ -91,6 +92,21 @@ describe 'POST /db/trial.request', ->
expect(count).toBe(1)
done()

it 'sends a sunburst email if the trial request has a referredBy property of "sunburst"', utils.wrap (done) ->
@user = yield utils.initUser()
yield utils.loginUser(@user)
json = _.cloneDeep(fixture)
json.properties.referredBy = 'sunburst'
spyOn(sendwithus.api, 'send')
[res, body] = yield request.postAsync(getURL('/db/trial.request'), { json })
expect(res.statusCode).toBe(201)
expect(body._id).toBeDefined()
@trialRequest = yield TrialRequest.findById(body._id)
expect(@trialRequest.get('properties').referredBy).toBe('sunburst')
expect(sendwithus.api.send.calls.count()).toBe(1)
expect(sendwithus.api.send.calls.argsFor(0)[0].email_id).toBe(sendwithus.templates.sunburst_referral)
done()

describe 'GET /db/trial.request', ->

beforeEach utils.wrap (done) ->
Expand Down

0 comments on commit 91d40b8

Please sign in to comment.