@@ -125,13 +125,12 @@ describe('Github - /actions/github', function () {
125125 } ) ;
126126
127127 it ( 'should return OKAY' , function ( done ) {
128- var options = hooks ( ) . pull_request ;
129- options . action = 'delete' ;
128+ var options = hooks ( ) . pull_request_closed ;
130129 request . post ( options , function ( err , res , body ) {
131130 if ( err ) { return done ( err ) ; }
132131
133132 expect ( res . statusCode ) . to . equal ( 202 ) ;
134- expect ( body ) . to . equal ( 'Do not handle pull request with actions not equal synchronize.' ) ;
133+ expect ( body ) . to . equal ( 'Do not handle pull request with actions not equal synchronize or opened .' ) ;
135134 done ( ) ;
136135 } ) ;
137136 } ) ;
@@ -312,40 +311,77 @@ describe('Github - /actions/github', function () {
312311 done ( ) ;
313312 } ) ;
314313
315- it ( 'should set server selection status for the branch without instance' , { timeout : 6000 } , function ( done ) {
316-
317- Github . prototype . getPullRequestHeadCommit = function ( repo , number , cb ) {
318- cb ( null , { commit : {
319- message : 'hello'
320- } } ) ;
321- } ;
322-
323- PullRequest . prototype . serverSelectionStatus = function ( pullRequest , targetUrl , cb ) {
324- expect ( pullRequest . number ) . to . equal ( 2 ) ;
325- expect ( pullRequest . headCommit . message ) . to . equal ( 'hello' ) ;
326- expect ( pullRequest ) . to . exist ( ) ;
327- expect ( targetUrl ) . to . include ( 'https://runnable.io/' ) ;
328- expect ( targetUrl ) . to . include ( '/serverSelection/' ) ;
329- cb ( ) ;
330- done ( ) ;
331- } ;
332-
333- var acv = ctx . contextVersion . attrs . appCodeVersions [ 0 ] ;
334- var data = {
335- branch : 'feature-1' ,
336- repo : acv . repo
337- } ;
338- var options = hooks ( data ) . pull_request_sync ;
339- require ( './fixtures/mocks/github/users-username' ) ( 101 , 'podviaznikov' ) ;
340- require ( './fixtures/mocks/docker/container-id-attach' ) ( ) ;
341- request . post ( options , function ( err , res , contextVersionIds ) {
342- if ( err ) { return done ( err ) ; }
343- expect ( res . statusCode ) . to . equal ( 201 ) ;
344- expect ( contextVersionIds ) . to . be . okay ;
345- expect ( contextVersionIds ) . to . be . an ( 'array' ) ;
346- expect ( contextVersionIds ) . to . have . a . lengthOf ( 1 ) ;
314+ it ( 'should set server selection status for the branch without instance - pull_request:synchronize' ,
315+ { timeout : 6000 } , function ( done ) {
316+
317+ Github . prototype . getPullRequestHeadCommit = function ( repo , number , cb ) {
318+ cb ( null , { commit : {
319+ message : 'hello'
320+ } } ) ;
321+ } ;
322+
323+ PullRequest . prototype . serverSelectionStatus = function ( pullRequest , targetUrl , cb ) {
324+ expect ( pullRequest . number ) . to . equal ( 2 ) ;
325+ expect ( pullRequest . headCommit . message ) . to . equal ( 'hello' ) ;
326+ expect ( pullRequest ) . to . exist ( ) ;
327+ expect ( targetUrl ) . to . include ( 'https://runnable.io/' ) ;
328+ expect ( targetUrl ) . to . include ( '/serverSelection/' ) ;
329+ cb ( ) ;
330+ done ( ) ;
331+ } ;
332+
333+ var acv = ctx . contextVersion . attrs . appCodeVersions [ 0 ] ;
334+ var data = {
335+ branch : 'feature-1' ,
336+ repo : acv . repo
337+ } ;
338+ var options = hooks ( data ) . pull_request_sync ;
339+ require ( './fixtures/mocks/github/users-username' ) ( 101 , 'podviaznikov' ) ;
340+ require ( './fixtures/mocks/docker/container-id-attach' ) ( ) ;
341+ request . post ( options , function ( err , res , contextVersionIds ) {
342+ if ( err ) { return done ( err ) ; }
343+ expect ( res . statusCode ) . to . equal ( 201 ) ;
344+ expect ( contextVersionIds ) . to . be . okay ;
345+ expect ( contextVersionIds ) . to . be . an ( 'array' ) ;
346+ expect ( contextVersionIds ) . to . have . a . lengthOf ( 1 ) ;
347+ } ) ;
348+ } ) ;
349+
350+ it ( 'should set server selection status for the branch without instance - pull_request:opened' ,
351+ { timeout : 6000 } , function ( done ) {
352+
353+ Github . prototype . getPullRequestHeadCommit = function ( repo , number , cb ) {
354+ cb ( null , { commit : {
355+ message : 'hello'
356+ } } ) ;
357+ } ;
358+
359+ PullRequest . prototype . serverSelectionStatus = function ( pullRequest , targetUrl , cb ) {
360+ expect ( pullRequest . number ) . to . equal ( 2 ) ;
361+ expect ( pullRequest . headCommit . message ) . to . equal ( 'hello' ) ;
362+ expect ( pullRequest ) . to . exist ( ) ;
363+ expect ( targetUrl ) . to . include ( 'https://runnable.io/' ) ;
364+ expect ( targetUrl ) . to . include ( '/serverSelection/' ) ;
365+ cb ( ) ;
366+ done ( ) ;
367+ } ;
368+
369+ var acv = ctx . contextVersion . attrs . appCodeVersions [ 0 ] ;
370+ var data = {
371+ branch : 'feature-1' ,
372+ repo : acv . repo
373+ } ;
374+ var options = hooks ( data ) . pull_request_opened ;
375+ require ( './fixtures/mocks/github/users-username' ) ( 101 , 'podviaznikov' ) ;
376+ require ( './fixtures/mocks/docker/container-id-attach' ) ( ) ;
377+ request . post ( options , function ( err , res , contextVersionIds ) {
378+ if ( err ) { return done ( err ) ; }
379+ expect ( res . statusCode ) . to . equal ( 201 ) ;
380+ expect ( contextVersionIds ) . to . be . okay ;
381+ expect ( contextVersionIds ) . to . be . an ( 'array' ) ;
382+ expect ( contextVersionIds ) . to . have . a . lengthOf ( 1 ) ;
383+ } ) ;
347384 } ) ;
348- } ) ;
349385
350386 it ( 'should redeploy two instances with new build' , { timeout : 6000 } , function ( done ) {
351387 ctx . user . copyInstance ( ctx . instance . id ( ) , { } , function ( err , instance2 ) {
0 commit comments