|
@@ -44,6 +44,7 @@ describe "SubscriptionController", ->
|
|
|
|
|
|
|
|
@RecurlyWrapper =
|
|
@RecurlyWrapper =
|
|
|
sign: sinon.stub().callsArgWith(1, null, "somthing")
|
|
sign: sinon.stub().callsArgWith(1, null, "somthing")
|
|
|
|
|
+ getSubscription: sinon.stub().callsArgWith(2, null, {})
|
|
|
|
|
|
|
|
@SubscriptionViewModelBuilder =
|
|
@SubscriptionViewModelBuilder =
|
|
|
buildUsersSubscriptionViewModel:sinon.stub().callsArgWith(1, null, @activeRecurlySubscription)
|
|
buildUsersSubscriptionViewModel:sinon.stub().callsArgWith(1, null, @activeRecurlySubscription)
|
|
@@ -55,7 +56,7 @@ describe "SubscriptionController", ->
|
|
|
collaborator:"COLLABORATORCODEHERE"
|
|
collaborator:"COLLABORATORCODEHERE"
|
|
|
apis:
|
|
apis:
|
|
|
recurly:
|
|
recurly:
|
|
|
- subdomain:"sl.recurly.com"
|
|
|
|
|
|
|
+ subdomain:"sl"
|
|
|
siteUrl: "http://de.sharelatex.dev:3000"
|
|
siteUrl: "http://de.sharelatex.dev:3000"
|
|
|
gaExperiments:{}
|
|
gaExperiments:{}
|
|
|
@GeoIpLookup =
|
|
@GeoIpLookup =
|
|
@@ -118,34 +119,6 @@ describe "SubscriptionController", ->
|
|
|
@UserGetter.getUser.callCount.should.equal 0
|
|
@UserGetter.getUser.callCount.should.equal 0
|
|
|
done()
|
|
done()
|
|
|
|
|
|
|
|
-
|
|
|
|
|
- describe "editBillingDetailsPage", ->
|
|
|
|
|
- describe "with a user with a subscription", ->
|
|
|
|
|
- beforeEach (done) ->
|
|
|
|
|
- @LimitationsManager.userHasSubscription.callsArgWith(1, null, true)
|
|
|
|
|
- @user._id = @activeRecurlySubscription.account.account_code
|
|
|
|
|
- @res.callback = done
|
|
|
|
|
- @SubscriptionController.editBillingDetailsPage(@req, @res)
|
|
|
|
|
-
|
|
|
|
|
- it "should render the edit billing details page", ->
|
|
|
|
|
- @res.rendered.should.equal true
|
|
|
|
|
- @res.renderedTemplate.should.equal "subscriptions/edit-billing-details"
|
|
|
|
|
-
|
|
|
|
|
- it "should set the correct variables for the template", ->
|
|
|
|
|
- should.exist @res.renderedVariables.signature
|
|
|
|
|
- @res.renderedVariables.successURL.should.equal "#{@settings.siteUrl}/user/subscription/billing-details/update"
|
|
|
|
|
- @res.renderedVariables.user.id.should.equal @user._id
|
|
|
|
|
-
|
|
|
|
|
- describe "with a user without subscription", ->
|
|
|
|
|
- beforeEach (done) ->
|
|
|
|
|
- @res.callback = done
|
|
|
|
|
- @LimitationsManager.userHasSubscription.callsArgWith(1, null, false)
|
|
|
|
|
- @SubscriptionController.reactivateSubscription @req, @res
|
|
|
|
|
-
|
|
|
|
|
- it "should redirect to the subscription dashboard", ->
|
|
|
|
|
- @res.redirected.should.equal true
|
|
|
|
|
- @res.redirectedTo.should.equal "/user/subscription"
|
|
|
|
|
-
|
|
|
|
|
describe "paymentPage", ->
|
|
describe "paymentPage", ->
|
|
|
beforeEach ->
|
|
beforeEach ->
|
|
|
@req.headers = {}
|
|
@req.headers = {}
|
|
@@ -255,7 +228,12 @@ describe "SubscriptionController", ->
|
|
|
describe "with an existing subscription", ->
|
|
describe "with an existing subscription", ->
|
|
|
beforeEach (done)->
|
|
beforeEach (done)->
|
|
|
@res.callback = done
|
|
@res.callback = done
|
|
|
- @LimitationsManager.userHasSubscriptionOrIsGroupMember.callsArgWith(1, null, true)
|
|
|
|
|
|
|
+ @settings.apis.recurly.subdomain = 'test'
|
|
|
|
|
+ @userSub = {account: {hosted_login_token: 'abcd'}}
|
|
|
|
|
+ @RecurlyWrapper.getSubscription = sinon.stub()
|
|
|
|
|
+ .callsArgWith(2, null, @userSub)
|
|
|
|
|
+ @LimitationsManager.userHasSubscriptionOrIsGroupMember
|
|
|
|
|
+ .callsArgWith(1, null, true, {})
|
|
|
@SubscriptionController.userSubscriptionPage @req, @res
|
|
@SubscriptionController.userSubscriptionPage @req, @res
|
|
|
|
|
|
|
|
|
|
|
|
@@ -266,7 +244,7 @@ describe "SubscriptionController", ->
|
|
|
beforeEach (done) ->
|
|
beforeEach (done) ->
|
|
|
@res.callback = done
|
|
@res.callback = done
|
|
|
@SubscriptionViewModelBuilder.buildUsersSubscriptionViewModel.callsArgWith(1, null, @activeRecurlySubscription)
|
|
@SubscriptionViewModelBuilder.buildUsersSubscriptionViewModel.callsArgWith(1, null, @activeRecurlySubscription)
|
|
|
- @LimitationsManager.userHasSubscriptionOrIsGroupMember.callsArgWith(1, null, true)
|
|
|
|
|
|
|
+ @LimitationsManager.userHasSubscriptionOrIsGroupMember.callsArgWith(1, null, true, {})
|
|
|
@SubscriptionController.userSubscriptionPage @req, @res
|
|
@SubscriptionController.userSubscriptionPage @req, @res
|
|
|
|
|
|
|
|
it "should render the dashboard", (done)->
|
|
it "should render the dashboard", (done)->
|
|
@@ -281,7 +259,7 @@ describe "SubscriptionController", ->
|
|
|
beforeEach (done) ->
|
|
beforeEach (done) ->
|
|
|
@res.callback = done
|
|
@res.callback = done
|
|
|
@SubscriptionViewModelBuilder.buildUsersSubscriptionViewModel.callsArgWith(1, null, @activeRecurlySubscription)
|
|
@SubscriptionViewModelBuilder.buildUsersSubscriptionViewModel.callsArgWith(1, null, @activeRecurlySubscription)
|
|
|
- @LimitationsManager.userHasSubscriptionOrIsGroupMember.callsArgWith(1, null, true)
|
|
|
|
|
|
|
+ @LimitationsManager.userHasSubscriptionOrIsGroupMember.callsArgWith(1, null, true, {})
|
|
|
@SubscriptionController.userSubscriptionPage @req, @res
|
|
@SubscriptionController.userSubscriptionPage @req, @res
|
|
|
|
|
|
|
|
it "should render the dashboard", ->
|
|
it "should render the dashboard", ->
|