hmpo-form-controller
Advanced tools
Comparing version 0.0.5 to 0.0.6
@@ -152,3 +152,6 @@ var util = require('util'), | ||
var next = this.options.next || req.path; | ||
return req.baseUrl + next; | ||
if (req.baseUrl !== '/') { | ||
next = req.baseUrl + next; | ||
} | ||
return next; | ||
}, | ||
@@ -163,3 +166,6 @@ getErrorStep: function (err, req) { | ||
} | ||
return req.baseUrl + redirect; | ||
if (req.baseUrl !== '/') { | ||
redirect = req.baseUrl + redirect; | ||
} | ||
return redirect; | ||
}, | ||
@@ -166,0 +172,0 @@ isValidationError: function (err) { |
{ | ||
"name": "hmpo-form-controller", | ||
"version": "0.0.5", | ||
"version": "0.0.6", | ||
"description": "", | ||
@@ -33,2 +33,3 @@ "main": "index.js", | ||
"postcode": "^0.2.2", | ||
"reqres": "^1.1.1", | ||
"sinon": "^1.12.2", | ||
@@ -35,0 +36,0 @@ "sinon-chai": "^2.6.0" |
module.exports = function (req) { | ||
req.form = req.form || {}; | ||
req.form.values = req.form.values || {}; | ||
req.session = req.session || {}; | ||
req.flash = req.flash || sinon.stub().returns([]); | ||
req.baseUrl = ''; | ||
req.params = req.params || {}; | ||
return req; | ||
return require('reqres').req(req); | ||
}; |
@@ -168,3 +168,2 @@ var Form = require('../../'); | ||
it('passes output of getValues to the rendered template', function () { | ||
req.flash.returns([]); | ||
form.getValues.yields(null, { values: [1] }); | ||
@@ -176,3 +175,2 @@ form.get(req, res, cb); | ||
it('calls callback with error if getValues fails', function () { | ||
req.flash.returns([]); | ||
form.getValues.yields({ error: 'message' }); | ||
@@ -446,3 +444,3 @@ form.get(req, res, cb); | ||
beforeEach(function () { | ||
form = new Form({ template: 'index', next: 'success' }); | ||
form = new Form({ template: 'index', next: '/success' }); | ||
req = request({ | ||
@@ -460,9 +458,9 @@ params: {}, | ||
form.successHandler(req, res); | ||
res.redirect.should.have.been.calledWith('success'); | ||
res.redirect.should.have.been.calledWith('/success'); | ||
}); | ||
it('prefixes redirect url with req.baseUrl', function () { | ||
req.baseUrl = 'base/'; | ||
req.baseUrl = '/base'; | ||
form.successHandler(req, res); | ||
res.redirect.should.have.been.calledWith('base/success'); | ||
res.redirect.should.have.been.calledWith('/base/success'); | ||
}); | ||
@@ -485,3 +483,3 @@ | ||
err = new Form.Error('field'); | ||
form = new Form({ template: 'index', next: 'success' }); | ||
form = new Form({ template: 'index', next: '/success' }); | ||
req = request({ | ||
@@ -488,0 +486,0 @@ path: '/index', |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
59837
9