Skip to content
This repository has been archived by the owner on Feb 1, 2019. It is now read-only.

Commit

Permalink
Merge pull request #132 from stevejameskent/lar-endpoint-fix
Browse files Browse the repository at this point in the history
Lar endpoint fix
  • Loading branch information
LinuxBozo committed May 1, 2015
2 parents 87ccb55 + bf989d4 commit 9ae9e60
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
9 changes: 7 additions & 2 deletions engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ HMDAEngine.prototype.runLarType = function(year, type, lar) {
var fileSpec = hmdaRuleSpec.getFileSpec(year);
var parsedLar = hmdajson.parseLine('loanApplicationRegister', fileSpec.loanApplicationRegister, lar);

if (type !== 'special' && type !== 'macro') {
if (hmdaRuleSpec.getEdits(year, 'lar', type)) {
var larPromise = this.getEditRunPromiseLar(year, type, parsedLar.record);
if (larPromise) {
return larPromise
Expand All @@ -435,6 +435,8 @@ HMDAEngine.prototype.runLarType = function(year, type, lar) {
return utils.resolveError(err);
});
}
} else {
return Promise.reject(new Error('Invalid edit type: ' + type));
}
};

Expand All @@ -446,8 +448,11 @@ HMDAEngine.prototype.runLarType = function(year, type, lar) {
*/
HMDAEngine.prototype.runLar = function(year, lar) {
var editTypes = hmdaRuleSpec.getValidEditTypes();

return Promise.each(editTypes, function(currentEditType) {
return this.runLarType(year, currentEditType, lar);
if (hmdaRuleSpec.getEdits(year, 'lar', currentEditType)) {
return this.runLarType(year, currentEditType, lar);
}
}.bind(this))
.then(function() {
return this.getErrors();
Expand Down
11 changes: 11 additions & 0 deletions test/engineSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -517,6 +517,17 @@ describe('Engine', function() {
done();
});
});

it('should return a rejected promise for an invalid edit type', function(done) {
rewiredEngine.clearErrors();
var lar = '201234567899ABCDEFGHIJKLMNOPQRSTUVWXY20130117432110000152013011906920060340100.01457432187654129000098701.0524B x ';

rewiredEngine.runLarType('2013', 'cat', lar)
.catch(function(err) {
expect(err.message).to.be('Invalid edit type: cat');
done();
});
});
});

describe('runLar', function() {
Expand Down

0 comments on commit 9ae9e60

Please sign in to comment.