diff --git a/.gitignore b/.gitignore index daa6029..b7058f7 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ test.js +node_modules diff --git a/Gruntfile.js b/Gruntfile.js new file mode 100644 index 0000000..4f4dca9 --- /dev/null +++ b/Gruntfile.js @@ -0,0 +1,22 @@ +module.exports = function (grunt) { + grunt.initConfig({ + tape: { + options: { + pretty: false, + output: 'console' + }, + files: ['test/**/*.js'] + }, + watch: { + files: ['./supermodel.js', 'test/**/*.js'], + tasks: ['tape'], + } + }); + // Enable plugins + grunt.loadNpmTasks('grunt-tape'); + grunt.loadNpmTasks('grunt-contrib-watch'); + // register tasks + grunt.registerTask('test', ['tape']); + // default task + grunt.registerTask('default', ['test']); +}; diff --git a/README.md b/README.md index 1120c53..4e1a258 100644 --- a/README.md +++ b/README.md @@ -4,3 +4,14 @@ Please see [pathable.github.com/supermodel][supermodel] for documentation. [supermodel]: http://pathable.github.com/supermodel [ci]: https://ci.testling.com/pathable/supermodel + + +## How to contribute + +* Fork this repository on GitHub +* Make sure you have [npm installed](https://www.npmjs.org/) +* Run `npm install` in the root directory +* Run the test suite with `grunt test` +* Write failing test +* Fix the test +* Submit a pull request diff --git a/package.json b/package.json index e58bb15..6904edd 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,10 @@ "uglify-js": "~2.4.11", "tape": "~2.4.2", "browserify": "~3.23.1", - "faucet": "0.0.0" + "faucet": "0.0.0", + "grunt": "~0.4.5", + "grunt-tape": "0.0.2", + "grunt-contrib-watch": "~0.6.1" }, "testling": { "files": "test/*.js", diff --git a/test/has.js b/test/has.js index fa3ae5f..75c90e7 100644 --- a/test/has.js +++ b/test/has.js @@ -316,6 +316,13 @@ test('Many is initialized only once.', function(t) { t.end(); }); +test('has.One and has.Many should play nicly together', function(t) { + var user = User.create({id: 1}); + var memberships = user.memberships().add({id: 1, user_id: 1}) + t.is(user.memberships().length, 1); + t.end(); +}); + test('Source is removed after parsing.', function(t) { var user = User.create(); user.parse({memberships: [{id: 1}, {id: 2, hidden: true}]});