Skip to content

Commit

Permalink
fix commands parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
mose committed Jul 26, 2016
1 parent dcf865f commit e120a4b
Show file tree
Hide file tree
Showing 3 changed files with 127 additions and 124 deletions.
4 changes: 2 additions & 2 deletions lib/phabricator.coffee
Expand Up @@ -243,9 +243,9 @@ class Phabricator
'constraints[statuses][0]': 'open',
'constraints[projects][0]': phid,
'order': 'newest',
'limit': 3
'limit': '3'
}
console.log query
# console.log query
@phabGet msg, query, 'maniphest.search', (json_body) ->
cb json_body

Expand Down
5 changes: 4 additions & 1 deletion scripts/phabs_commands.coffee
Expand Up @@ -51,6 +51,7 @@ module.exports = (robot) ->
url = process.env.PHABRICATOR_URL + "/T#{id}"
phab.recordPhid msg, id
msg.send "Task T#{id} created = #{url}"
msg.finish()

# hubot phab paste <name of the paste> - creates a new paste
robot.respond /ph(?:ab)? paste (.*)$/, (msg) ->
Expand All @@ -63,6 +64,7 @@ module.exports = (robot) ->
url = process.env.PHABRICATOR_URL + "/paste/edit/#{id}"
phab.recordPhid msg, id
msg.send "Paste P#{id} created = edit on #{url}"
msg.finish()

# hubot phab count <project> - counts how many tasks a project has
robot.respond (/ph(?:ab)? count ([-_a-zA-Z0-9]+)/), (msg) ->
Expand All @@ -72,6 +74,7 @@ module.exports = (robot) ->
msg.send "#{projectData.data.name} has no tasks."
else
msg.send "#{projectData.data.name} has #{Object.keys(body['result']).length} tasks."
msg.finish()

# hubot phab Txx - gives information about task Txxx
robot.respond /ph(?:ab)?(?: T([0-9]+) ?)?$/, (msg) ->
Expand Down Expand Up @@ -187,7 +190,7 @@ module.exports = (robot) ->
msg.finish()

# hubot phab <project> search terms - searches for terms in project
robot.respond /ph(?:ab)? ([^ ]+) (.*)$/, (msg) ->
robot.respond /ph(?:ab)? ([^ ]+) (.+)$/, (msg) ->
project = msg.match[1]
terms = msg.match[2]
phab.withProject msg, project, (projectData) ->
Expand Down
242 changes: 121 additions & 121 deletions test/phabs_commands_test.coffee
Expand Up @@ -26,7 +26,7 @@ describe 'phabs_commands module', ->
room.messages[i]?[1]

hubotResponseCount = ->
room.messages.length
room.messages?.length

beforeEach ->
process.env.PHABRICATOR_URL = 'http://example.com'
Expand Down Expand Up @@ -849,126 +849,126 @@ describe 'phabs_commands module', ->
expect(hubotResponse()).to.eql 'Ok. T42 is now assigned to user_with_phid'

# ---------------------------------------------------------------------------------
# context 'user searches through tasks', ->

# context 'there is some results', ->
# beforeEach ->
# room.robot.brain.data.phabricator.projects = {
# 'proj3': {
# phid: 'PHID-PROJ-qhmexneudkt62wc7o3z4'
# }
# }
# do nock.disableNetConnect
# nock(process.env.PHABRICATOR_URL)
# .get('/api/maniphest.search')
# .reply(200, { result: {
# 'data': [
# {
# 'id': 2490,
# 'type': 'TASK',
# 'phid': 'PHID-TASK-p5tbi3vbcffx3mpbxhwr',
# 'fields': {
# 'name': 'Bad configuration parsing on pypo v2 / policy1-d',
# 'authorPHID': 'PHID-USER-7p4d4k6v4csqx7gcxcbw',
# 'ownerPHID': null,
# 'status': {
# 'value': 'open',
# 'name': 'Open',
# 'color': null
# },
# 'priority': {
# 'value': 90,
# 'subpriority': 0,
# 'name': 'Needs Triage',
# 'color': 'violet'
# },
# 'points': null,
# 'spacePHID': null,
# 'dateCreated': 1468339539,
# 'dateModified': 1469535704,
# 'policy': {
# 'view': 'users',
# 'edit': 'users'
# }
# },
# 'attachments': { }
# },
# {
# 'id': 2080,
# 'type': 'TASK',
# 'phid': 'PHID-TASK-ext-55d324653c69b5351ff64d0a',
# 'fields': {
# 'name': 'Use a dedicated VM for gandi* backup.',
# 'authorPHID': 'PHID-USER-hqnae6h2h7fyhln3kqkd',
# 'ownerPHID': null,
# 'status': {
# 'value': 'open',
# 'name': 'Open',
# 'color': null
# },
# 'priority': {
# 'value': 90,
# 'subpriority': 0,
# 'name': 'Needs Triage',
# 'color': 'violet'
# },
# 'points': null,
# 'spacePHID': null,
# 'dateCreated': 1439900773,
# 'dateModified': 1467045532,
# 'policy': {
# 'view': 'users',
# 'edit': 'users'
# }
# },
# 'attachments': { }
# },
# {
# 'id': 2078,
# 'type': 'TASK',
# 'phid': 'PHID-TASK-ext-55e53abba4d0c58648fdfab6',
# 'fields': {
# 'name': 'H and D.root-servers IP change',
# 'authorPHID': 'PHID-USER-syykf4ieymsc73z6tie7',
# 'ownerPHID': null,
# 'status': {
# 'value': 'open',
# 'name': 'Open',
# 'color': null
# },
# 'priority': {
# 'value': 90,
# 'subpriority': 0,
# 'name': 'Needs Triage',
# 'color': 'violet'
# },
# 'points': null,
# 'spacePHID': null,
# 'dateCreated': 1441086139,
# 'dateModified': 1468252093,
# 'policy': {
# 'view': 'users',
# 'edit': 'users'
# }
# },
# 'attachments': { }
# }
# ],
# 'maps': { },
# 'query': {
# 'queryKey': 'rwQ6luYqjZF0'
# },
# 'cursor': {
# 'limit': 3,
# 'after': '2078',
# 'before': null,
# 'order': 'newest'
# }
# } })

