diff --git a/test/phabricator_test.coffee b/test/phabricator_test.coffee index 05894ca..5ab7ba0 100644 --- a/test/phabricator_test.coffee +++ b/test/phabricator_test.coffee @@ -1,6 +1,7 @@ Phabricator = require('../lib/phabricator.coffee') sinon = require("sinon") expect = require('chai').use(require('sinon-chai')).expect +nock = require('nock') describe 'Phabricator lib', -> diff --git a/test/phabs_test.coffee b/test/phabs_test.coffee index d714365..e7e60c5 100644 --- a/test/phabs_test.coffee +++ b/test/phabs_test.coffee @@ -34,7 +34,7 @@ describe 'hubot-phabs module', -> process.env.PHABRICATOR_URL = 'http://example.com' process.env.PHABRICATOR_API_KEY = 'xxx' process.env.PHABRICATOR_BOT_PHID = 'PHID-USER-xxx' - process.env.PHABRICATOR_PROJECTS = 'PHID-PROJ-xxx:proj1,PHID-PROJ-yyy:proj2' + process.env.PHABRICATOR_PROJECTS = 'PHID-PROJ-xxx:proj1,PHID-PCOL-yyy:proj2' room = helper.createRoom { httpd: false } room.robot.brain.userForId 'user', name: 'user' @@ -247,6 +247,24 @@ describe 'hubot-phabs module', -> expect(hubotResponse()).to.eql 'Something went wrong' + context 'phab new proj2 a task', -> + beforeEach -> + do nock.disableNetConnect + nock(process.env.PHABRICATOR_URL) + .get('/api/user.query') + .reply(200, { result: [ { phid: 'PHID-USER-42' } ] }) + .get('/api/maniphest.edit') + .reply(200, { result: { object: { id: 24 } } }) + + afterEach -> + nock.cleanAll() + + context 'when user is known and his phid is in the brain', -> + hubot 'phab new proj2 a task', 'user_with_phid' + it 'replies with the object id', -> + expect(hubotResponse()).to.eql 'Task T24 created = http://example.com/T24' + + # --------------------------------------------------------------------------------- context 'user changes status for a task', -> context 'when the task is unknown', ->