Mike Gerwitz

Activist for User Freedom

aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShelly Shaver <shelly.shaver@rtspecialty.com>2020-01-24 08:25:51 -0500
committerShelly Shaver <shelly.shaver@rtspecialty.com>2020-01-24 09:08:47 -0500
commit8967583349d5522d27f9dc11968ae13dc077cca0 (patch)
tree050806ad5cce0638a244df9cc9d949b5442753fa
parent09a84e7cafeb27e4efeab40dd074c8cac70279ed (diff)
downloadliza-8967583349d5522d27f9dc11968ae13dc077cca0.tar.gz
liza-8967583349d5522d27f9dc11968ae13dc077cca0.tar.bz2
liza-8967583349d5522d27f9dc11968ae13dc077cca0.zip
[DEV-6325] Return previous rating results on rate call
-rw-r--r--src/server/service/RatingService.ts7
-rw-r--r--test/server/service/RatingServiceTest.ts56
2 files changed, 60 insertions, 3 deletions
diff --git a/src/server/service/RatingService.ts b/src/server/service/RatingService.ts
index 4c6fd75..7eb2de8 100644
--- a/src/server/service/RatingService.ts
+++ b/src/server/service/RatingService.ts
@@ -96,10 +96,11 @@ export class RatingService
// cmd represents a request for a single rater
if ( !cmd && this._isQuoteValid( quote ) )
{
- // send an empty reply (keeps what is currently in the
- // bucket)
+ // send last rated data
this._server.sendResponse( request, quote, {
- data: {},
+ data: quote.getRatingData(),
+ initialRatedDate: quote.getRatedDate(),
+ lastRatedDate: quote.getLastPremiumDate()
}, [] );
// XXX: When this class is no longer responsible for
diff --git a/test/server/service/RatingServiceTest.ts b/test/server/service/RatingServiceTest.ts
index 016d75f..e781ceb 100644
--- a/test/server/service/RatingServiceTest.ts
+++ b/test/server/service/RatingServiceTest.ts
@@ -76,6 +76,62 @@ describe( 'RatingService', () =>
.to.eventually.deep.equal( expected );
} );
+ it( "returns previous rating results when rating is not performed", () =>
+ {
+ const {
+ logger,
+ server,
+ raters,
+ dao,
+ request,
+ response,
+ quote,
+ stub_rate_data,
+ createDelta,
+ } = getStubs();
+
+ let last_premium_date_call_count = 0;
+ let initial_date_call_count = 0;
+ let send_is_called = false;
+
+ const initial_date = <UnixTimestamp>2345;
+ const cur_date = <UnixTimestamp>Math.round(
+ ( ( new Date() ).getTime() / 1000 )
+ );
+
+ // setup recent last prem date to ensure quote is valid
+ quote.getLastPremiumDate = () =>
+ {
+ last_premium_date_call_count++;
+ return cur_date;
+ };
+
+ quote.getRatedDate = () =>
+ {
+ initial_date_call_count++;
+ return initial_date;
+ };
+
+ const sut = new Sut( logger, dao, server, raters, createDelta );
+ server.sendResponse = (
+ _request: any,
+ _quote: any,
+ resp: RateRequestResult,
+ _actions: any
+ ) =>
+ {
+ expect( resp.initialRatedDate ).to.equal( initial_date );
+ expect( resp.lastRatedDate ).to.equal( cur_date );
+ expect( resp.data ).to.equal( stub_rate_data );
+ expect( last_premium_date_call_count ).to.equal( 2 );
+ expect( initial_date_call_count ).to.equal( 1 );
+ send_is_called = true;
+ return server;
+ };
+
+ return sut.request( request, response, quote, "" )
+ .then( _=> expect( send_is_called ).to.be.true );
+ } );
it( "updates rating dates before serving to client", () =>
{