{"action":"created","comment":{"url":"https://api.github.com/repos/pskucherov/learning/pulls/comments/70482973","id":70482973,"diff_hunk":"@@ -1,51 +1,106 @@\n var chai = require('chai'),\n-    chaiAsPromised = require('chai-as-promised'),\n-    assert = chai.assert,\n-    path = require('path');\n+    chaiAsPromised = require('chai-as-promised');\n \n chai.use(chaiAsPromised);\n \n-var appDir = path.resolve(__dirname, '../../../common.blocks/app'),\n-    models = require(path.join(appDir, 'models')),\n-    Consultor = require(path.join(appDir, 'controllers/Consultor'));\n+var assert = chai.assert,\n+    _ = require('lodash'),\n+    path = require('path'),\n+    vow = require('vow');\n \n-describe('Controller: Consultor', function () {\n+var appDir = './common.blocks/app/',\n+    models = require(path.resolve(appDir + 'models/')),\n+    Consultor = require(path.resolve(appDir + 'controllers/Consultor'));\n+    User = require(path.resolve(appDir + 'controllers/User'));\n \n-    var consultorModel;\n+models(function (err, db) {\n+    if (err) throw err;\n \n-    before(function() {\n-        return new Promise((resolve, reject) => {\n-            models(function (err, db) {\n-                if (err) throw reject(err);\n+    db.sync(function (err) {\n+        if (err) throw err;\n \n-                db.sync(function (err) {\n-                    if (err) throw reject(err);\n-                    resolve(db.models['s-consultor']);\n-                });\n+        var VK_USER_ID = 100,\n+            usersModel = db.models['users'],\n+            consultorModel = db.models['s-consultor'];\n \n-            });\n-        }).then((model) => consultorModel = model);\n-    });\n+        describe('Controller: Consultor', function () {\n \n-    beforeEach(function() {\n-        return new Promise((resolve, reject) => {\n-            consultorModel.find().remove(function(err) {\n-                if (err) {\n-                    reject(err);\n-                }\n-                resolve();\n+            before(function (done) {\n+                this.timeout(10000);\n+                User.deleteByVKId(usersModel, VK_USER_ID).then(function () {\n+                    done();\n+                });\n+            });\n+            beforeEach(function (done) {\n+                this.timeout(10000);\n+                consultorModel.find().remove(function () {\n+                    done();\n+                });\n             });\n-        });\n-    });\n \n-    describe('create', function() {\n-        it('should create question', function () {\n-            var question = 'What\\'s up?',\n-                userId = 'a12345678901';\n+            describe('Create consultor', function () {\n+                it('should create consultor', function () {\n+                    var defered = vow.defer(),\n+                        question = 'Test question one',\n+                        userId = 'a12345678901';\n \n-            return Consultor\n-                .create(consultorModel, question, userId)\n-                .then((data) => assert.equal(data.question, question));\n+                    Consultor.create(consultorModel, question, userId)\n+                        .then(function (data) {\n+                            defered.resolve(data);\n+                        });\n+\n+                        return assert.isFulfilled(\n+                            defered.promise(),\n+                            'Should be resolved'\n+                        );\n+                });\n+\n+                it('should get all questions', function () {\n+                    var defered = vow.defer(),\n+                        question = 'Test question two';\n+\n+                    User.createByVKId(usersModel, VK_USER_ID)\n+                        .then(function () {\n+                            User.getByVKId(usersModel, VK_USER_ID)\n+                                .then(function (data) {\n+                                    defered.resolve(data);","path":"test/unit/controllers/Consultor.js","position":101,"original_position":101,"commit_id":"b11c0e26d8035a805f9972a2ebbd724742f5b512","original_commit_id":"b11c0e26d8035a805f9972a2ebbd724742f5b512","user":{"login":"pskucherov","id":3197868,"avatar_url":"https://avatars.githubusercontent.com/u/3197868?v=3","gravatar_id":"","url":"https://api.github.com/users/pskucherov","html_url":"https://github.com/pskucherov","followers_url":"https://api.github.com/users/pskucherov/followers","following_url":"https://api.github.com/users/pskucherov/following{/other_user}","gists_url":"https://api.github.com/users/pskucherov/gists{/gist_id}","starred_url":"https://api.github.com/users/pskucherov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pskucherov/subscriptions","organizations_url":"https://api.github.com/users/pskucherov/orgs","repos_url":"https://api.github.com/users/pskucherov/repos","events_url":"https://api.github.com/users/pskucherov/events{/privacy}","received_events_url":"https://api.github.com/users/pskucherov/received_events","type":"User","site_admin":false},"body":"два резолва у одно и того же промиса быть не может,  уберите этот \r\n\r\nи `deferred` пишется с двумя r","created_at":"2016-07-12T17:29:52Z","updated_at":"2016-07-12T17:29:52Z","html_url":"https://github.com/pskucherov/learning/pull/11#discussion_r70482973","pull_request_url":"https://api.github.com/repos/pskucherov/learning/pulls/11","_links":{"self":{"href":"https://api.github.com/repos/pskucherov/learning/pulls/comments/70482973"},"html":{"href":"https://github.com/pskucherov/learning/pull/11#discussion_r70482973"},"pull_request":{"href":"https://api.github.com/repos/pskucherov/learning/pulls/11"}}},"pull_request":{"url":"https://api.github.com/repos/pskucherov/learning/pulls/11","id":77011813,"html_url":"https://github.com/pskucherov/learning/pull/11","diff_url":"https://github.com/pskucherov/learning/pull/11.diff","patch_url":"https://github.com/pskucherov/learning/pull/11.patch","issue_url":"https://api.github.com/repos/pskucherov/learning/issues/11","number":11,"state":"open","locked":false,"title":"Add test for controller Consultor etc.","user":{"login":"blisnec","id":8180606,"avatar_url":"https://avatars.githubusercontent.com/u/8180606?v=3","gravatar_id":"","url":"https://api.github.com/users/blisnec","html_url":"https://github.com/blisnec","followers_url":"https://api.github.com/users/blisnec/followers","following_url":"https://api.github.com/users/blisnec/following{/other_user}","gists_url":"https://api.github.com/users/blisnec/gists{/gist_id}","starred_url":"https://api.github.com/users/blisnec/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/blisnec/subscriptions","organizations_url":"https://api.github.com/users/blisnec/orgs","repos_url":"https://api.github.com/users/blisnec/repos","events_url":"https://api.github.com/users/blisnec/events{/privacy}","received_events_url":"https://api.github.com/users/blisnec/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-07-11T19:47:54Z","updated_at":"2016-07-12T17:29:52Z","closed_at":null,"merged_at":null,"merge_commit_sha":"8cf2b87fc7f8a11bc586bcb58ba04fcee141db71","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/pskucherov/learning/pulls/11/commits","review_comments_url":"https://api.github.com/repos/pskucherov/learning/pulls/11/comments","review_comment_url":"https://api.github.com/repos/pskucherov/learning/pulls/comments{/number}","comments_url":"https://api.github.com/repos/pskucherov/learning/issues/11/comments","statuses_url":"https://api.github.com/repos/pskucherov/learning/statuses/b11c0e26d8035a805f9972a2ebbd724742f5b512","head":{"label":"pskucherov:test_consultor","ref":"test_consultor","sha":"b11c0e26d8035a805f9972a2ebbd724742f5b512","user":{"login":"pskucherov","id":3197868,"avatar_url":"https://avatars.githubusercontent.com/u/3197868?v=3","gravatar_id":"","url":"https://api.github.com/users/pskucherov","html_url":"https://github.com/pskucherov","followers_url":"https://api.github.com/users/pskucherov/followers","following_url":"https://api.github.com/users/pskucherov/following{/other_user}","gists_url":"https://api.github.com/users/pskucherov/gists{/gist_id}","starred_url":"https://api.github.com/users/pskucherov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pskucherov/subscriptions","organizations_url":"https://api.github.com/users/pskucherov/orgs","repos_url":"https://api.github.com/users/pskucherov/repos","events_url":"https://api.github.com/users/pskucherov/events{/privacy}","received_events_url":"https://api.github.com/users/pskucherov/received_events","type":"User","site_admin":false},"repo":{"id":34578238,"name":"learning","full_name":"pskucherov/learning","owner":{"login":"pskucherov","id":3197868,"avatar_url":"https://avatars.githubusercontent.com/u/3197868?v=3","gravatar_id":"","url":"https://api.github.com/users/pskucherov","html_url":"https://github.com/pskucherov","followers_url":"https://api.github.com/users/pskucherov/followers","following_url":"https://api.github.com/users/pskucherov/following{/other_user}","gists_url":"https://api.github.com/users/pskucherov/gists{/gist_id}","starred_url":"https://api.github.com/users/pskucherov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pskucherov/subscriptions","organizations_url":"https://api.github.com/users/pskucherov/orgs","repos_url":"https://api.github.com/users/pskucherov/repos","events_url":"https://api.github.com/users/pskucherov/events{/privacy}","received_events_url":"https://api.github.com/users/pskucherov/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/pskucherov/learning","description":"pet-project на поиграться","fork":false,"url":"https://api.github.com/repos/pskucherov/learning","forks_url":"https://api.github.com/repos/pskucherov/learning/forks","keys_url":"https://api.github.com/repos/pskucherov/learning/keys{/key_id}","collaborators_url":"https://api.github.com/repos/pskucherov/learning/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/pskucherov/learning/teams","hooks_url":"https://api.github.com/repos/pskucherov/learning/hooks","issue_events_url":"https://api.github.com/repos/pskucherov/learning/issues/events{/number}","events_url":"https://api.github.com/repos/pskucherov/learning/events","assignees_url":"https://api.github.com/repos/pskucherov/learning/assignees{/user}","branches_url":"https://api.github.com/repos/pskucherov/learning/branches{/branch}","tags_url":"https://api.github.com/repos/pskucherov/learning/tags","blobs_url":"https://api.github.com/repos/pskucherov/learning/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/pskucherov/learning/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/pskucherov/learning/git/refs{/sha}","trees_url":"https://api.github.com/repos/pskucherov/learning/git/trees{/sha}","statuses_url":"https://api.github.com/repos/pskucherov/learning/statuses/{sha}","languages_url":"https://api.github.com/repos/pskucherov/learning/languages","stargazers_url":"https://api.github.com/repos/pskucherov/learning/stargazers","contributors_url":"https://api.github.com/repos/pskucherov/learning/contributors","subscribers_url":"https://api.github.com/repos/pskucherov/learning/subscribers","subscription_url":"https://api.github.com/repos/pskucherov/learning/subscription","commits_url":"https://api.github.com/repos/pskucherov/learning/commits{/sha}","git_commits_url":"https://api.github.com/repos/pskucherov/learning/git/commits{/sha}","comments_url":"https://api.github.com/repos/pskucherov/learning/comments{/number}","issue_comment_url":"https://api.github.com/repos/pskucherov/learning/issues/comments{/number}","contents_url":"https://api.github.com/repos/pskucherov/learning/contents/{+path}","compare_url":"https://api.github.com/repos/pskucherov/learning/compare/{base}...{head}","merges_url":"https://api.github.com/repos/pskucherov/learning/merges","archive_url":"https://api.github.com/repos/pskucherov/learning/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/pskucherov/learning/downloads","issues_url":"https://api.github.com/repos/pskucherov/learning/issues{/number}","pulls_url":"https://api.github.com/repos/pskucherov/learning/pulls{/number}","milestones_url":"https://api.github.com/repos/pskucherov/learning/milestones{/number}","notifications_url":"https://api.github.com/repos/pskucherov/learning/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/pskucherov/learning/labels{/name}","releases_url":"https://api.github.com/repos/pskucherov/learning/releases{/id}","deployments_url":"https://api.github.com/repos/pskucherov/learning/deployments","created_at":"2015-04-25T17:24:33Z","updated_at":"2016-07-03T19:16:08Z","pushed_at":"2016-07-12T12:16:32Z","git_url":"git://github.com/pskucherov/learning.git","ssh_url":"git@github.com:pskucherov/learning.git","clone_url":"https://github.com/pskucherov/learning.git","svn_url":"https://github.com/pskucherov/learning","homepage":"https://schoolnik.com/","size":1408,"stargazers_count":1,"watchers_count":1,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":6,"forks":2,"open_issues":6,"watchers":1,"default_branch":"master"}},"base":{"label":"pskucherov:master","ref":"master","sha":"47ca320efd31bf7d1de40ad7fb0cbd65657da77d","user":{"login":"pskucherov","id":3197868,"avatar_url":"https://avatars.githubusercontent.com/u/3197868?v=3","gravatar_id":"","url":"https://api.github.com/users/pskucherov","html_url":"https://github.com/pskucherov","followers_url":"https://api.github.com/users/pskucherov/followers","following_url":"https://api.github.com/users/pskucherov/following{/other_user}","gists_url":"https://api.github.com/users/pskucherov/gists{/gist_id}","starred_url":"https://api.github.com/users/pskucherov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pskucherov/subscriptions","organizations_url":"https://api.github.com/users/pskucherov/orgs","repos_url":"https://api.github.com/users/pskucherov/repos","events_url":"https://api.github.com/users/pskucherov/events{/privacy}","received_events_url":"https://api.github.com/users/pskucherov/received_events","type":"User","site_admin":false},"repo":{"id":34578238,"name":"learning","full_name":"pskucherov/learning","owner":{"login":"pskucherov","id":3197868,"avatar_url":"https://avatars.githubusercontent.com/u/3197868?v=3","gravatar_id":"","url":"https://api.github.com/users/pskucherov","html_url":"https://github.com/pskucherov","followers_url":"https://api.github.com/users/pskucherov/followers","following_url":"https://api.github.com/users/pskucherov/following{/other_user}","gists_url":"https://api.github.com/users/pskucherov/gists{/gist_id}","starred_url":"https://api.github.com/users/pskucherov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pskucherov/subscriptions","organizations_url":"https://api.github.com/users/pskucherov/orgs","repos_url":"https://api.github.com/users/pskucherov/repos","events_url":"https://api.github.com/users/pskucherov/events{/privacy}","received_events_url":"https://api.github.com/users/pskucherov/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/pskucherov/learning","description":"pet-project на поиграться","fork":false,"url":"https://api.github.com/repos/pskucherov/learning","forks_url":"https://api.github.com/repos/pskucherov/learning/forks","keys_url":"https://api.github.com/repos/pskucherov/learning/keys{/key_id}","collaborators_url":"https://api.github.com/repos/pskucherov/learning/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/pskucherov/learning/teams","hooks_url":"https://api.github.com/repos/pskucherov/learning/hooks","issue_events_url":"https://api.github.com/repos/pskucherov/learning/issues/events{/number}","events_url":"https://api.github.com/repos/pskucherov/learning/events","assignees_url":"https://api.github.com/repos/pskucherov/learning/assignees{/user}","branches_url":"https://api.github.com/repos/pskucherov/learning/branches{/branch}","tags_url":"https://api.github.com/repos/pskucherov/learning/tags","blobs_url":"https://api.github.com/repos/pskucherov/learning/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/pskucherov/learning/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/pskucherov/learning/git/refs{/sha}","trees_url":"https://api.github.com/repos/pskucherov/learning/git/trees{/sha}","statuses_url":"https://api.github.com/repos/pskucherov/learning/statuses/{sha}","languages_url":"https://api.github.com/repos/pskucherov/learning/languages","stargazers_url":"https://api.github.com/repos/pskucherov/learning/stargazers","contributors_url":"https://api.github.com/repos/pskucherov/learning/contributors","subscribers_url":"https://api.github.com/repos/pskucherov/learning/subscribers","subscription_url":"https://api.github.com/repos/pskucherov/learning/subscription","commits_url":"https://api.github.com/repos/pskucherov/learning/commits{/sha}","git_commits_url":"https://api.github.com/repos/pskucherov/learning/git/commits{/sha}","comments_url":"https://api.github.com/repos/pskucherov/learning/comments{/number}","issue_comment_url":"https://api.github.com/repos/pskucherov/learning/issues/comments{/number}","contents_url":"https://api.github.com/repos/pskucherov/learning/contents/{+path}","compare_url":"https://api.github.com/repos/pskucherov/learning/compare/{base}...{head}","merges_url":"https://api.github.com/repos/pskucherov/learning/merges","archive_url":"https://api.github.com/repos/pskucherov/learning/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/pskucherov/learning/downloads","issues_url":"https://api.github.com/repos/pskucherov/learning/issues{/number}","pulls_url":"https://api.github.com/repos/pskucherov/learning/pulls{/number}","milestones_url":"https://api.github.com/repos/pskucherov/learning/milestones{/number}","notifications_url":"https://api.github.com/repos/pskucherov/learning/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/pskucherov/learning/labels{/name}","releases_url":"https://api.github.com/repos/pskucherov/learning/releases{/id}","deployments_url":"https://api.github.com/repos/pskucherov/learning/deployments","created_at":"2015-04-25T17:24:33Z","updated_at":"2016-07-03T19:16:08Z","pushed_at":"2016-07-12T12:16:32Z","git_url":"git://github.com/pskucherov/learning.git","ssh_url":"git@github.com:pskucherov/learning.git","clone_url":"https://github.com/pskucherov/learning.git","svn_url":"https://github.com/pskucherov/learning","homepage":"https://schoolnik.com/","size":1408,"stargazers_count":1,"watchers_count":1,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":6,"forks":2,"open_issues":6,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/pskucherov/learning/pulls/11"},"html":{"href":"https://github.com/pskucherov/learning/pull/11"},"issue":{"href":"https://api.github.com/repos/pskucherov/learning/issues/11"},"comments":{"href":"https://api.github.com/repos/pskucherov/learning/issues/11/comments"},"review_comments":{"href":"https://api.github.com/repos/pskucherov/learning/pulls/11/comments"},"review_comment":{"href":"https://api.github.com/repos/pskucherov/learning/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/pskucherov/learning/pulls/11/commits"},"statuses":{"href":"https://api.github.com/repos/pskucherov/learning/statuses/b11c0e26d8035a805f9972a2ebbd724742f5b512"}}}}
{"actor":{"display_login":"pskucherov"}}