|
@@ -3,12 +3,12 @@ should = require('chai').should()
|
|
|
sinon = require 'sinon'
|
|
sinon = require 'sinon'
|
|
|
assert = require("chai").assert
|
|
assert = require("chai").assert
|
|
|
modulePath = "../../../../app/js/Features/Subscription/SubscriptionGroupController"
|
|
modulePath = "../../../../app/js/Features/Subscription/SubscriptionGroupController"
|
|
|
-
|
|
|
|
|
|
|
+MockResponse = require "../helpers/MockResponse"
|
|
|
|
|
|
|
|
describe "Subscription Group Controller", ->
|
|
describe "Subscription Group Controller", ->
|
|
|
|
|
|
|
|
beforeEach ->
|
|
beforeEach ->
|
|
|
- @user = {_id:"!@312431"}
|
|
|
|
|
|
|
+ @user = {_id:"!@312431",email:"user@email.com"}
|
|
|
@subscription = {}
|
|
@subscription = {}
|
|
|
@GroupHandler =
|
|
@GroupHandler =
|
|
|
addUserToGroup: sinon.stub().callsArgWith(2, null, @user)
|
|
addUserToGroup: sinon.stub().callsArgWith(2, null, @user)
|
|
@@ -16,7 +16,7 @@ describe "Subscription Group Controller", ->
|
|
|
isUserPartOfGroup: sinon.stub()
|
|
isUserPartOfGroup: sinon.stub()
|
|
|
sendVerificationEmail:sinon.stub()
|
|
sendVerificationEmail:sinon.stub()
|
|
|
processGroupVerification:sinon.stub()
|
|
processGroupVerification:sinon.stub()
|
|
|
-
|
|
|
|
|
|
|
+ getPopulatedListOfMembers: sinon.stub().callsArgWith(1, null, [@user])
|
|
|
@SubscriptionLocator = getUsersSubscription: sinon.stub().callsArgWith(1, null, @subscription)
|
|
@SubscriptionLocator = getUsersSubscription: sinon.stub().callsArgWith(1, null, @subscription)
|
|
|
|
|
|
|
|
@SubscriptionDomainHandler =
|
|
@SubscriptionDomainHandler =
|
|
@@ -78,7 +78,7 @@ describe "Subscription Group Controller", ->
|
|
|
|
|
|
|
|
describe "renderSubscriptionGroupAdminPage", ->
|
|
describe "renderSubscriptionGroupAdminPage", ->
|
|
|
it "should redirect you if you don't have a group account", (done)->
|
|
it "should redirect you if you don't have a group account", (done)->
|
|
|
- @subscription.group = false
|
|
|
|
|
|
|
+ @subscription.groupPlan = false
|
|
|
|
|
|
|
|
res =
|
|
res =
|
|
|
redirect : (path)=>
|
|
redirect : (path)=>
|
|
@@ -86,7 +86,6 @@ describe "Subscription Group Controller", ->
|
|
|
done()
|
|
done()
|
|
|
@Controller.renderSubscriptionGroupAdminPage @req, res
|
|
@Controller.renderSubscriptionGroupAdminPage @req, res
|
|
|
|
|
|
|
|
-
|
|
|
|
|
describe "renderGroupInvitePage", ->
|
|
describe "renderGroupInvitePage", ->
|
|
|
describe "with a valid licence", ->
|
|
describe "with a valid licence", ->
|
|
|
beforeEach ->
|
|
beforeEach ->
|
|
@@ -166,4 +165,30 @@ describe "Subscription Group Controller", ->
|
|
|
it "should send a 500", (done)->
|
|
it "should send a 500", (done)->
|
|
|
@Controller.completeJoin @req, {}
|
|
@Controller.completeJoin @req, {}
|
|
|
@ErrorsController.notFound.called.should.equal true
|
|
@ErrorsController.notFound.called.should.equal true
|
|
|
- done()
|
|
|
|
|
|
|
+ done()
|
|
|
|
|
+ describe "exportGroupCsv", ->
|
|
|
|
|
+
|
|
|
|
|
+ beforeEach ->
|
|
|
|
|
+ @subscription.groupPlan = true
|
|
|
|
|
+ @res = new MockResponse()
|
|
|
|
|
+ @res.contentType = sinon.stub()
|
|
|
|
|
+ @res.header = sinon.stub()
|
|
|
|
|
+ @res.send = sinon.stub()
|
|
|
|
|
+ @Controller.exportGroupCsv @req, @res
|
|
|
|
|
+
|
|
|
|
|
+ it "should set the correct content type on the request", ->
|
|
|
|
|
+ @res.contentType
|
|
|
|
|
+ .calledWith("text/csv")
|
|
|
|
|
+ .should.equal true
|
|
|
|
|
+
|
|
|
|
|
+ it "should name the exported csv file", ->
|
|
|
|
|
+ @res.header
|
|
|
|
|
+ .calledWith(
|
|
|
|
|
+ "Content-Disposition",
|
|
|
|
|
+ "attachment; filename=Group.csv")
|
|
|
|
|
+ .should.equal true
|
|
|
|
|
+
|
|
|
|
|
+ it "should export the correct csv", ->
|
|
|
|
|
+ @res.send
|
|
|
|
|
+ .calledWith("user@email.com\n")
|
|
|
|
|
+ .should.equal true
|