 		expect(body).to.match new RegExp("<title>Project Invite - .*</title>")
 		callback()
 
-expectInvalidInvitePage = (user, link, callback=()->) ->
+expectInvalidInvitePage = (user, link, callback=(err,result)->) ->
 	# view invalid invite
 	tryFollowInviteLink user, link, (err, response, body) ->
 		expect(err).to.be.oneOf [null, undefined]

					Async.series [
						(cb) => expectInviteRedirectToRegister(@user, @link, cb)
					], done

			token: invite.token
	}, callback

tryRegisterUser = (user, email, redir, callback=(err, response, body)->) ->
	user.getCsrfToken (error) =>
		return callback(error) if error?
		user.request.post {
			url: "/register"
			json:
				email: email
				password: "some_weird_password"
				redir: redir
		}, callback


# Expectations
expectProjectAccess = (user, projectId, callback=(err,result)->) ->
	# should have access to project
	user.openProject projectId, (err) =>
		expect(err).to.be.oneOf [null, undefined]
		callback()

expectNoProjectAccess = (user, projectId, callback=(err,result)->) ->
	# should not have access to project page
	user.openProject projectId, (err) =>
		expect(err).to.be.instanceof Error
		callback()

expectInvitePage = (user, link, callback=(err,result)->) ->
	# view invite
	tryFollowInviteLink user, link, (err, response, body) ->
		expect(err).to.be.oneOf [null, undefined]
