From db3b4447358dc7d45e1e650106e8f45ec985a332 Mon Sep 17 00:00:00 2001 From: Maxim Zhilyaev Date: Thu, 30 Jan 2014 11:26:12 -0800 Subject: [PATCH] Timestamp NYT userInfo object --- lib/NYTUtils.js | 1 + test/test-NYTUtils.js | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/lib/NYTUtils.js b/lib/NYTUtils.js index 84c77e0..6424ac5 100644 --- a/lib/NYTUtils.js +++ b/lib/NYTUtils.js @@ -43,6 +43,7 @@ exports.NYTUtils = { if (response.status >= 200 && response.status < 300) { let userInfo = response.json; userInfo.visitCount = this._extractVisitCount(); + userInfo.timeStamp = Date.now(); // we must persist userInfo to avoid a situation when dispatcher // is making a payload but response from NYT has not arrvied yet // In which case, we should use data stored previously diff --git a/test/test-NYTUtils.js b/test/test-NYTUtils.js index d29d192..62994a6 100644 --- a/test/test-NYTUtils.js +++ b/test/test-NYTUtils.js @@ -56,6 +56,10 @@ exports["test fetchNYTUserData"] = function test_fetchNYTUserData(assert, done) server.stop(function(){}); // add visit count to expected jason user info responseJSON.visitCount = 20; + // ensure userInfo is timestamped + assert.ok(userInfo.timeStamp); + // add it to the expected response + responseJSON.timeStamp = userInfo.timeStamp; testUtils.isIdentical(assert, userInfo, responseJSON); }).then(done); }