# afterEach ->
# room.robot.brain.data.phabricator = { }
# nock.cleanAll()
context 'user searches through tasks', ->

context 'there is some results', ->
beforeEach ->
room.robot.brain.data.phabricator.projects = {
'proj3': {
phid: 'PHID-PROJ-qhmexneudkt62wc7o3z4'
}
}
do nock.disableNetConnect
nock(process.env.PHABRICATOR_URL)
.get('/api/maniphest.search')
.reply(200, { result: {
'data': [
{
'id': 2490,
'type': 'TASK',
'phid': 'PHID-TASK-p5tbi3vbcffx3mpbxhwr',
'fields': {
'name': 'Bad configuration parsing on pypo v2 / policy1-d',
'authorPHID': 'PHID-USER-7p4d4k6v4csqx7gcxcbw',
'ownerPHID': null,
'status': {
'value': 'open',
'name': 'Open',
'color': null
},
'priority': {
'value': 90,
'subpriority': 0,
'name': 'Needs Triage',
'color': 'violet'
},
'points': null,
'spacePHID': null,
'dateCreated': 1468339539,
'dateModified': 1469535704,
'policy': {
'view': 'users',
'edit': 'users'
}
},
'attachments': { }
},
{
'id': 2080,
'type': 'TASK',
'phid': 'PHID-TASK-ext-55d324653c69b5351ff64d0a',
'fields': {
'name': 'Use a dedicated VM for gandi* backup.',
'authorPHID': 'PHID-USER-hqnae6h2h7fyhln3kqkd',
'ownerPHID': null,
'status': {
'value': 'open',
'name': 'Open',
'color': null
},
'priority': {
'value': 90,
'subpriority': 0,
'name': 'Needs Triage',
'color': 'violet'
},
'points': null,
'spacePHID': null,
'dateCreated': 1439900773,
'dateModified': 1467045532,
'policy': {
'view': 'users',
'edit': 'users'
}
},
'attachments': { }
},
{
'id': 2078,
'type': 'TASK',
'phid': 'PHID-TASK-ext-55e53abba4d0c58648fdfab6',
'fields': {
'name': 'H and D.root-servers IP change',
'authorPHID': 'PHID-USER-syykf4ieymsc73z6tie7',
'ownerPHID': null,
'status': {
'value': 'open',
'name': 'Open',
'color': null
},
'priority': {
'value': 90,
'subpriority': 0,
'name': 'Needs Triage',
'color': 'violet'
},
'points': null,
'spacePHID': null,
'dateCreated': 1441086139,
'dateModified': 1468252093,
'policy': {
'view': 'users',
'edit': 'users'
}
},
'attachments': { }
}
],
'maps': { },
'query': {
'queryKey': 'rwQ6luYqjZF0'
},
'cursor': {
'limit': 3,
'after': '2078',
'before': null,
'order': 'newest'
}
} })

afterEach ->
room.robot.brain.data.phabricator = { }
nock.cleanAll()

# context 'phab proj1 gitlab', ->
# hubot 'phab proj1 gitlab'
Expand Down

0 comments on commit e120a4b

Please sign in to comment.