refine beta opt-in workflow.

This commit is contained in:
Shane Kilkelly 2016-06-08 11:04:44 +01:00
parent 20485cbfed
commit 90dac348ff
3 changed files with 6 additions and 3 deletions

View file

@ -14,7 +14,7 @@ module.exports = BetaProgramController =
BetaProgramHandler.optIn user_id, (err) ->
if err
return next(err)
return res.redirect "/"
return res.redirect "/beta/opt-in"
optInPage: (req, res, next)->
user_id = req.session?.user?._id

View file

@ -18,11 +18,13 @@ block content
.col-md-12
if user.betaProgram
p #{translate("beta_program_already_participating")}
.form-group
a(href="/project").btn.btn-info #{translate("back_to_your_projects")}
else
form(method="post", action="/beta/opt-in", novalidate)
.form-group
input(type="hidden", name="_csrf", value=csrfToken)
button.btn.btn-lg.btn-primary(
button.btn.btn-primary(
type="submit"
)
span #{translate("beta_program_opt_in_action")}

View file

@ -44,9 +44,10 @@ describe "BetaProgramController", ->
beforeEach ->
@BetaProgramHandler.optIn.callsArgWith(1, null)
it "should redirect to '/'", () ->
it "should redirect to '/beta/opt-in'", () ->
@BetaProgramController.optIn @req, @res, @next
@res.redirect.callCount.should.equal 1
@res.redirect.firstCall.args[0].should.equal "/beta/opt-in"
it "should not call next with an error", () ->
@BetaProgramController.optIn @req, @res, @next