Add AB test for plans (+15 squashed commits)
Squashed commits: [45c2237] Add a `subscription-form-switch-to-student` event [1ad9b8f] change experiment name, and re-enable switch-to-student workflow [f7cdb78] Remove debug [4b9778a] Incorporate collaborator alternative plans [701e80b] Add collaborator plans for heron and ibis [287aa0f] AB test plans from editor page [c74052e] Fix change-plan view for default plans [1a947d6] Use correct plan codes [1eecda7] Adjust prices [69c4c7b] Introduce two plans [8b8d5f8] Rename sixpack experiment [c332002] Fix up the change-plan page [c7af52d] Overhaul change-plan page, show only plans from current generation [33d86bf] update plan [5bbd946] Add a basic plans AB test
This commit is contained in:
@@ -20,7 +20,7 @@ mockSubscriptions =
|
||||
describe "SubscriptionController sanboxed", ->
|
||||
|
||||
beforeEach ->
|
||||
@user = {email:"tom@yahoo.com", _id: 'one'}
|
||||
@user = {email:"tom@yahoo.com", _id: 'one', signUpDate: new Date('2000-10-01')}
|
||||
@activeRecurlySubscription = mockSubscriptions["subscription-123-active"]
|
||||
|
||||
@AuthenticationController =
|
||||
@@ -63,6 +63,8 @@ describe "SubscriptionController sanboxed", ->
|
||||
getCurrencyCode:sinon.stub()
|
||||
@SubscriptionDomainHandler =
|
||||
getDomainLicencePage:sinon.stub()
|
||||
@UserGetter =
|
||||
getUser: sinon.stub().callsArgWith(2, null, @user)
|
||||
@SubscriptionController = SandboxedModule.require modulePath, requires:
|
||||
'../Authentication/AuthenticationController': @AuthenticationController
|
||||
'./SubscriptionHandler': @SubscriptionHandler
|
||||
@@ -76,6 +78,7 @@ describe "SubscriptionController sanboxed", ->
|
||||
warn:->
|
||||
"settings-sharelatex": @settings
|
||||
"./SubscriptionDomainHandler":@SubscriptionDomainHandler
|
||||
"../User/UserGetter": @UserGetter
|
||||
|
||||
|
||||
@res = new MockResponse()
|
||||
@@ -92,12 +95,31 @@ describe "SubscriptionController sanboxed", ->
|
||||
@GeoIpLookup.getCurrencyCode.callsArgWith(1, null, @stubbedCurrencyCode)
|
||||
@res.callback = done
|
||||
@SubscriptionController.plansPage(@req, @res)
|
||||
@UserGetter.getUser = sinon.stub().callsArgWith(2, null, @user)
|
||||
|
||||
it "should set the recommended currency from the geoiplookup", (done)->
|
||||
@res.renderedVariables.recomendedCurrency.should.equal(@stubbedCurrencyCode)
|
||||
@GeoIpLookup.getCurrencyCode.calledWith(@req.ip).should.equal true
|
||||
done()
|
||||
|
||||
it 'should fetch the current user', (done) ->
|
||||
@UserGetter.getUser.callCount.should.equal 1
|
||||
done()
|
||||
|
||||
it 'should decide not to AB test the plans', (done) ->
|
||||
@res.renderedVariables.shouldABTestPlans.should.equal false
|
||||
done()
|
||||
|
||||
describe 'when user is not logged in', (done) ->
|
||||
|
||||
beforeEach ->
|
||||
@AuthenticationController.getLoggedInUserId.returns(null)
|
||||
|
||||
it 'should not fetch the current user', (done) ->
|
||||
@UserGetter.getUser.callCount.should.equal 0
|
||||
done()
|
||||
|
||||
|
||||
describe "editBillingDetailsPage", ->
|
||||
describe "with a user with a subscription", ->
|
||||
beforeEach (done) ->
|
||||
|
||||
Reference in New Issue
Block a user