From 492900fc2250ab0e261f39b6e2b210fc15328046 Mon Sep 17 00:00:00 2001 From: Michael Hidalgo Date: Wed, 11 Jan 2017 18:11:11 -0600 Subject: [PATCH 1/2] Upgrading packages and doing refactoring based on those new packages. --- package.json | 10 +++++----- src/Vis/Guid.coffee | 4 ++-- src/services/GitHub-Service.coffee | 10 +++++----- src/services/TeamMentor-Service.coffee | 2 +- test/services/Cache-Service.test.coffee | 8 +++++--- test/services/GitHub-Service.test.coffee | 9 +++++---- test/services/TeamMentor-Service.test.coffee | 2 +- 7 files changed, 24 insertions(+), 21 deletions(-) diff --git a/package.json b/package.json index 644c7ef..b585d52 100644 --- a/package.json +++ b/package.json @@ -26,15 +26,15 @@ "dependencies": { "coffee-script": "^1.8.0", "fluentnode": "*", - "github": "^0.2.3", + "github": "^7.3.2", "jade": "^1.8.2", - "node-uuid": "^1.4.2", "request": "^2.51.0", + "uuid": "^3.0.1", "xml2js": "^0.4.4" }, "devDependencies": { - "chai": "^1.10.0", - "cheerio": "^0.18.0", - "mocha": "^2.0.1" + "chai": "^3.5.0", + "cheerio": "^0.22.0", + "mocha": "^3.2.0" } } diff --git a/src/Vis/Guid.coffee b/src/Vis/Guid.coffee index d79dd73..8ba1323 100644 --- a/src/Vis/Guid.coffee +++ b/src/Vis/Guid.coffee @@ -1,10 +1,10 @@ require('fluentnode') -node_uuid = require('node-uuid') +uuid = require('uuid') class Guid constructor: (title, guid)-> - @raw = guid || node_uuid.v4() + @raw = guid || uuid.v4() @short = (if (title) then title + "-" else "") + @raw.split('-').last() module.exports = Guid \ No newline at end of file diff --git a/src/services/GitHub-Service.coffee b/src/services/GitHub-Service.coffee index fed0a03..23404b7 100644 --- a/src/services/GitHub-Service.coffee +++ b/src/services/GitHub-Service.coffee @@ -38,7 +38,7 @@ class GitHubService rateLimit: (callback)=> @cacheService 'rateLimit', callback, (cache_callback) => - @github.misc.rateLimit {}, (err,res)=> + @github.misc.getRateLimit {}, (err,res)=> throw err if err cache_callback(res) @@ -53,28 +53,28 @@ class GitHubService gist: (id, file, callback)-> @cacheService "gist_#{id}_#{file}", callback, (cache_callback) => @github.gists.get id : id, (err, res)-> - if err or res.files.keys().not_Contains(file) + if err or res.files.keys_Own().not_Contains(file) cache_callback(null) else cache_callback(res.files[file]) repo_Raw: (user,repo, callback)-> @cacheService "repo_Raw_#{user}_#{repo}", callback, (cache_callback) => - @github.repos.get user : user, repo: repo, (err, res)-> + @github.repos.get user : user, owner: user, repo: repo, (err, res)-> throw err if err cache_callback(res) tree_Raw: (user,repo, sha, callback)-> recursive = true @cacheService "tree_Raw_#{user}_#{repo}_#{sha}_#{recursive}", callback, (cache_callback) => - @github.gitdata.getTree user : user, repo: repo, sha: sha, recursive : recursive, (err, res)-> + @github.gitdata.getTree user : user, owner:user, repo: repo, sha: sha, recursive : recursive, (err, res)-> throw err if err cache_callback(res) file: (user,repo, path, callback)-> path_safe = path.replace('/','_') @cacheService "file_#{user}_#{repo}_#{path_safe}", callback, (cache_callback) => - @github.repos.getContent user : user, repo: repo, path: path, (err, res)-> + @github.repos.getContent user : user, owner:user, repo: repo, path: path, (err, res)-> throw err if err asciiContent = new Buffer(res.content, 'base64').toString('ascii') cache_callback(asciiContent) diff --git a/src/services/TeamMentor-Service.coffee b/src/services/TeamMentor-Service.coffee index 7f54bed..e1fa231 100644 --- a/src/services/TeamMentor-Service.coffee +++ b/src/services/TeamMentor-Service.coffee @@ -8,7 +8,7 @@ class TeamMentor_Service @options = options || {} @name = @options.name || '_tm_data' @cacheService = new Cache_Service(@name) - @tmServer = @options.tmServer || 'https://tmdev01-uno.teammentor.net' + @tmServer = @options.tmServer || 'https://beta36.teammentor.net' @asmx = new TeamMentor_ASMX(@) @tmConfig_File = @options.tmConfig_File || null @tmConfig = null diff --git a/test/services/Cache-Service.test.coffee b/test/services/Cache-Service.test.coffee index a2fcbe0..da7fa99 100644 --- a/test/services/Cache-Service.test.coffee +++ b/test/services/Cache-Service.test.coffee @@ -90,7 +90,8 @@ describe 'services | test-Cache-Service |', -> $('title') .assert_Is_Object() $('title').html() .assert_Is('Error 404 (Not Found)!!1') response.statusCode.str() .assert_Is('404') - response.headers['x-xss-protection'].assert_Is('1; mode=block') + response.headers['content-type'] .assert_Is('text/html; charset=UTF-8') + response.headers['content-length'] .assert_Is_Number response.request.uri.hostname .assert_Is('www.google.co.uk') response.body .assert_Is(data) @@ -113,12 +114,13 @@ describe 'services | test-Cache-Service |', -> done() it 'json_POST', (done)-> - cacheService.json_POST 'https://teammentor.net/Aspx_Pages/TM_WebServices.asmx/Ping', {message: 'a'}, (json, response)-> + cacheService.json_POST 'https://www36.teammentor.net/Aspx_Pages/TM_WebServices.asmx/Ping', {message: 'a'}, (json, response)-> + (typeof(json) ) .assert_Is_Equal_To("object") (typeof(response)) .assert_Is_Equal_To("object") json.d .assert_Is('received ping: a') response.headers['x-xss-protection'].assert_Is('1; mode=block') - response.request.uri.hostname .assert_Is('teammentor.net') + response.request.uri.hostname .assert_Is('www36.teammentor.net') response.request.method .assert_Is('POST') done() diff --git a/test/services/GitHub-Service.test.coffee b/test/services/GitHub-Service.test.coffee index b92dddb..3f8b85c 100644 --- a/test/services/GitHub-Service.test.coffee +++ b/test/services/GitHub-Service.test.coffee @@ -47,6 +47,7 @@ describe 'services | test-GitHub-Service |', -> it 'rateLimit', (done)-> expect(gitHubService.rateLimit ).to.be.an('Function') + gitHubService.rateLimit (data)-> expect(data ).to.be.an('Object') expect(data.resources ).to.be.an('Object') @@ -62,10 +63,10 @@ describe 'services | test-GitHub-Service |', -> gistId = "ad328585205f67569e0d" gitHubService.gist_Raw gistId, (data)-> expect(data ).to.be.an('Object') - files = Object.keys(data.files) - expect(files).to.be.an("Array") - expect(files).to.contain('Search_Data_Validation.json' ) - expect(files).to.contain('Search_Input_Validation.json') + files = data.files + expect(files).to.be.an("Object") + expect(files).to.have.property(('Search_Data_Validation.json')) + expect(files).to.have.property(('Search_Input_Validation.json')) done() it 'gist_Raw (bad gistOd)', (done)-> diff --git a/test/services/TeamMentor-Service.test.coffee b/test/services/TeamMentor-Service.test.coffee index 35c0b68..52b3ab8 100644 --- a/test/services/TeamMentor-Service.test.coffee +++ b/test/services/TeamMentor-Service.test.coffee @@ -20,7 +20,7 @@ describe 'services | test-TeamMentor-Service |', -> @.name .assert_Is '_tm_data' @.name .assert_Is teamMentor.cacheService.area - @.tmServer .assert_Is 'https://tmdev01-uno.teammentor.net' + @.tmServer .assert_Is 'https://beta36.teammentor.net' @.tmConfig .assert_Is_Object() assert_Is_Null(@.tmConfig_File) From 4490015451dcd776a2838f1faca19d566cd1f565 Mon Sep 17 00:00:00 2001 From: Michael Hidalgo Date: Wed, 11 Jan 2017 18:15:29 -0600 Subject: [PATCH 2/2] Small fix on the uri.hostname --- test/services/Cache-Service.test.coffee | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/services/Cache-Service.test.coffee b/test/services/Cache-Service.test.coffee index da7fa99..b003d5e 100644 --- a/test/services/Cache-Service.test.coffee +++ b/test/services/Cache-Service.test.coffee @@ -114,13 +114,13 @@ describe 'services | test-Cache-Service |', -> done() it 'json_POST', (done)-> - cacheService.json_POST 'https://www36.teammentor.net/Aspx_Pages/TM_WebServices.asmx/Ping', {message: 'a'}, (json, response)-> + cacheService.json_POST 'https://beta36.teammentor.net/Aspx_Pages/TM_WebServices.asmx/Ping', {message: 'a'}, (json, response)-> (typeof(json) ) .assert_Is_Equal_To("object") (typeof(response)) .assert_Is_Equal_To("object") json.d .assert_Is('received ping: a') response.headers['x-xss-protection'].assert_Is('1; mode=block') - response.request.uri.hostname .assert_Is('www36.teammentor.net') + response.request.uri.hostname .assert_Is('beta36.teammentor.net') response.request.method .assert_Is('POST') done()