From 4f90ef2945bbd14022133a4f44cde4771980ee7f Mon Sep 17 00:00:00 2001 From: Mark Nyon Date: Sun, 1 Nov 2015 15:16:44 -0500 Subject: [PATCH 01/28] Added rollbar to app.js and #16 Initial addition of [Rollbar](https://rollbar.com) to the application. This baseline implementation adds a message upon server startup as well as handling any uncaught exceptions. - app.js - Added Rollbar with server side code from service. Added uncaught exception handler to log unexpected errors. Added code to link to Rollbar middleware. --- app.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/app.js b/app.js index d0254f769..99a399bc4 100644 --- a/app.js +++ b/app.js @@ -12,11 +12,18 @@ var config = require('./config'), passport = require('passport'), models = require('./models/index'), helmet = require('helmet'), + rollbar = require("rollbar"), csrf = require('csurf'); //create express app var app = express(); +// Rollbar initialization +rollbar.init("ba471954344648d490ea209ff586ae43"); + +// record a generic message and send to rollbar +rollbar.reportMessage("Rollbar started: " + Date.now()); + //keep reference to config app.config = config; @@ -35,6 +42,19 @@ app.set('view engine', 'jade'); app.use(require('morgan')('dev')); app.use(require('compression')()); app.use(require('serve-static')(path.join(__dirname, 'public'))); + +// Use the rollbar error handler to send exceptions to your rollbar account +app.use(rollbar.errorHandler('ba471954344648d490ea209ff586ae43')); + +var options = { + // Call process.exit(1) when an uncaught exception occurs but after reporting all + // pending errors to Rollbar. + // + // Default: false + exitOnUncaughtException: true +}; +rollbar.handleUncaughtExceptions("ba471954344648d490ea209ff586ae43", options); + app.use(require('method-override')()); app.use(bodyParser.json()); app.use(bodyParser.urlencoded({ extended: true })); From 123032cb899e982e7376f772e607428b881380b0 Mon Sep 17 00:00:00 2001 From: Mark Nyon Date: Fri, 29 Jan 2016 21:08:42 -0500 Subject: [PATCH 02/28] Changed test suite to use mocha for #10; WIP Update the test suite to use Mocha. This tests results in creation of the model objects in /models. The ultimate goal is to create unit tests that are not dependent upon the actual database, in order to enforce separation. - package.json - Changed the npm test command to use a test runner named `test.js` which starts mocha with some configuration options set. Also added other packages to be used with testing, including: * lodash * factory-girl * factory-girl-sequelize * faker - test.js - Test runner starting Mocha with standard options. - specs/index-spec.js - Old supertest based test that no longer applies. - specs/models/AccountSpec.js - Unit test that checks the functionality of the Accont model. - models/Account.js - Changed the jshint to use 4 spaces. --- models/Account.js | 2 +- package.json | 6 +++++- specs/index-spec.js | 33 -------------------------------- specs/models/AccountSpec.js | 26 +++++++++++++++++++++++++ test.js | 38 +++++++++++++++++++++++++++++++++++++ 5 files changed, 70 insertions(+), 35 deletions(-) delete mode 100644 specs/index-spec.js create mode 100644 specs/models/AccountSpec.js create mode 100644 test.js diff --git a/models/Account.js b/models/Account.js index 4758ec88b..d48bc0f3b 100644 --- a/models/Account.js +++ b/models/Account.js @@ -1,4 +1,4 @@ -/* jshint indent: 2 */ +/* jshint indent: 4 */ module.exports = function(sequelize, DataTypes) { return sequelize.define('Account', { diff --git a/package.json b/package.json index 43e496917..a035c9efb 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "private": true, "scripts": { "start": "grunt", - "test": "NODE_ENV=test mocha specs" + "test": "NODE_ENV=test node test.js" }, "dependencies": { "async": "^0.9.x", @@ -20,6 +20,7 @@ "express-session": "^1.11.3", "helmet": "^0.7.x", "jade": "^1.x.x", + "lodash": "^4.1.0", "method-override": "^2.x.x", "morgan": "^1.x.x", "passport": "^0.2.x", @@ -40,6 +41,9 @@ "bootstrap": "^3.x.x", "chai": "^3.2.0", "chai-as-promised": "^5.1.0", + "factory-girl": "^2.2.2", + "factory-girl-sequelize": "^1.0.0", + "faker": "^3.0.1", "font-awesome": "^4.1.0", "grunt": "^0.4.x", "grunt-cli": "^0.1.13", diff --git a/specs/index-spec.js b/specs/index-spec.js deleted file mode 100644 index 3c1cd9e47..000000000 --- a/specs/index-spec.js +++ /dev/null @@ -1,33 +0,0 @@ -/* Specs for the index.js route, the main route of the application. - * This app is currently using supertest, a module for express - * "unit" testing. I put "unit" in quotes because at this point, - * supertest walks and quacks like an integration test than a unit - * test. That being said, having integration automated tests serves - * us better than having no automated tests at all. - * - */ -var request = require('supertest'), - express = require('express'), - db = require('./../models', {logging:console.log}), - chai = require('chai'), - chaiAsPromised = require('chai-as-promised'); - -var expect = chai.expect; - -var app = require('../app.js'); - -describe("GET", function() { - it('responds with the drywall admin index HTML', function() { - try { - request(app) - .get('/') - .set('Accept', 'text/html') - .expect(200) - .end(function(err, res) { - expect(res.text).to.contain('Your Node.js website and user system is running'); - }); - } catch (error) { - console.log("ERROR: " + JSON.stringify(error)); - } - }); -}); diff --git a/specs/models/AccountSpec.js b/specs/models/AccountSpec.js new file mode 100644 index 000000000..47d9abfd6 --- /dev/null +++ b/specs/models/AccountSpec.js @@ -0,0 +1,26 @@ +var chai = require('chai'); +var expect = chai.expect; +var _ = require('lodash'); +var sinon = require('sinon'); +var faker = require('faker'); +var factory = require('factory-girl'); +var models = require(process.cwd() + '/models/index'); + + +describe('Models/Account', function () { + beforeEach(function (done) { + AccountModel = models.Account; + done(); + }); + + afterEach(function (done) { + AccountModel = models.Account; + done(); + }); + + describe('account', function () { + it('should be true', function () { + expect(models.Account).to.be.an('object'); + }); + }); +}); \ No newline at end of file diff --git a/test.js b/test.js new file mode 100644 index 000000000..f0cbe4b4c --- /dev/null +++ b/test.js @@ -0,0 +1,38 @@ +var _ = require('lodash'); +var Mocha = require('mocha'); +var fs = require('fs'); +var path = require('path'); + +var testConfig = { + NODE_ENV: 'test' +}; + +_.each(testConfig, function(value, key){ + process.env[key] = value; +}); + +var mocha = new Mocha({ + timeout: 60000, + reporter: "spec" +}); + +["specs/models"].forEach(function(pathName){ + // Here is an example: + fs.readdirSync(pathName).filter(function(file){ + // Only keep the .js files + return file.substr(-3) === '.js'; + + }).forEach(function(file){ + mocha.addFile( + path.join(pathName, file) + ); + }); +}); + +mocha.run(function(failures){ + process.on('exit', function () { + process.exit(failures); + }); + + process.exit(0); +}); \ No newline at end of file From 3fe2a70f2b90bc1efb22324a1c0a312cab988f65 Mon Sep 17 00:00:00 2001 From: Mark Nyon Date: Fri, 29 Jan 2016 21:20:57 -0500 Subject: [PATCH 03/28] Updated node version for Travis; #10 Updated to use latest LTS and Stable versions of Node --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 0bcd56863..5f40479e6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,6 @@ language: node_js node_js: - - "0.12" - - "iojs" + - "4.2.6" + - "5.5.0" addons: postgresql: 9.4 \ No newline at end of file From 675ca7c54686b2858692f988de6bf8dfd4cab149 Mon Sep 17 00:00:00 2001 From: Mark Nyon Date: Fri, 29 Jan 2016 21:25:44 -0500 Subject: [PATCH 04/28] updated GCC options for compiling bcrypt; #10 Adds an option to compile bcrypt so that it can compile successfully. This is based on the bug entered at: https://github.com/travis-ci/travis-ci/issues/4771 --- .travis.yml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 5f40479e6..5ba9f2148 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,4 +3,12 @@ node_js: - "4.2.6" - "5.5.0" addons: - postgresql: 9.4 \ No newline at end of file + postgresql: 9.4 + apt: + sources: + - ubuntu-toolchain-r-test + packages: + - gcc-4.8 + - g++-4.8 +env: + - TRAVIS=travis CXX=g++-4.8 \ No newline at end of file From 8ea35cd4d2ccffe305f78310438fa9774fad9f16 Mon Sep 17 00:00:00 2001 From: Mark Nyon Date: Fri, 29 Jan 2016 21:40:05 -0500 Subject: [PATCH 05/28] Testing out setupTestDatabases.sh; #10 - .travis.yml - Added call to setupTestDatabases.sh in before_script - bin/setupTestDatabases.sh - Proof of concept that echoes "Running Test Database Script" --- .travis.yml | 6 ++++-- bin/setupTestDatabases.sh | 5 +++++ 2 files changed, 9 insertions(+), 2 deletions(-) create mode 100644 bin/setupTestDatabases.sh diff --git a/.travis.yml b/.travis.yml index 5ba9f2148..986ed644b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,7 +3,7 @@ node_js: - "4.2.6" - "5.5.0" addons: - postgresql: 9.4 + postgresql: 9.5 apt: sources: - ubuntu-toolchain-r-test @@ -11,4 +11,6 @@ addons: - gcc-4.8 - g++-4.8 env: - - TRAVIS=travis CXX=g++-4.8 \ No newline at end of file + - TRAVIS=travis CXX=g++-4.8 +before_script: + - ./bin/setupTestDatabases.sh diff --git a/bin/setupTestDatabases.sh b/bin/setupTestDatabases.sh new file mode 100644 index 000000000..7c6ceca35 --- /dev/null +++ b/bin/setupTestDatabases.sh @@ -0,0 +1,5 @@ +#!/bin/sh +# +# +#cp config/config.json.tmpl config/config.json +echo "Running Test Database Script" \ No newline at end of file From 2637df35c066b3e02c15a5275acdb93a0f0f3e8b Mon Sep 17 00:00:00 2001 From: Mark Nyon Date: Fri, 29 Jan 2016 21:43:18 -0500 Subject: [PATCH 06/28] changed tab to spaces; #10 - .travis.yml - changed tab to space --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 986ed644b..1eb138543 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,4 +13,4 @@ addons: env: - TRAVIS=travis CXX=g++-4.8 before_script: - - ./bin/setupTestDatabases.sh + - ./bin/setupTestDatabases.sh From 7c6087df9d5fbae975e09c03f0150c4a987b2480 Mon Sep 17 00:00:00 2001 From: Mark Nyon Date: Fri, 29 Jan 2016 21:48:14 -0500 Subject: [PATCH 07/28] Made startup script executable: #10 - .travis.yml - Made the setup test executable and then run it --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 1eb138543..3d79992f7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,4 +13,4 @@ addons: env: - TRAVIS=travis CXX=g++-4.8 before_script: - - ./bin/setupTestDatabases.sh + - chmod +x bin/setupTestDatabases.sh; ./bin/setupTestDatabases.sh From 4e7b830c603b84d401cb50aaf0ca9083d53a26d5 Mon Sep 17 00:00:00 2001 From: Mark Nyon Date: Fri, 29 Jan 2016 22:06:35 -0500 Subject: [PATCH 08/28] Continuous Integration Database Setup; #10 - bin/setupTestDatabases.sh - Copy config.json.tmpl to config.json create a test database and update the username & password database to match the newly created database. --- bin/setupTestDatabases.sh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/bin/setupTestDatabases.sh b/bin/setupTestDatabases.sh index 7c6ceca35..6e0378b58 100644 --- a/bin/setupTestDatabases.sh +++ b/bin/setupTestDatabases.sh @@ -1,5 +1,7 @@ #!/bin/sh -# -# -#cp config/config.json.tmpl config/config.json -echo "Running Test Database Script" \ No newline at end of file +# Script used to create & set up the test database for Continuous Integration +psql -c 'create database drywall-test;' -U postgres +cp config/config.json.tmpl config/config.json # Copy template file to template +sed -i -- 's/"_INSERT USERNAME_"/postgres/g' config/config.json # change username for db +sed -i -- 's/"_INSERT PASSWORD_"//g' config/config.json # change password for db +#echo "Running Test Database Script" From 844e73b2f3f3414b0e18d7d1d5e071e71e186230 Mon Sep 17 00:00:00 2001 From: Mark Nyon Date: Fri, 29 Jan 2016 22:11:26 -0500 Subject: [PATCH 09/28] Updated script to show template output; #10 --- bin/setupTestDatabases.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/bin/setupTestDatabases.sh b/bin/setupTestDatabases.sh index 6e0378b58..f04312f7a 100644 --- a/bin/setupTestDatabases.sh +++ b/bin/setupTestDatabases.sh @@ -1,7 +1,6 @@ #!/bin/sh # Script used to create & set up the test database for Continuous Integration -psql -c 'create database drywall-test;' -U postgres cp config/config.json.tmpl config/config.json # Copy template file to template sed -i -- 's/"_INSERT USERNAME_"/postgres/g' config/config.json # change username for db sed -i -- 's/"_INSERT PASSWORD_"//g' config/config.json # change password for db -#echo "Running Test Database Script" +echo config/config.json From 739c312a91a5b4dfc58eab9b00cbc80b6a4c8205 Mon Sep 17 00:00:00 2001 From: Mark Nyon Date: Fri, 29 Jan 2016 22:13:51 -0500 Subject: [PATCH 10/28] Changed echo to cat #10 --- bin/setupTestDatabases.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/setupTestDatabases.sh b/bin/setupTestDatabases.sh index f04312f7a..a8cc4d9d8 100644 --- a/bin/setupTestDatabases.sh +++ b/bin/setupTestDatabases.sh @@ -3,4 +3,4 @@ cp config/config.json.tmpl config/config.json # Copy template file to template sed -i -- 's/"_INSERT USERNAME_"/postgres/g' config/config.json # change username for db sed -i -- 's/"_INSERT PASSWORD_"//g' config/config.json # change password for db -echo config/config.json +cat config/config.json From da902a65ab7b584555a6194dc2d653afac0bda2e Mon Sep 17 00:00:00 2001 From: Mark Nyon Date: Fri, 29 Jan 2016 22:15:59 -0500 Subject: [PATCH 11/28] Quoted replacement values - bin/setupTestDatabases.sh - Updated sed commands to quote replacement values. --- bin/setupTestDatabases.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/setupTestDatabases.sh b/bin/setupTestDatabases.sh index a8cc4d9d8..f0fe47109 100644 --- a/bin/setupTestDatabases.sh +++ b/bin/setupTestDatabases.sh @@ -1,6 +1,6 @@ #!/bin/sh # Script used to create & set up the test database for Continuous Integration cp config/config.json.tmpl config/config.json # Copy template file to template -sed -i -- 's/"_INSERT USERNAME_"/postgres/g' config/config.json # change username for db -sed -i -- 's/"_INSERT PASSWORD_"//g' config/config.json # change password for db +sed -i -- 's/"_INSERT USERNAME_"/"postgres"/g' config/config.json # change username for db +sed -i -- 's/"_INSERT PASSWORD_"/""/g' config/config.json # change password for db cat config/config.json From a078e684d486ce6ea3916a5b52daa06fd919aad3 Mon Sep 17 00:00:00 2001 From: Mark Nyon Date: Fri, 29 Jan 2016 22:29:09 -0500 Subject: [PATCH 12/28] Manually create database; #10 --- bin/setupTestDatabases.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/bin/setupTestDatabases.sh b/bin/setupTestDatabases.sh index f0fe47109..1ccb97ff2 100644 --- a/bin/setupTestDatabases.sh +++ b/bin/setupTestDatabases.sh @@ -3,4 +3,6 @@ cp config/config.json.tmpl config/config.json # Copy template file to template sed -i -- 's/"_INSERT USERNAME_"/"postgres"/g' config/config.json # change username for db sed -i -- 's/"_INSERT PASSWORD_"/""/g' config/config.json # change password for db +if [ '$DB' = 'pgsql' ]; then psql -c 'DROP DATABASE IF EXISTS drywall-test;' -U postgres; fi +if [ '$DB' = 'pgsql' ]; then psql -c 'create database drywall-test;' -U postgres; fi cat config/config.json From 70ae68b0c1bfffbf17810d711aeb9383c93a8f91 Mon Sep 17 00:00:00 2001 From: Mark Nyon Date: Fri, 29 Jan 2016 22:33:07 -0500 Subject: [PATCH 13/28] Changed "127.0.0.1" to "localhost"; #10 --- config/config.json.tmpl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/config/config.json.tmpl b/config/config.json.tmpl index f54eda1a9..07d25b1f0 100644 --- a/config/config.json.tmpl +++ b/config/config.json.tmpl @@ -3,7 +3,7 @@ "username": "_INSERT USERNAME_", "password": "_INSERT PASSWORD_", "database": "drywall-development", - "host": "127.0.0.1", + "host": "localhost", "dialect": "postgres", "_comment_": ["Comment out the 'logging' line below to get SQL etc", "console logging. See also the 'Options' section of", @@ -14,14 +14,14 @@ "username": "_INSERT USERNAME_", "password": "_INSERT PASSWORD_", "database": "drywall-test", - "host": "127.0.0.1", + "host": "localhost", "dialect": "postgres" }, "production": { "username": "_INSERT USERNAME_", "password": "_INSERT PASSWORD_", "database": "drywall-production", - "host": "127.0.0.1", + "host": "localhost", "dialect": "postgres" } } From b4efa3312de7686a1e0c2406ad3a39ed203a1ef2 Mon Sep 17 00:00:00 2001 From: Mark Nyon Date: Fri, 29 Jan 2016 22:36:41 -0500 Subject: [PATCH 14/28] Added diagnostics to account spec #10 Added a console.log to the account spec --- specs/models/AccountSpec.js | 1 + 1 file changed, 1 insertion(+) diff --git a/specs/models/AccountSpec.js b/specs/models/AccountSpec.js index 47d9abfd6..2f654b64e 100644 --- a/specs/models/AccountSpec.js +++ b/specs/models/AccountSpec.js @@ -20,6 +20,7 @@ describe('Models/Account', function () { describe('account', function () { it('should be true', function () { + console.log("models.Account = " + models.Account); expect(models.Account).to.be.an('object'); }); }); From 89ff9b7a626d0e20daf56e343b2f56c13b21fd6d Mon Sep 17 00:00:00 2001 From: Mark Nyon Date: Fri, 29 Jan 2016 22:40:49 -0500 Subject: [PATCH 15/28] Remove console.log from AccountSpec; #10 - specs/models/AccountSpec.js - Removed unused spec from Account.js --- specs/models/AccountSpec.js | 1 - 1 file changed, 1 deletion(-) diff --git a/specs/models/AccountSpec.js b/specs/models/AccountSpec.js index 2f654b64e..47d9abfd6 100644 --- a/specs/models/AccountSpec.js +++ b/specs/models/AccountSpec.js @@ -20,7 +20,6 @@ describe('Models/Account', function () { describe('account', function () { it('should be true', function () { - console.log("models.Account = " + models.Account); expect(models.Account).to.be.an('object'); }); }); From 615c0f41bd7ea64291973d1aec2ef1d3c349bcbd Mon Sep 17 00:00:00 2001 From: Mark Nyon Date: Fri, 29 Jan 2016 23:18:38 -0500 Subject: [PATCH 16/28] Added CodeClimate badge to the README.md; #20 --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 1aecb9987..44d6442f7 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,6 @@ # Drywall +[![Code Climate](https://codeclimate.com/github/trystant/drywall/badges/gpa.svg)](https://codeclimate.com/github/trystant/drywall) A website and user system starter. Implemented with Express and Backbone. This fork uses sequelize to connect to Relational Database Management Systems instead of using Mongoose to connect to Mongo From 087ef6f153d2d084615a20cc8711b50caefd1a93 Mon Sep 17 00:00:00 2001 From: Mark Nyon Date: Fri, 29 Jan 2016 23:30:23 -0500 Subject: [PATCH 17/28] Added Code Climate badge; #20 - Added Code Climae badge for the repo. --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 44d6442f7..231145d3a 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ # Drywall [![Code Climate](https://codeclimate.com/github/trystant/drywall/badges/gpa.svg)](https://codeclimate.com/github/trystant/drywall) + A website and user system starter. Implemented with Express and Backbone. This fork uses sequelize to connect to Relational Database Management Systems instead of using Mongoose to connect to Mongo From cfbbc8e5d8e37cbde85ded74cf58eca4e3d18c9c Mon Sep 17 00:00:00 2001 From: Mark Nyon Date: Fri, 29 Jan 2016 23:32:16 -0500 Subject: [PATCH 18/28] Added istanbul & configured for test coverage; #20 - bin/setupTestDatabases.sh - Added codeclimate repo token to capture lcov information from istanbul - package.json - added codeclimate-test-reporter and istanbul packages to the repo --- bin/setupTestDatabases.sh | 4 +++- package.json | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/bin/setupTestDatabases.sh b/bin/setupTestDatabases.sh index 1ccb97ff2..f0adf9ffd 100644 --- a/bin/setupTestDatabases.sh +++ b/bin/setupTestDatabases.sh @@ -3,6 +3,8 @@ cp config/config.json.tmpl config/config.json # Copy template file to template sed -i -- 's/"_INSERT USERNAME_"/"postgres"/g' config/config.json # change username for db sed -i -- 's/"_INSERT PASSWORD_"/""/g' config/config.json # change password for db +# Drop and create the test database if [ '$DB' = 'pgsql' ]; then psql -c 'DROP DATABASE IF EXISTS drywall-test;' -U postgres; fi if [ '$DB' = 'pgsql' ]; then psql -c 'create database drywall-test;' -U postgres; fi -cat config/config.json +# set up Codeclimate to be run on the codebase +CODECLIMATE_REPO_TOKEN=d59a2529d82564323b652ad2e84bfc4b477270f97207045fd7cd03d38d50ef22 codeclimate-test-reporter < coverage/lcov.info diff --git a/package.json b/package.json index a035c9efb..54a71b1f6 100644 --- a/package.json +++ b/package.json @@ -41,6 +41,7 @@ "bootstrap": "^3.x.x", "chai": "^3.2.0", "chai-as-promised": "^5.1.0", + "codeclimate-test-reporter": "^0.3.0", "factory-girl": "^2.2.2", "factory-girl-sequelize": "^1.0.0", "faker": "^3.0.1", @@ -58,6 +59,7 @@ "grunt-nodemon": "^0.4.x", "grunt-sequelize-fixtures": "^0.1.0", "html5shiv": "^3.x.x", + "istanbul": "^0.4.2", "jquery": "^2.x.x", "jquery.cookie": "^1.x.x", "mocha": "^2.3.0", From 41616de773cff1b0474fcfc669a30d7a9a2b0f9e Mon Sep 17 00:00:00 2001 From: Mark Nyon Date: Fri, 29 Jan 2016 23:39:52 -0500 Subject: [PATCH 19/28] Added config variables to help test coverage; #20 - .codeclimate.yml - Added default config from Code Climate - .travis.yml - Explicitly set db to pg --- .codeclimate.yml | 6 ++++++ .travis.yml | 3 +++ 2 files changed, 9 insertions(+) create mode 100644 .codeclimate.yml diff --git a/.codeclimate.yml b/.codeclimate.yml new file mode 100644 index 000000000..cf4586090 --- /dev/null +++ b/.codeclimate.yml @@ -0,0 +1,6 @@ +engines: + duplication: + enabled: true + config: + languages: + - javascript \ No newline at end of file diff --git a/.travis.yml b/.travis.yml index 3d79992f7..24c8589c7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,6 +2,9 @@ language: node_js node_js: - "4.2.6" - "5.5.0" + +env: + - DB=pgsql addons: postgresql: 9.5 apt: From 2b9bcf57d5ae1467b6f7fd740a844a0a18a8c855 Mon Sep 17 00:00:00 2001 From: Mark Nyon Date: Sat, 30 Jan 2016 00:03:26 -0500 Subject: [PATCH 20/28] Added commands to generate lcov data; #20 - bin/setupTestDatabases.sh - Added commands to install NPM modules so that istanbul can generate the coverage data needed by Code Climate --- bin/setupTestDatabases.sh | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/bin/setupTestDatabases.sh b/bin/setupTestDatabases.sh index f0adf9ffd..434952327 100644 --- a/bin/setupTestDatabases.sh +++ b/bin/setupTestDatabases.sh @@ -3,8 +3,16 @@ cp config/config.json.tmpl config/config.json # Copy template file to template sed -i -- 's/"_INSERT USERNAME_"/"postgres"/g' config/config.json # change username for db sed -i -- 's/"_INSERT PASSWORD_"/""/g' config/config.json # change password for db + # Drop and create the test database if [ '$DB' = 'pgsql' ]; then psql -c 'DROP DATABASE IF EXISTS drywall-test;' -U postgres; fi if [ '$DB' = 'pgsql' ]; then psql -c 'create database drywall-test;' -U postgres; fi -# set up Codeclimate to be run on the codebase -CODECLIMATE_REPO_TOKEN=d59a2529d82564323b652ad2e84bfc4b477270f97207045fd7cd03d38d50ef22 codeclimate-test-reporter < coverage/lcov.info + +# Run the code test coverage script. Install istanbul & mocha to run +# the script to create the lcov files. +npm install -g istanbul +npm install -g mocha +npm install -g codeclimate-test-reporter +istanbul cover test.js +codeclimate-test-reporter < lcov.info + From 2a44b4ee31f130a886fc2a7ab3cb75e0e2b688b1 Mon Sep 17 00:00:00 2001 From: Mark Nyon Date: Sat, 30 Jan 2016 00:10:05 -0500 Subject: [PATCH 21/28] Changed lcov.info location for code climate; #20 - bin/setupTestDatabases.sh - Changed the location of the lcov.info file to under the /coverage directory --- bin/setupTestDatabases.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/setupTestDatabases.sh b/bin/setupTestDatabases.sh index 434952327..5099aac63 100644 --- a/bin/setupTestDatabases.sh +++ b/bin/setupTestDatabases.sh @@ -14,5 +14,5 @@ npm install -g istanbul npm install -g mocha npm install -g codeclimate-test-reporter istanbul cover test.js -codeclimate-test-reporter < lcov.info +codeclimate-test-reporter < coverage/lcov.info From 1376d390fa2bc3ee2c30503b9ed9d31eda1956cf Mon Sep 17 00:00:00 2001 From: Mark Nyon Date: Sat, 30 Jan 2016 00:15:41 -0500 Subject: [PATCH 22/28] Updated README.md and removed unused code; #20 --- README.md | 4 ---- 1 file changed, 4 deletions(-) diff --git a/README.md b/README.md index 231145d3a..2e1a36740 100644 --- a/README.md +++ b/README.md @@ -6,10 +6,6 @@ A website and user system starter. Implemented with Express and Backbone. This fork uses sequelize to connect to Relational Database Management Systems instead of using Mongoose to connect to Mongo -[![Dependency Status](https://david-dm.org/jedireza/drywall.svg?theme=shields.io)](https://david-dm.org/jedireza/drywall) -[![devDependency Status](https://david-dm.org/jedireza/drywall/dev-status.svg?theme=shields.io)](https://david-dm.org/jedireza/drywall#info=devDependencies) - - ## Technology Server side, Drywall is built with the [Express](http://expressjs.com/) From ad5900ba3fee6c1b2b5c7a97155cb1e609d7c75d Mon Sep 17 00:00:00 2001 From: Mark Nyon Date: Sat, 30 Jan 2016 00:17:12 -0500 Subject: [PATCH 23/28] Changed Markdown version to HTML for README.md #20 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 2e1a36740..ff94a5bba 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Drywall -[![Code Climate](https://codeclimate.com/github/trystant/drywall/badges/gpa.svg)](https://codeclimate.com/github/trystant/drywall) + A website and user system starter. Implemented with Express and Backbone. From 093f502eec1353e6d97ff89f831c2074c5f5dbf1 Mon Sep 17 00:00:00 2001 From: Mark Nyon Date: Sat, 30 Jan 2016 00:25:00 -0500 Subject: [PATCH 24/28] Added codeclimate test coverage badge; #20 Added code climate test coverage badge to the README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ff94a5bba..0e7bd2fd7 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # Drywall - + A website and user system starter. Implemented with Express and Backbone. This fork uses sequelize to connect to Relational Database Management Systems instead of using Mongoose to connect to Mongo From 2ba9a54fd696de61dc7e8a7c5d627d8f9b5cd0b2 Mon Sep 17 00:00:00 2001 From: Mark Nyon Date: Sat, 30 Jan 2016 21:13:24 -0500 Subject: [PATCH 25/28] Updated README to remove supertest - README.md - Testing section now doesn't include supertest and refers to unit testing explicitly. This will change as the testing strategy is defined. --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 0e7bd2fd7..4949416e2 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,7 @@ + A website and user system starter. Implemented with Express and Backbone. This fork uses sequelize to connect to Relational Database Management Systems instead of using Mongoose to connect to Mongo From a50c13d97702785cfaa04b720243b8024bd5d9ae Mon Sep 17 00:00:00 2001 From: Mark Nyon Date: Sat, 30 Jan 2016 23:15:54 -0500 Subject: [PATCH 26/28] Updated README.md with testing info - README.md - Updated testing data --- README.md | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 4949416e2..4bba87750 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ We're using [Grunt](http://gruntjs.com/) for the asset pipeline. | Passport | Underscore.js | | | Async | Font-Awesome | | | EmailJS | Moment.js | | -| Postgres | | | +| Postgres | | | ## Live demo @@ -116,9 +116,8 @@ Login. Customize. Enjoy. ## Testing -The test suite uses [mochajs](https://mochajs.org) and [supertest] -(https://github.com/visionmedia/supertest) to execute end to end -testing. The suite can be executed using the command `npm test` +The test suite uses [mochajs](https://mochajs.org) for unit testing. +The suite can be executed using the command `npm test` from the top level of the project. ## Philosophy From 1d439af5cac93b991abe2914fca5ae8527c0e7f0 Mon Sep 17 00:00:00 2001 From: Mark Nyon Date: Wed, 23 Mar 2016 13:20:38 -0400 Subject: [PATCH 27/28] Updated README.md installation process - README.md - Updated the Installation process to include both config files with details on information in each file. --- README.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 4bba87750..b24cd07e9 100644 --- a/README.md +++ b/README.md @@ -62,9 +62,14 @@ $ npm install First you need to setup your config file. ```bash -$ mv ./config.example.js ./config.js #set database and email credentials +$ mv ./config/config.json.tmpl ./config/config.json # this file contains database credentials +$ mv ./config.js.tmpl ./config.js # this file contains drywall configuration parameters ``` +Next, create the desired databases using psql or your favorite database agent. +drywall-development and drywall-test are the default names in the `config/config.json` file, +but those can be changed to whatever is desired. + Next, you need a few records in the database to start using the user system. The code below should serve as pseudocode for adding a default admin user to the database, as opposed to exact instructions. From a39d7300cd7466a389d6cb269d56f3c3670d2e37 Mon Sep 17 00:00:00 2001 From: Mark Nyon Date: Wed, 23 Mar 2016 13:36:50 -0400 Subject: [PATCH 28/28] Updated Postgres system requirement for #22 - README.md - Explicitly set the Postgres version requirement to 9.3 based upon its support for JSON data types. --- README.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index b24cd07e9..0cfbdba29 100644 --- a/README.md +++ b/README.md @@ -39,9 +39,8 @@ order to keep the app ready to use at all times. ## Requirements -You need [Node.js](http://nodejs.org/download/) and a Relational Database -Management System such as [Postgres](http://www.postgresql.org/download) -installed and running. +You need [Node.js](http://nodejs.org/download/) and [Postgres](http://www.postgresql.org/download) +9.3 or higher installed and running. We use [`bcrypt`](https://github.com/ncb000gt/node.bcrypt.js) for hashing secrets. If you have issues during installation related to `bcrypt` then [refer