1+ 'use strict' ;
12var Lab = require ( 'lab' ) ;
23var describe = Lab . experiment ;
34var it = Lab . test ;
@@ -76,10 +77,10 @@ describe('Github - /actions/github', function () {
7677 process . env . ENABLE_BUILDS_ON_GIT_PUSH = ctx . originalBuildsOnPushSetting ;
7778 done ( ) ;
7879 } ) ;
79- it ( 'should just say hi if hooks are disabled' , function ( done ) {
80+ it ( 'should send response immediately if hooks are disabled' , function ( done ) {
8081 var options = hooks ( ctx . contextVersion . json ( ) ) . push ;
8182 options . json . ref = 'refs/heads/someotherbranch' ;
82- // require('./fixtures/mocks/github/users-username')(101, 'bkendall');
83+ require ( './fixtures/mocks/github/users-username' ) ( 101 , 'bkendall' ) ;
8384 request . post ( options , function ( err , res ) {
8485 if ( err ) {
8586 done ( err ) ;
@@ -93,6 +94,55 @@ describe('Github - /actions/github', function () {
9394 } ) ;
9495 } ) ;
9596
97+ describe ( 'ignore hooks without commits data' , function ( ) {
98+ var ctx = { } ;
99+ beforeEach ( function ( done ) {
100+ process . env . ENABLE_BUILDS_ON_GIT_PUSH = 'true' ;
101+ multi . createInstance ( function ( err , instance , build , user , modelsArr ) {
102+ ctx . contextVersion = modelsArr [ 0 ] ;
103+ ctx . context = modelsArr [ 1 ] ;
104+ ctx . build = build ;
105+ ctx . user = user ;
106+ done ( err ) ;
107+ } ) ;
108+ } ) ;
109+
110+ it ( 'should send response immediately there are no commits data ([]) in the payload ' , function ( done ) {
111+ var options = hooks ( ctx . contextVersion . json ( ) ) . push ;
112+ options . json . ref = 'refs/heads/someotherbranch' ;
113+ options . json . commits = [ ] ;
114+ require ( './fixtures/mocks/github/users-username' ) ( 101 , 'bkendall' ) ;
115+ request . post ( options , function ( err , res ) {
116+ if ( err ) {
117+ done ( err ) ;
118+ }
119+ else {
120+ expect ( res . statusCode ) . to . equal ( 202 ) ;
121+ expect ( res . body ) . to . equal ( 'No commits pushed; no work to be done.' ) ;
122+ done ( ) ;
123+ }
124+ } ) ;
125+ } ) ;
126+
127+ it ( 'should send response immediately there are no commits data (null) in the payload ' , function ( done ) {
128+ var options = hooks ( ctx . contextVersion . json ( ) ) . push ;
129+ options . json . ref = 'refs/heads/someotherbranch' ;
130+ options . json . commits = null ;
131+ require ( './fixtures/mocks/github/users-username' ) ( 101 , 'bkendall' ) ;
132+ request . post ( options , function ( err , res ) {
133+ if ( err ) {
134+ done ( err ) ;
135+ }
136+ else {
137+ expect ( res . statusCode ) . to . equal ( 202 ) ;
138+ expect ( res . body ) . to . equal ( 'No commits pushed; no work to be done.' ) ;
139+ done ( ) ;
140+ }
141+ } ) ;
142+ } ) ;
143+ } ) ;
144+
145+
96146 // describe('push', function () {
97147 // var ctx = {};
98148 // beforeEach(function (done) {
0 commit comments