From f0e246deef1e10f382cafcd36eca89620a8f6ace Mon Sep 17 00:00:00 2001 From: Mike Gerwitz Date: Thu, 31 Oct 2019 11:21:01 -0400 Subject: [PATCH] RatingService#postProcessRaterData: Fix accidental indvRate change I accidentally changed id=>after when prototyping data for the _new_ deferred rating (not yet written). There were no tests for this code, which was originally written in July of 2012 (see private lovullo.git repo), so it was not caught until QA. --- src/server/service/RatingService.ts | 2 +- test/server/service/RatingServiceTest.ts | 46 ++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 1 deletion(-) diff --git a/src/server/service/RatingService.ts b/src/server/service/RatingService.ts index df27f31..b2a5062 100644 --- a/src/server/service/RatingService.ts +++ b/src/server/service/RatingService.ts @@ -346,7 +346,7 @@ export class RatingService meta.deferred.forEach( ( alias: string ) => { - actions.push( { action: 'indvRate', after: alias } ); + actions.push( { action: 'indvRate', id: alias } ); torate.push( alias ); } ); diff --git a/test/server/service/RatingServiceTest.ts b/test/server/service/RatingServiceTest.ts index fd659d6..7bab2e4 100644 --- a/test/server/service/RatingServiceTest.ts +++ b/test/server/service/RatingServiceTest.ts @@ -194,6 +194,52 @@ describe( 'RatingService', () => } ); + // this means of deferred rating is deprecated and is being superceded + // in the near future by a better system; it will hopefully be removed + // at some point + it( "sends indvRate action for old-style deferred suppliers", () => + { + const { + dao, + logger, + quote, + raters, + request, + response, + server, + stub_rate_data, + } = getStubs(); + + let sent = false; + + stub_rate_data._cmpdata = { + deferred: [ 'supp1', 'supp2' ], + }; + + server.sendResponse = ( + _request: any, + _quote: any, + _resp: any, + actions: ClientActions + ) => + { + expect( actions ).to.deep.equal( [ + { action: 'indvRate', id: 'supp1' }, + { action: 'indvRate', id: 'supp2' }, + ] ); + + sent = true; + + return server; + }; + + const sut = new Sut( logger, dao, server, raters ); + + return sut.request( request, response, quote, "" ) + .then( () => expect( sent ).to.be.true ); + } ); + + describe( "protected API", () => { it( "calls #postProcessRaterData after rating before save", done =>