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) -> BetaProgramHandler.optIn user_id, (err) ->
if err if err
return next(err) return next(err)
return res.redirect "/" return res.redirect "/beta/opt-in"
optInPage: (req, res, next)-> optInPage: (req, res, next)->
user_id = req.session?.user?._id user_id = req.session?.user?._id

View file

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

View file

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