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

Lar endpoint fix #132

Merged
merged 4 commits into from
May 1, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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