Simplify method name

This commit is contained in:
Alberto Fernández Capel 2018-06-07 15:35:18 +01:00
parent 30b935befd
commit 670f24ef6f
5 changed files with 15 additions and 15 deletions

View file

@ -33,7 +33,7 @@ module.exports = SubscriptionGroupHandler =
userViewModel = buildUserViewModel(user)
callback(err, userViewModel)
else
TeamInvitesHandler.createManagerInvite adminUserId, newEmail, (err) ->
TeamInvitesHandler.createInvite adminUserId, newEmail, (err) ->
return callback(err) if err?
userViewModel = buildEmailInviteViewModel(newEmail)
callback(err, userViewModel)

View file

@ -10,7 +10,7 @@ module.exports =
teamManagerId = AuthenticationController.getLoggedInUserId(req)
email = req.body.email
TeamInvitesHandler.createManagerInvite teamManagerId, email, (err, invite) ->
TeamInvitesHandler.createInvite teamManagerId, email, (err, invite) ->
return handleError(err, req, res, next) if err?
inviteView = { user:
{ email: invite.email, sentAt: invite.sentAt, invite: true }

View file

@ -24,7 +24,7 @@ module.exports = TeamInvitesHandler =
invite = subscription.teamInvites.find (i) -> i.token == token
return callback(null, invite, subscription)
createManagerInvite: (teamManagerId, email, callback) ->
createInvite: (teamManagerId, email, callback) ->
logger.log {teamManagerId, email}, "Creating manager team invite"
UserGetter.getUser teamManagerId, (error, teamManager) ->
return callback(error) if error?
@ -73,7 +73,7 @@ module.exports = TeamInvitesHandler =
return callback(err) if err?
async.map teams,
(team, cb) -> TeamInvitesHandler.createManagerInvite(team.admin_id, email, cb)
(team, cb) -> TeamInvitesHandler.createInvite(team.admin_id, email, cb)
, callback
createInvite = (subscription, email, inviterName, callback) ->

View file

@ -29,7 +29,7 @@ describe "SubscriptionGroupHandler", ->
removeUserFromGroup: sinon.stub().callsArgWith(2)
@TeamInvitesHandler =
createManagerInvite: sinon.stub().callsArgWith(2)
createInvite: sinon.stub().callsArgWith(2)
@UserGetter =
getUser: sinon.stub()
@ -106,7 +106,7 @@ describe "SubscriptionGroupHandler", ->
it "should add an email invite if no user is found", (done) ->
@UserGetter.getUserByMainEmail.callsArgWith(1, null, null)
@Handler.addUserToGroup @adminUser_id, @newEmail, (err)=>
@TeamInvitesHandler.createManagerInvite.calledWith(@adminUser_id, @newEmail).should.equal true
@TeamInvitesHandler.createInvite.calledWith(@adminUser_id, @newEmail).should.equal true
done()
describe "removeUserFromGroup", ->

View file

@ -98,9 +98,9 @@ describe "TeamInvitesHandler", ->
expect(err).to.deep.eq(teamNotFound: true)
done()
describe "createManagerInvite", ->
describe "createInvite", ->
it "adds the team invite to the subscription", (done) ->
@TeamInvitesHandler.createManagerInvite @manager.id, "John.Snow@nightwatch.com", (err, invite) =>
@TeamInvitesHandler.createInvite @manager.id, "John.Snow@nightwatch.com", (err, invite) =>
expect(err).to.eq(null)
expect(invite.token).to.eq(@newToken)
expect(invite.email).to.eq("john.snow@nightwatch.com")
@ -109,7 +109,7 @@ describe "TeamInvitesHandler", ->
done()
it "sends an email", (done) ->
@TeamInvitesHandler.createManagerInvite @manager.id, "John.Snow@nightwatch.com", (err, invite) =>
@TeamInvitesHandler.createInvite @manager.id, "John.Snow@nightwatch.com", (err, invite) =>
@EmailHandler.sendEmail.calledWith("verifyEmailToJoinTeam",
sinon.match({
to: "john.snow@nightwatch.com",
@ -122,7 +122,7 @@ describe "TeamInvitesHandler", ->
it "refreshes the existing invite if the email has already been invited", (done) ->
originalInvite = Object.assign({}, @teamInvite)
@TeamInvitesHandler.createManagerInvite @manager.id, originalInvite.email, (err, invite) =>
@TeamInvitesHandler.createInvite @manager.id, originalInvite.email, (err, invite) =>
expect(err).to.eq(null)
expect(invite).to.exist
@ -206,26 +206,26 @@ describe "TeamInvitesHandler", ->
describe "createTeamInvitesForLegacyInvitedEmail", (done) ->
beforeEach ->
@subscription.invited_emails = ["eddard@stark.com", "robert@stark.com"]
@TeamInvitesHandler.createManagerInvite = sinon.stub().yields(null)
@TeamInvitesHandler.createInvite = sinon.stub().yields(null)
@SubscriptionLocator.getGroupsWithEmailInvite = sinon.stub().yields(null, [@subscription])
it "sends an invitation email to addresses in the legacy invited_emails field", (done) ->
@TeamInvitesHandler.createTeamInvitesForLegacyInvitedEmail "eddard@stark.com", (err, invite) =>
expect(err).not.to.exist
@TeamInvitesHandler.createManagerInvite.calledWith(
@TeamInvitesHandler.createInvite.calledWith(
@subscription.admin_id,
"eddard@stark.com"
).should.eq true
@TeamInvitesHandler.createManagerInvite.callCount.should.eq 1
@TeamInvitesHandler.createInvite.callCount.should.eq 1
done()
describe "validation", ->
it "doesn't create an invite if the team limit has been reached", (done) ->
@LimitationsManager.teamHasReachedMemberLimit = sinon.stub().returns(true)
@TeamInvitesHandler.createManagerInvite @manager.id, "John.Snow@nightwatch.com", (err, invite) =>
@TeamInvitesHandler.createInvite @manager.id, "John.Snow@nightwatch.com", (err, invite) =>
expect(err).to.deep.equal(limitReached: true)
done()
@ -239,7 +239,7 @@ describe "TeamInvitesHandler", ->
@subscription.member_ids = [member.id]
@UserGetter.getUserByAnyEmail.withArgs(member.email).yields(null, member)
@TeamInvitesHandler.createManagerInvite @manager.id, "tyrion@lannister.com", (err, invite) =>
@TeamInvitesHandler.createInvite @manager.id, "tyrion@lannister.com", (err, invite) =>
expect(err).to.deep.equal(alreadyInTeam: true)
expect(invite).not.to.exist
done()