mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
if a user is elelable to be part of a group subscription and they go to
/user/subscription it should redirect them to the group subscription invite
This commit is contained in:
parent
1d21bddcf5
commit
79fa49a43d
2 changed files with 38 additions and 3 deletions
|
@ -8,7 +8,7 @@ RecurlyWrapper = require './RecurlyWrapper'
|
|||
Settings = require 'settings-sharelatex'
|
||||
logger = require('logger-sharelatex')
|
||||
GeoIpLookup = require("../../infrastructure/GeoIpLookup")
|
||||
|
||||
SubscriptionDomainAllocator = require("./SubscriptionDomainAllocator")
|
||||
|
||||
module.exports = SubscriptionController =
|
||||
|
||||
|
@ -84,9 +84,13 @@ module.exports = SubscriptionController =
|
|||
SecurityManager.getCurrentUser req, (error, user) =>
|
||||
return next(error) if error?
|
||||
LimitationsManager.userHasSubscriptionOrIsGroupMember user, (err, hasSubOrIsGroupMember, subscription)->
|
||||
groupLicenceInviteUrl = SubscriptionDomainAllocator.getDomainLicencePage(user)
|
||||
if subscription?.customAccount
|
||||
logger.log user: user, "redirecting to plans"
|
||||
res.redirect "/user/subscription/custom_account"
|
||||
res.redirect "/user/subscription/custom_account"
|
||||
else if groupLicenceInviteUrl? and !hasSubOrIsGroupMember
|
||||
logger.log user:user, "redirecting to group subscription invite page"
|
||||
res.redirect groupLicenceInviteUrl
|
||||
else if !hasSubOrIsGroupMember
|
||||
logger.log user: user, "redirecting to plans"
|
||||
res.redirect "/user/subscription/plans"
|
||||
|
|
|
@ -58,7 +58,8 @@ describe "SubscriptionController sanboxed", ->
|
|||
gaExperiments:{}
|
||||
@GeoIpLookup =
|
||||
getCurrencyCode:sinon.stub()
|
||||
|
||||
@SubscriptionDomainAllocator =
|
||||
getDomainLicencePage:sinon.stub()
|
||||
@SubscriptionController = SandboxedModule.require modulePath, requires:
|
||||
'../../managers/SecurityManager': @SecurityManager
|
||||
'./SubscriptionHandler': @SubscriptionHandler
|
||||
|
@ -69,6 +70,7 @@ describe "SubscriptionController sanboxed", ->
|
|||
'./RecurlyWrapper': @RecurlyWrapper
|
||||
"logger-sharelatex": log:->
|
||||
"settings-sharelatex": @settings
|
||||
"./SubscriptionDomainAllocator":@SubscriptionDomainAllocator
|
||||
|
||||
|
||||
@res = new MockResponse()
|
||||
|
@ -206,6 +208,35 @@ describe "SubscriptionController sanboxed", ->
|
|||
@res.redirected.should.equal true
|
||||
@res.redirectedTo.should.equal "/user/subscription/plans"
|
||||
|
||||
describe "with a potential domain licence", ->
|
||||
beforeEach () ->
|
||||
@groupUrl = "/go/over-here"
|
||||
@SubscriptionDomainAllocator.getDomainLicencePage.returns(@groupUrl)
|
||||
|
||||
describe "without an existing subscription", ->
|
||||
beforeEach (done)->
|
||||
@res.callback = done
|
||||
@LimitationsManager.userHasSubscriptionOrIsGroupMember.callsArgWith(1, null, false)
|
||||
@SubscriptionController.userSubscriptionPage @req, @res
|
||||
|
||||
it "should redirect to the group invite url", ->
|
||||
@res.redirected.should.equal true
|
||||
@res.redirectedTo.should.equal @groupUrl
|
||||
|
||||
describe "with an existing subscription", ->
|
||||
beforeEach (done)->
|
||||
@res.callback = done
|
||||
@LimitationsManager.userHasSubscriptionOrIsGroupMember.callsArgWith(1, null, true)
|
||||
@SubscriptionController.userSubscriptionPage @req, @res
|
||||
|
||||
|
||||
it "should render the dashboard", ->
|
||||
@res.renderedTemplate.should.equal "subscriptions/dashboard"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
describe "with a user with a paid subscription", ->
|
||||
beforeEach (done) ->
|
||||
@res.callback = done
|
||||
|
|
Loading…
Reference in a new issue