diff --git a/lib/parsers/webhook_json_parser.rb b/lib/parsers/webhook_json_parser.rb index 652a60b..d3c9022 100644 --- a/lib/parsers/webhook_json_parser.rb +++ b/lib/parsers/webhook_json_parser.rb @@ -61,7 +61,7 @@ def bitbucket_webhook? def tfs_webhook? # https://docs.microsoft.com/en-us/vsts/service-hooks/services/webhooks return false unless @data.key? 'resource' - return false unless @data.key? 'event.type' + return false unless @data.key? 'eventType' true end @@ -78,7 +78,8 @@ def branch when 'stash' @data['refChanges'][0]['refId'].sub('refs/heads/', '') when 'bitbucket' - @data['push']['changes'][0]['new']['name'] + return @data['push']['changes'][0]['new']['name'] unless deleted? + @data['push']['changes'][0]['old']['name'] when 'tfs' @data['resource']['refUpdates'][0]['name'].sub('refs/heads/', '') end @@ -94,8 +95,9 @@ def deleted? @data['refChanges'][0]['type'] == 'DELETE' when 'bitbucket' @data['push']['changes'][0]['closed'] + when 'tfs' + @data['resource']['refUpdates'][0]['newObjectId'] == '0000000000000000000000000000000000000000' else - # TODO: TFS false end end @@ -103,6 +105,8 @@ def deleted? def repo_name if @vcs == 'gitlab' @data['project']['name'] + elsif @vcs == 'tfs' + @data['resource']['repository']['name'] else @data['repository']['name'] end diff --git a/spec/fixtures/bitbucket/create.json b/spec/fixtures/bitbucket/create.json new file mode 100644 index 0000000..e07c97c --- /dev/null +++ b/spec/fixtures/bitbucket/create.json @@ -0,0 +1,411 @@ +{ + "push": { + "changes": [ + { + "forced": false, + "old": null, + "links": { + "commits": { + "href": "https://api.bitbucket.org/2.0/repositories/dhollinger3/puppet-r10k/commits?include=65b4b4b14af68439fcd3ed0b7a13a80154e4735f" + }, + "html": { + "href": "https://bitbucket.org/dhollinger3/puppet-r10k/branch/master" + } + }, + "truncated": true, + "commits": [ + { + "hash": "65b4b4b14af68439fcd3ed0b7a13a80154e4735f", + "links": { + "self": { + "href": "https://api.bitbucket.org/2.0/repositories/dhollinger3/puppet-r10k/commit/65b4b4b14af68439fcd3ed0b7a13a80154e4735f" + }, + "comments": { + "href": "https://api.bitbucket.org/2.0/repositories/dhollinger3/puppet-r10k/commit/65b4b4b14af68439fcd3ed0b7a13a80154e4735f/comments" + }, + "patch": { + "href": "https://api.bitbucket.org/2.0/repositories/dhollinger3/puppet-r10k/patch/65b4b4b14af68439fcd3ed0b7a13a80154e4735f" + }, + "html": { + "href": "https://bitbucket.org/dhollinger3/puppet-r10k/commits/65b4b4b14af68439fcd3ed0b7a13a80154e4735f" + }, + "diff": { + "href": "https://api.bitbucket.org/2.0/repositories/dhollinger3/puppet-r10k/diff/65b4b4b14af68439fcd3ed0b7a13a80154e4735f" + }, + "approve": { + "href": "https://api.bitbucket.org/2.0/repositories/dhollinger3/puppet-r10k/commit/65b4b4b14af68439fcd3ed0b7a13a80154e4735f/approve" + }, + "statuses": { + "href": "https://api.bitbucket.org/2.0/repositories/dhollinger3/puppet-r10k/commit/65b4b4b14af68439fcd3ed0b7a13a80154e4735f/statuses" + } + }, + "author": { + "raw": "Tim Meusel ", + "type": "author" + }, + "parents": [ + { + "type": "commit", + "hash": "053ae795d57ebe1b435a9bdde47f8da72f179422", + "links": { + "self": { + "href": "https://api.bitbucket.org/2.0/repositories/dhollinger3/puppet-r10k/commit/053ae795d57ebe1b435a9bdde47f8da72f179422" + }, + "html": { + "href": "https://bitbucket.org/dhollinger3/puppet-r10k/commits/053ae795d57ebe1b435a9bdde47f8da72f179422" + } + } + } + ], + "date": "2017-10-11T18:39:12+00:00", + "message": "[blacksmith] Bump version to 6.2.1-rc0\n", + "type": "commit" + }, + { + "hash": "053ae795d57ebe1b435a9bdde47f8da72f179422", + "links": { + "self": { + "href": "https://api.bitbucket.org/2.0/repositories/dhollinger3/puppet-r10k/commit/053ae795d57ebe1b435a9bdde47f8da72f179422" + }, + "comments": { + "href": "https://api.bitbucket.org/2.0/repositories/dhollinger3/puppet-r10k/commit/053ae795d57ebe1b435a9bdde47f8da72f179422/comments" + }, + "html": { + "href": "https://bitbucket.org/dhollinger3/puppet-r10k/commits/053ae795d57ebe1b435a9bdde47f8da72f179422" + }, + "diff": { + "href": "https://api.bitbucket.org/2.0/repositories/dhollinger3/puppet-r10k/diff/053ae795d57ebe1b435a9bdde47f8da72f179422" + }, + "approve": { + "href": "https://api.bitbucket.org/2.0/repositories/dhollinger3/puppet-r10k/commit/053ae795d57ebe1b435a9bdde47f8da72f179422/approve" + }, + "statuses": { + "href": "https://api.bitbucket.org/2.0/repositories/dhollinger3/puppet-r10k/commit/053ae795d57ebe1b435a9bdde47f8da72f179422/statuses" + } + }, + "author": { + "raw": "David Hollinger III ", + "type": "author", + "user": { + "username": "dhollinger", + "type": "user", + "display_name": "David Hollinger III", + "uuid": "{cd5a6b54-bdb7-470c-85c7-34698355f9f6}", + "links": { + "self": { + "href": "https://api.bitbucket.org/2.0/users/dhollinger" + }, + "html": { + "href": "https://bitbucket.org/dhollinger/" + }, + "avatar": { + "href": "https://bitbucket.org/account/dhollinger/avatar/32/" + } + } + } + }, + "parents": [ + { + "type": "commit", + "hash": "2bf7f541cca1f8a44795d5c0ec924b79c664c271", + "links": { + "self": { + "href": "https://api.bitbucket.org/2.0/repositories/dhollinger3/puppet-r10k/commit/2bf7f541cca1f8a44795d5c0ec924b79c664c271" + }, + "html": { + "href": "https://bitbucket.org/dhollinger3/puppet-r10k/commits/2bf7f541cca1f8a44795d5c0ec924b79c664c271" + } + } + }, + { + "type": "commit", + "hash": "ed3c4114312ebdfe66453cfe4c9319acff1fdf19", + "links": { + "self": { + "href": "https://api.bitbucket.org/2.0/repositories/dhollinger3/puppet-r10k/commit/ed3c4114312ebdfe66453cfe4c9319acff1fdf19" + }, + "html": { + "href": "https://bitbucket.org/dhollinger3/puppet-r10k/commits/ed3c4114312ebdfe66453cfe4c9319acff1fdf19" + } + } + } + ], + "date": "2017-10-11T18:38:38+00:00", + "message": "Merge pull request #388 from bastelfreak/rel620\n\nrelease 6.2.0", + "type": "commit" + }, + { + "hash": "ed3c4114312ebdfe66453cfe4c9319acff1fdf19", + "links": { + "self": { + "href": "https://api.bitbucket.org/2.0/repositories/dhollinger3/puppet-r10k/commit/ed3c4114312ebdfe66453cfe4c9319acff1fdf19" + }, + "comments": { + "href": "https://api.bitbucket.org/2.0/repositories/dhollinger3/puppet-r10k/commit/ed3c4114312ebdfe66453cfe4c9319acff1fdf19/comments" + }, + "patch": { + "href": "https://api.bitbucket.org/2.0/repositories/dhollinger3/puppet-r10k/patch/ed3c4114312ebdfe66453cfe4c9319acff1fdf19" + }, + "html": { + "href": "https://bitbucket.org/dhollinger3/puppet-r10k/commits/ed3c4114312ebdfe66453cfe4c9319acff1fdf19" + }, + "diff": { + "href": "https://api.bitbucket.org/2.0/repositories/dhollinger3/puppet-r10k/diff/ed3c4114312ebdfe66453cfe4c9319acff1fdf19" + }, + "approve": { + "href": "https://api.bitbucket.org/2.0/repositories/dhollinger3/puppet-r10k/commit/ed3c4114312ebdfe66453cfe4c9319acff1fdf19/approve" + }, + "statuses": { + "href": "https://api.bitbucket.org/2.0/repositories/dhollinger3/puppet-r10k/commit/ed3c4114312ebdfe66453cfe4c9319acff1fdf19/statuses" + } + }, + "author": { + "raw": "Tim Meusel ", + "type": "author" + }, + "parents": [ + { + "type": "commit", + "hash": "2bf7f541cca1f8a44795d5c0ec924b79c664c271", + "links": { + "self": { + "href": "https://api.bitbucket.org/2.0/repositories/dhollinger3/puppet-r10k/commit/2bf7f541cca1f8a44795d5c0ec924b79c664c271" + }, + "html": { + "href": "https://bitbucket.org/dhollinger3/puppet-r10k/commits/2bf7f541cca1f8a44795d5c0ec924b79c664c271" + } + } + } + ], + "date": "2017-10-11T17:39:01+00:00", + "message": "release 6.2.0\n", + "type": "commit" + }, + { + "hash": "2bf7f541cca1f8a44795d5c0ec924b79c664c271", + "links": { + "self": { + "href": "https://api.bitbucket.org/2.0/repositories/dhollinger3/puppet-r10k/commit/2bf7f541cca1f8a44795d5c0ec924b79c664c271" + }, + "comments": { + "href": "https://api.bitbucket.org/2.0/repositories/dhollinger3/puppet-r10k/commit/2bf7f541cca1f8a44795d5c0ec924b79c664c271/comments" + }, + "html": { + "href": "https://bitbucket.org/dhollinger3/puppet-r10k/commits/2bf7f541cca1f8a44795d5c0ec924b79c664c271" + }, + "diff": { + "href": "https://api.bitbucket.org/2.0/repositories/dhollinger3/puppet-r10k/diff/2bf7f541cca1f8a44795d5c0ec924b79c664c271" + }, + "approve": { + "href": "https://api.bitbucket.org/2.0/repositories/dhollinger3/puppet-r10k/commit/2bf7f541cca1f8a44795d5c0ec924b79c664c271/approve" + }, + "statuses": { + "href": "https://api.bitbucket.org/2.0/repositories/dhollinger3/puppet-r10k/commit/2bf7f541cca1f8a44795d5c0ec924b79c664c271/statuses" + } + }, + "author": { + "raw": "Tim Meusel ", + "type": "author" + }, + "parents": [ + { + "type": "commit", + "hash": "000a31c7a5c9c13035c589f5137aa827d6ee0fbf", + "links": { + "self": { + "href": "https://api.bitbucket.org/2.0/repositories/dhollinger3/puppet-r10k/commit/000a31c7a5c9c13035c589f5137aa827d6ee0fbf" + }, + "html": { + "href": "https://bitbucket.org/dhollinger3/puppet-r10k/commits/000a31c7a5c9c13035c589f5137aa827d6ee0fbf" + } + } + }, + { + "type": "commit", + "hash": "1ee5cd27d2c29450cc1af094e98b9e470269b8e2", + "links": { + "self": { + "href": "https://api.bitbucket.org/2.0/repositories/dhollinger3/puppet-r10k/commit/1ee5cd27d2c29450cc1af094e98b9e470269b8e2" + }, + "html": { + "href": "https://bitbucket.org/dhollinger3/puppet-r10k/commits/1ee5cd27d2c29450cc1af094e98b9e470269b8e2" + } + } + } + ], + "date": "2017-09-20T20:17:18+00:00", + "message": "Merge pull request #387 from voxpupuli/modulesync\n\nmodulesync 1.1.0", + "type": "commit" + }, + { + "hash": "1ee5cd27d2c29450cc1af094e98b9e470269b8e2", + "links": { + "self": { + "href": "https://api.bitbucket.org/2.0/repositories/dhollinger3/puppet-r10k/commit/1ee5cd27d2c29450cc1af094e98b9e470269b8e2" + }, + "comments": { + "href": "https://api.bitbucket.org/2.0/repositories/dhollinger3/puppet-r10k/commit/1ee5cd27d2c29450cc1af094e98b9e470269b8e2/comments" + }, + "patch": { + "href": "https://api.bitbucket.org/2.0/repositories/dhollinger3/puppet-r10k/patch/1ee5cd27d2c29450cc1af094e98b9e470269b8e2" + }, + "html": { + "href": "https://bitbucket.org/dhollinger3/puppet-r10k/commits/1ee5cd27d2c29450cc1af094e98b9e470269b8e2" + }, + "diff": { + "href": "https://api.bitbucket.org/2.0/repositories/dhollinger3/puppet-r10k/diff/1ee5cd27d2c29450cc1af094e98b9e470269b8e2" + }, + "approve": { + "href": "https://api.bitbucket.org/2.0/repositories/dhollinger3/puppet-r10k/commit/1ee5cd27d2c29450cc1af094e98b9e470269b8e2/approve" + }, + "statuses": { + "href": "https://api.bitbucket.org/2.0/repositories/dhollinger3/puppet-r10k/commit/1ee5cd27d2c29450cc1af094e98b9e470269b8e2/statuses" + } + }, + "author": { + "raw": "Rob Nelson ", + "type": "author", + "user": { + "username": "rnelson0", + "type": "user", + "display_name": "Rob Nelson", + "uuid": "{3ed89436-0fd0-407d-a4fb-f73060407521}", + "links": { + "self": { + "href": "https://api.bitbucket.org/2.0/users/rnelson0" + }, + "html": { + "href": "https://bitbucket.org/rnelson0/" + }, + "avatar": { + "href": "https://bitbucket.org/account/rnelson0/avatar/32/" + } + } + } + }, + "parents": [ + { + "type": "commit", + "hash": "da3deaf600be98284ea69a9e22dbb4d5ceeef395", + "links": { + "self": { + "href": "https://api.bitbucket.org/2.0/repositories/dhollinger3/puppet-r10k/commit/da3deaf600be98284ea69a9e22dbb4d5ceeef395" + }, + "html": { + "href": "https://bitbucket.org/dhollinger3/puppet-r10k/commits/da3deaf600be98284ea69a9e22dbb4d5ceeef395" + } + } + } + ], + "date": "2017-09-20T20:09:57+00:00", + "message": "Puppet 5's parser fixes a few bugs from Puppet 4 and has highlighted a few missing pre_conditions in tests\n", + "type": "commit" + } + ], + "created": true, + "closed": false, + "new": { + "type": "branch", + "name": "master", + "links": { + "commits": { + "href": "https://api.bitbucket.org/2.0/repositories/dhollinger3/puppet-r10k/commits/master" + }, + "self": { + "href": "https://api.bitbucket.org/2.0/repositories/dhollinger3/puppet-r10k/refs/branches/master" + }, + "html": { + "href": "https://bitbucket.org/dhollinger3/puppet-r10k/branch/master" + } + }, + "target": { + "hash": "65b4b4b14af68439fcd3ed0b7a13a80154e4735f", + "links": { + "self": { + "href": "https://api.bitbucket.org/2.0/repositories/dhollinger3/puppet-r10k/commit/65b4b4b14af68439fcd3ed0b7a13a80154e4735f" + }, + "html": { + "href": "https://bitbucket.org/dhollinger3/puppet-r10k/commits/65b4b4b14af68439fcd3ed0b7a13a80154e4735f" + } + }, + "author": { + "raw": "Tim Meusel ", + "type": "author" + }, + "parents": [ + { + "type": "commit", + "hash": "053ae795d57ebe1b435a9bdde47f8da72f179422", + "links": { + "self": { + "href": "https://api.bitbucket.org/2.0/repositories/dhollinger3/puppet-r10k/commit/053ae795d57ebe1b435a9bdde47f8da72f179422" + }, + "html": { + "href": "https://bitbucket.org/dhollinger3/puppet-r10k/commits/053ae795d57ebe1b435a9bdde47f8da72f179422" + } + } + } + ], + "date": "2017-10-11T18:39:12+00:00", + "message": "[blacksmith] Bump version to 6.2.1-rc0\n", + "type": "commit" + } + } + } + ] + }, + "actor": { + "username": "dhollinger3", + "type": "user", + "display_name": "David Hollinger III", + "uuid": "{9a151b63-a0fb-4a20-a01f-99aefae76ac0}", + "links": { + "self": { + "href": "https://api.bitbucket.org/2.0/users/dhollinger3" + }, + "html": { + "href": "https://bitbucket.org/dhollinger3/" + }, + "avatar": { + "href": "https://bitbucket.org/account/dhollinger3/avatar/32/" + } + } + }, + "repository": { + "scm": "git", + "website": "", + "name": "puppet-r10k", + "links": { + "self": { + "href": "https://api.bitbucket.org/2.0/repositories/dhollinger3/puppet-r10k" + }, + "html": { + "href": "https://bitbucket.org/dhollinger3/puppet-r10k" + }, + "avatar": { + "href": "https://bitbucket.org/dhollinger3/puppet-r10k/avatar/32/" + } + }, + "full_name": "dhollinger3/puppet-r10k", + "owner": { + "username": "dhollinger3", + "type": "user", + "display_name": "David Hollinger III", + "uuid": "{9a151b63-a0fb-4a20-a01f-99aefae76ac0}", + "links": { + "self": { + "href": "https://api.bitbucket.org/2.0/users/dhollinger3" + }, + "html": { + "href": "https://bitbucket.org/dhollinger3/" + }, + "avatar": { + "href": "https://bitbucket.org/account/dhollinger3/avatar/32/" + } + } + }, + "type": "repository", + "is_private": true, + "uuid": "{f2d7282e-accb-46a1-b9d0-44bfe61b5af4}" + } +} \ No newline at end of file diff --git a/spec/fixtures/bitbucket/delete.json b/spec/fixtures/bitbucket/delete.json new file mode 100644 index 0000000..8176e97 --- /dev/null +++ b/spec/fixtures/bitbucket/delete.json @@ -0,0 +1,131 @@ +{ + "push": { + "changes": [ + { + "forced": false, + "old": { + "type": "branch", + "name": "add_branch", + "links": { + "commits": { + "href": "https://api.bitbucket.org/2.0/repositories/dhollinger3/puppet-r10k/commits/add_branch" + }, + "self": { + "href": "https://api.bitbucket.org/2.0/repositories/dhollinger3/puppet-r10k/refs/branches/add_branch" + }, + "html": { + "href": "https://bitbucket.org/dhollinger3/puppet-r10k/branch/add_branch" + } + }, + "target": { + "hash": "31dfeec60f7f864b3f91ec6c61264595e1198ab8", + "links": { + "self": { + "href": "https://api.bitbucket.org/2.0/repositories/dhollinger3/puppet-r10k/commit/31dfeec60f7f864b3f91ec6c61264595e1198ab8" + }, + "html": { + "href": "https://bitbucket.org/dhollinger3/puppet-r10k/commits/31dfeec60f7f864b3f91ec6c61264595e1198ab8" + } + }, + "author": { + "raw": "David Hollinger ", + "type": "author", + "user": { + "username": "dhollinger3", + "type": "user", + "display_name": "David Hollinger III", + "uuid": "{9a151b63-a0fb-4a20-a01f-99aefae76ac0}", + "links": { + "self": { + "href": "https://api.bitbucket.org/2.0/users/dhollinger3" + }, + "html": { + "href": "https://bitbucket.org/dhollinger3/" + }, + "avatar": { + "href": "https://bitbucket.org/account/dhollinger3/avatar/32/" + } + } + } + }, + "parents": [ + { + "type": "commit", + "hash": "65b4b4b14af68439fcd3ed0b7a13a80154e4735f", + "links": { + "self": { + "href": "https://api.bitbucket.org/2.0/repositories/dhollinger3/puppet-r10k/commit/65b4b4b14af68439fcd3ed0b7a13a80154e4735f" + }, + "html": { + "href": "https://bitbucket.org/dhollinger3/puppet-r10k/commits/65b4b4b14af68439fcd3ed0b7a13a80154e4735f" + } + } + } + ], + "date": "2017-11-15T22:26:13+00:00", + "message": "Add .keep file\n", + "type": "commit" + } + }, + "truncated": false, + "created": false, + "closed": true, + "new": null + } + ] + }, + "actor": { + "username": "dhollinger3", + "type": "user", + "display_name": "David Hollinger III", + "uuid": "{9a151b63-a0fb-4a20-a01f-99aefae76ac0}", + "links": { + "self": { + "href": "https://api.bitbucket.org/2.0/users/dhollinger3" + }, + "html": { + "href": "https://bitbucket.org/dhollinger3/" + }, + "avatar": { + "href": "https://bitbucket.org/account/dhollinger3/avatar/32/" + } + } + }, + "repository": { + "scm": "git", + "website": "", + "name": "puppet-r10k", + "links": { + "self": { + "href": "https://api.bitbucket.org/2.0/repositories/dhollinger3/puppet-r10k" + }, + "html": { + "href": "https://bitbucket.org/dhollinger3/puppet-r10k" + }, + "avatar": { + "href": "https://bitbucket.org/dhollinger3/puppet-r10k/avatar/32/" + } + }, + "full_name": "dhollinger3/puppet-r10k", + "owner": { + "username": "dhollinger3", + "type": "user", + "display_name": "David Hollinger III", + "uuid": "{9a151b63-a0fb-4a20-a01f-99aefae76ac0}", + "links": { + "self": { + "href": "https://api.bitbucket.org/2.0/users/dhollinger3" + }, + "html": { + "href": "https://bitbucket.org/dhollinger3/" + }, + "avatar": { + "href": "https://bitbucket.org/account/dhollinger3/avatar/32/" + } + } + }, + "type": "repository", + "is_private": true, + "uuid": "{f2d7282e-accb-46a1-b9d0-44bfe61b5af4}" + } +} \ No newline at end of file diff --git a/spec/fixtures/bitbucket/update.json b/spec/fixtures/bitbucket/update.json new file mode 100644 index 0000000..1a5ae2f --- /dev/null +++ b/spec/fixtures/bitbucket/update.json @@ -0,0 +1,254 @@ +{ + "push": { + "changes": [ + { + "forced": false, + "old": { + "type": "branch", + "name": "feature_branch", + "links": { + "commits": { + "href": "https://api.bitbucket.org/2.0/repositories/dhollinger3/puppet-r10k/commits/feature_branch" + }, + "self": { + "href": "https://api.bitbucket.org/2.0/repositories/dhollinger3/puppet-r10k/refs/branches/feature_branch" + }, + "html": { + "href": "https://bitbucket.org/dhollinger3/puppet-r10k/branch/feature_branch" + } + }, + "target": { + "hash": "65b4b4b14af68439fcd3ed0b7a13a80154e4735f", + "links": { + "self": { + "href": "https://api.bitbucket.org/2.0/repositories/dhollinger3/puppet-r10k/commit/65b4b4b14af68439fcd3ed0b7a13a80154e4735f" + }, + "html": { + "href": "https://bitbucket.org/dhollinger3/puppet-r10k/commits/65b4b4b14af68439fcd3ed0b7a13a80154e4735f" + } + }, + "author": { + "raw": "Tim Meusel ", + "type": "author" + }, + "parents": [ + { + "type": "commit", + "hash": "053ae795d57ebe1b435a9bdde47f8da72f179422", + "links": { + "self": { + "href": "https://api.bitbucket.org/2.0/repositories/dhollinger3/puppet-r10k/commit/053ae795d57ebe1b435a9bdde47f8da72f179422" + }, + "html": { + "href": "https://bitbucket.org/dhollinger3/puppet-r10k/commits/053ae795d57ebe1b435a9bdde47f8da72f179422" + } + } + } + ], + "date": "2017-10-11T18:39:12+00:00", + "message": "[blacksmith] Bump version to 6.2.1-rc0\n", + "type": "commit" + } + }, + "links": { + "commits": { + "href": "https://api.bitbucket.org/2.0/repositories/dhollinger3/puppet-r10k/commits?include=31dfeec60f7f864b3f91ec6c61264595e1198ab8&exclude=65b4b4b14af68439fcd3ed0b7a13a80154e4735f" + }, + "html": { + "href": "https://bitbucket.org/dhollinger3/puppet-r10k/branches/compare/31dfeec60f7f864b3f91ec6c61264595e1198ab8..65b4b4b14af68439fcd3ed0b7a13a80154e4735f" + }, + "diff": { + "href": "https://api.bitbucket.org/2.0/repositories/dhollinger3/puppet-r10k/diff/31dfeec60f7f864b3f91ec6c61264595e1198ab8..65b4b4b14af68439fcd3ed0b7a13a80154e4735f" + } + }, + "truncated": false, + "commits": [ + { + "hash": "31dfeec60f7f864b3f91ec6c61264595e1198ab8", + "links": { + "self": { + "href": "https://api.bitbucket.org/2.0/repositories/dhollinger3/puppet-r10k/commit/31dfeec60f7f864b3f91ec6c61264595e1198ab8" + }, + "comments": { + "href": "https://api.bitbucket.org/2.0/repositories/dhollinger3/puppet-r10k/commit/31dfeec60f7f864b3f91ec6c61264595e1198ab8/comments" + }, + "patch": { + "href": "https://api.bitbucket.org/2.0/repositories/dhollinger3/puppet-r10k/patch/31dfeec60f7f864b3f91ec6c61264595e1198ab8" + }, + "html": { + "href": "https://bitbucket.org/dhollinger3/puppet-r10k/commits/31dfeec60f7f864b3f91ec6c61264595e1198ab8" + }, + "diff": { + "href": "https://api.bitbucket.org/2.0/repositories/dhollinger3/puppet-r10k/diff/31dfeec60f7f864b3f91ec6c61264595e1198ab8" + }, + "approve": { + "href": "https://api.bitbucket.org/2.0/repositories/dhollinger3/puppet-r10k/commit/31dfeec60f7f864b3f91ec6c61264595e1198ab8/approve" + }, + "statuses": { + "href": "https://api.bitbucket.org/2.0/repositories/dhollinger3/puppet-r10k/commit/31dfeec60f7f864b3f91ec6c61264595e1198ab8/statuses" + } + }, + "author": { + "raw": "David Hollinger ", + "type": "author", + "user": { + "username": "dhollinger3", + "type": "user", + "display_name": "David Hollinger III", + "uuid": "{9a151b63-a0fb-4a20-a01f-99aefae76ac0}", + "links": { + "self": { + "href": "https://api.bitbucket.org/2.0/users/dhollinger3" + }, + "html": { + "href": "https://bitbucket.org/dhollinger3/" + }, + "avatar": { + "href": "https://bitbucket.org/account/dhollinger3/avatar/32/" + } + } + } + }, + "parents": [ + { + "type": "commit", + "hash": "65b4b4b14af68439fcd3ed0b7a13a80154e4735f", + "links": { + "self": { + "href": "https://api.bitbucket.org/2.0/repositories/dhollinger3/puppet-r10k/commit/65b4b4b14af68439fcd3ed0b7a13a80154e4735f" + }, + "html": { + "href": "https://bitbucket.org/dhollinger3/puppet-r10k/commits/65b4b4b14af68439fcd3ed0b7a13a80154e4735f" + } + } + } + ], + "date": "2017-11-15T22:26:13+00:00", + "message": "Add .keep file\n", + "type": "commit" + } + ], + "created": false, + "closed": false, + "new": { + "type": "branch", + "name": "feature_branch", + "links": { + "commits": { + "href": "https://api.bitbucket.org/2.0/repositories/dhollinger3/puppet-r10k/commits/feature_branch" + }, + "self": { + "href": "https://api.bitbucket.org/2.0/repositories/dhollinger3/puppet-r10k/refs/branches/feature_branch" + }, + "html": { + "href": "https://bitbucket.org/dhollinger3/puppet-r10k/branch/feature_branch" + } + }, + "target": { + "hash": "31dfeec60f7f864b3f91ec6c61264595e1198ab8", + "links": { + "self": { + "href": "https://api.bitbucket.org/2.0/repositories/dhollinger3/puppet-r10k/commit/31dfeec60f7f864b3f91ec6c61264595e1198ab8" + }, + "html": { + "href": "https://bitbucket.org/dhollinger3/puppet-r10k/commits/31dfeec60f7f864b3f91ec6c61264595e1198ab8" + } + }, + "author": { + "raw": "David Hollinger ", + "type": "author", + "user": { + "username": "dhollinger3", + "type": "user", + "display_name": "David Hollinger III", + "uuid": "{9a151b63-a0fb-4a20-a01f-99aefae76ac0}", + "links": { + "self": { + "href": "https://api.bitbucket.org/2.0/users/dhollinger3" + }, + "html": { + "href": "https://bitbucket.org/dhollinger3/" + }, + "avatar": { + "href": "https://bitbucket.org/account/dhollinger3/avatar/32/" + } + } + } + }, + "parents": [ + { + "type": "commit", + "hash": "65b4b4b14af68439fcd3ed0b7a13a80154e4735f", + "links": { + "self": { + "href": "https://api.bitbucket.org/2.0/repositories/dhollinger3/puppet-r10k/commit/65b4b4b14af68439fcd3ed0b7a13a80154e4735f" + }, + "html": { + "href": "https://bitbucket.org/dhollinger3/puppet-r10k/commits/65b4b4b14af68439fcd3ed0b7a13a80154e4735f" + } + } + } + ], + "date": "2017-11-15T22:26:13+00:00", + "message": "Add .keep file\n", + "type": "commit" + } + } + } + ] + }, + "actor": { + "username": "dhollinger3", + "type": "user", + "display_name": "David Hollinger III", + "uuid": "{9a151b63-a0fb-4a20-a01f-99aefae76ac0}", + "links": { + "self": { + "href": "https://api.bitbucket.org/2.0/users/dhollinger3" + }, + "html": { + "href": "https://bitbucket.org/dhollinger3/" + }, + "avatar": { + "href": "https://bitbucket.org/account/dhollinger3/avatar/32/" + } + } + }, + "repository": { + "scm": "git", + "website": "", + "name": "puppet-r10k", + "links": { + "self": { + "href": "https://api.bitbucket.org/2.0/repositories/dhollinger3/puppet-r10k" + }, + "html": { + "href": "https://bitbucket.org/dhollinger3/puppet-r10k" + }, + "avatar": { + "href": "https://bitbucket.org/dhollinger3/puppet-r10k/avatar/32/" + } + }, + "full_name": "dhollinger3/puppet-r10k", + "owner": { + "username": "dhollinger3", + "type": "user", + "display_name": "David Hollinger III", + "uuid": "{9a151b63-a0fb-4a20-a01f-99aefae76ac0}", + "links": { + "self": { + "href": "https://api.bitbucket.org/2.0/users/dhollinger3" + }, + "html": { + "href": "https://bitbucket.org/dhollinger3/" + }, + "avatar": { + "href": "https://bitbucket.org/account/dhollinger3/avatar/32/" + } + } + }, + "type": "repository", + "is_private": true, + "uuid": "{f2d7282e-accb-46a1-b9d0-44bfe61b5af4}" + } +} \ No newline at end of file diff --git a/spec/fixtures/github/create.json b/spec/fixtures/github/create.json new file mode 100644 index 0000000..ce034c7 --- /dev/null +++ b/spec/fixtures/github/create.json @@ -0,0 +1,137 @@ +{ + "zen": "Favor focus over features.", + "hook_id": 18017662, + "hook": { + "type": "Repository", + "id": 18017662, + "name": "web", + "active": true, + "events": [ + "push" + ], + "config": { + "content_type": "json", + "insecure_ssl": "0", + "url": "https://moduletux.com" + }, + "updated_at": "2017-11-15T22:46:15Z", + "created_at": "2017-11-15T22:46:15Z", + "url": "https://api.github.com/repos/moduletux/puppet-r10k/hooks/18017662", + "test_url": "https://api.github.com/repos/moduletux/puppet-r10k/hooks/18017662/test", + "ping_url": "https://api.github.com/repos/moduletux/puppet-r10k/hooks/18017662/pings", + "last_response": { + "code": null, + "status": "unused", + "message": null + } + }, + "repository": { + "id": 110895309, + "name": "puppet-r10k", + "full_name": "moduletux/puppet-r10k", + "owner": { + "login": "moduletux", + "id": 15914432, + "avatar_url": "https://avatars3.githubusercontent.com/u/15914432?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/moduletux", + "html_url": "https://github.com/moduletux", + "followers_url": "https://api.github.com/users/moduletux/followers", + "following_url": "https://api.github.com/users/moduletux/following{/other_user}", + "gists_url": "https://api.github.com/users/moduletux/gists{/gist_id}", + "starred_url": "https://api.github.com/users/moduletux/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/moduletux/subscriptions", + "organizations_url": "https://api.github.com/users/moduletux/orgs", + "repos_url": "https://api.github.com/users/moduletux/repos", + "events_url": "https://api.github.com/users/moduletux/events{/privacy}", + "received_events_url": "https://api.github.com/users/moduletux/received_events", + "type": "Organization", + "site_admin": false + }, + "private": false, + "html_url": "https://github.com/moduletux/puppet-r10k", + "description": null, + "fork": false, + "url": "https://api.github.com/repos/moduletux/puppet-r10k", + "forks_url": "https://api.github.com/repos/moduletux/puppet-r10k/forks", + "keys_url": "https://api.github.com/repos/moduletux/puppet-r10k/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/moduletux/puppet-r10k/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/moduletux/puppet-r10k/teams", + "hooks_url": "https://api.github.com/repos/moduletux/puppet-r10k/hooks", + "issue_events_url": "https://api.github.com/repos/moduletux/puppet-r10k/issues/events{/number}", + "events_url": "https://api.github.com/repos/moduletux/puppet-r10k/events", + "assignees_url": "https://api.github.com/repos/moduletux/puppet-r10k/assignees{/user}", + "branches_url": "https://api.github.com/repos/moduletux/puppet-r10k/branches{/branch}", + "tags_url": "https://api.github.com/repos/moduletux/puppet-r10k/tags", + "blobs_url": "https://api.github.com/repos/moduletux/puppet-r10k/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/moduletux/puppet-r10k/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/moduletux/puppet-r10k/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/moduletux/puppet-r10k/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/moduletux/puppet-r10k/statuses/{sha}", + "languages_url": "https://api.github.com/repos/moduletux/puppet-r10k/languages", + "stargazers_url": "https://api.github.com/repos/moduletux/puppet-r10k/stargazers", + "contributors_url": "https://api.github.com/repos/moduletux/puppet-r10k/contributors", + "subscribers_url": "https://api.github.com/repos/moduletux/puppet-r10k/subscribers", + "subscription_url": "https://api.github.com/repos/moduletux/puppet-r10k/subscription", + "commits_url": "https://api.github.com/repos/moduletux/puppet-r10k/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/moduletux/puppet-r10k/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/moduletux/puppet-r10k/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/moduletux/puppet-r10k/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/moduletux/puppet-r10k/contents/{+path}", + "compare_url": "https://api.github.com/repos/moduletux/puppet-r10k/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/moduletux/puppet-r10k/merges", + "archive_url": "https://api.github.com/repos/moduletux/puppet-r10k/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/moduletux/puppet-r10k/downloads", + "issues_url": "https://api.github.com/repos/moduletux/puppet-r10k/issues{/number}", + "pulls_url": "https://api.github.com/repos/moduletux/puppet-r10k/pulls{/number}", + "milestones_url": "https://api.github.com/repos/moduletux/puppet-r10k/milestones{/number}", + "notifications_url": "https://api.github.com/repos/moduletux/puppet-r10k/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/moduletux/puppet-r10k/labels{/name}", + "releases_url": "https://api.github.com/repos/moduletux/puppet-r10k/releases{/id}", + "deployments_url": "https://api.github.com/repos/moduletux/puppet-r10k/deployments", + "created_at": "2017-11-15T22:45:40Z", + "updated_at": "2017-11-15T22:45:40Z", + "pushed_at": "2017-11-15T22:45:40Z", + "git_url": "git://github.com/moduletux/puppet-r10k.git", + "ssh_url": "git@github.com:moduletux/puppet-r10k.git", + "clone_url": "https://github.com/moduletux/puppet-r10k.git", + "svn_url": "https://github.com/moduletux/puppet-r10k", + "homepage": null, + "size": 0, + "stargazers_count": 0, + "watchers_count": 0, + "language": null, + "has_issues": true, + "has_projects": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": false, + "forks_count": 0, + "mirror_url": null, + "archived": false, + "open_issues_count": 0, + "forks": 0, + "open_issues": 0, + "watchers": 0, + "default_branch": "master" + }, + "sender": { + "login": "dhollinger", + "id": 2914211, + "avatar_url": "https://avatars1.githubusercontent.com/u/2914211?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/dhollinger", + "html_url": "https://github.com/dhollinger", + "followers_url": "https://api.github.com/users/dhollinger/followers", + "following_url": "https://api.github.com/users/dhollinger/following{/other_user}", + "gists_url": "https://api.github.com/users/dhollinger/gists{/gist_id}", + "starred_url": "https://api.github.com/users/dhollinger/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/dhollinger/subscriptions", + "organizations_url": "https://api.github.com/users/dhollinger/orgs", + "repos_url": "https://api.github.com/users/dhollinger/repos", + "events_url": "https://api.github.com/users/dhollinger/events{/privacy}", + "received_events_url": "https://api.github.com/users/dhollinger/received_events", + "type": "User", + "site_admin": false + } +} \ No newline at end of file diff --git a/spec/fixtures/github/delete.json b/spec/fixtures/github/delete.json new file mode 100644 index 0000000..a6669e0 --- /dev/null +++ b/spec/fixtures/github/delete.json @@ -0,0 +1,145 @@ +{ + "ref": "refs/heads/feature_branch", + "before": "31dfeec60f7f864b3f91ec6c61264595e1198ab8", + "after": "0000000000000000000000000000000000000000", + "created": false, + "deleted": true, + "forced": false, + "base_ref": null, + "compare": "https://github.com/moduletux/puppet-r10k/compare/31dfeec60f7f...000000000000", + "commits": [ + + ], + "head_commit": null, + "repository": { + "id": 110895309, + "name": "puppet-r10k", + "full_name": "moduletux/puppet-r10k", + "owner": { + "name": "moduletux", + "email": "david.hollinger@moduletux.com", + "login": "moduletux", + "id": 15914432, + "avatar_url": "https://avatars3.githubusercontent.com/u/15914432?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/moduletux", + "html_url": "https://github.com/moduletux", + "followers_url": "https://api.github.com/users/moduletux/followers", + "following_url": "https://api.github.com/users/moduletux/following{/other_user}", + "gists_url": "https://api.github.com/users/moduletux/gists{/gist_id}", + "starred_url": "https://api.github.com/users/moduletux/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/moduletux/subscriptions", + "organizations_url": "https://api.github.com/users/moduletux/orgs", + "repos_url": "https://api.github.com/users/moduletux/repos", + "events_url": "https://api.github.com/users/moduletux/events{/privacy}", + "received_events_url": "https://api.github.com/users/moduletux/received_events", + "type": "Organization", + "site_admin": false + }, + "private": false, + "html_url": "https://github.com/moduletux/puppet-r10k", + "description": null, + "fork": false, + "url": "https://github.com/moduletux/puppet-r10k", + "forks_url": "https://api.github.com/repos/moduletux/puppet-r10k/forks", + "keys_url": "https://api.github.com/repos/moduletux/puppet-r10k/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/moduletux/puppet-r10k/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/moduletux/puppet-r10k/teams", + "hooks_url": "https://api.github.com/repos/moduletux/puppet-r10k/hooks", + "issue_events_url": "https://api.github.com/repos/moduletux/puppet-r10k/issues/events{/number}", + "events_url": "https://api.github.com/repos/moduletux/puppet-r10k/events", + "assignees_url": "https://api.github.com/repos/moduletux/puppet-r10k/assignees{/user}", + "branches_url": "https://api.github.com/repos/moduletux/puppet-r10k/branches{/branch}", + "tags_url": "https://api.github.com/repos/moduletux/puppet-r10k/tags", + "blobs_url": "https://api.github.com/repos/moduletux/puppet-r10k/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/moduletux/puppet-r10k/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/moduletux/puppet-r10k/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/moduletux/puppet-r10k/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/moduletux/puppet-r10k/statuses/{sha}", + "languages_url": "https://api.github.com/repos/moduletux/puppet-r10k/languages", + "stargazers_url": "https://api.github.com/repos/moduletux/puppet-r10k/stargazers", + "contributors_url": "https://api.github.com/repos/moduletux/puppet-r10k/contributors", + "subscribers_url": "https://api.github.com/repos/moduletux/puppet-r10k/subscribers", + "subscription_url": "https://api.github.com/repos/moduletux/puppet-r10k/subscription", + "commits_url": "https://api.github.com/repos/moduletux/puppet-r10k/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/moduletux/puppet-r10k/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/moduletux/puppet-r10k/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/moduletux/puppet-r10k/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/moduletux/puppet-r10k/contents/{+path}", + "compare_url": "https://api.github.com/repos/moduletux/puppet-r10k/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/moduletux/puppet-r10k/merges", + "archive_url": "https://api.github.com/repos/moduletux/puppet-r10k/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/moduletux/puppet-r10k/downloads", + "issues_url": "https://api.github.com/repos/moduletux/puppet-r10k/issues{/number}", + "pulls_url": "https://api.github.com/repos/moduletux/puppet-r10k/pulls{/number}", + "milestones_url": "https://api.github.com/repos/moduletux/puppet-r10k/milestones{/number}", + "notifications_url": "https://api.github.com/repos/moduletux/puppet-r10k/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/moduletux/puppet-r10k/labels{/name}", + "releases_url": "https://api.github.com/repos/moduletux/puppet-r10k/releases{/id}", + "deployments_url": "https://api.github.com/repos/moduletux/puppet-r10k/deployments", + "created_at": 1510785940, + "updated_at": "2017-11-15T22:47:31Z", + "pushed_at": 1510786089, + "git_url": "git://github.com/moduletux/puppet-r10k.git", + "ssh_url": "git@github.com:moduletux/puppet-r10k.git", + "clone_url": "https://github.com/moduletux/puppet-r10k.git", + "svn_url": "https://github.com/moduletux/puppet-r10k", + "homepage": null, + "size": 0, + "stargazers_count": 0, + "watchers_count": 0, + "language": "Ruby", + "has_issues": true, + "has_projects": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": false, + "forks_count": 0, + "mirror_url": null, + "archived": false, + "open_issues_count": 0, + "forks": 0, + "open_issues": 0, + "watchers": 0, + "default_branch": "master", + "stargazers": 0, + "master_branch": "master", + "organization": "moduletux" + }, + "pusher": { + "name": "dhollinger", + "email": "david.hollinger@moduletux.com" + }, + "organization": { + "login": "moduletux", + "id": 15914432, + "url": "https://api.github.com/orgs/moduletux", + "repos_url": "https://api.github.com/orgs/moduletux/repos", + "events_url": "https://api.github.com/orgs/moduletux/events", + "hooks_url": "https://api.github.com/orgs/moduletux/hooks", + "issues_url": "https://api.github.com/orgs/moduletux/issues", + "members_url": "https://api.github.com/orgs/moduletux/members{/member}", + "public_members_url": "https://api.github.com/orgs/moduletux/public_members{/member}", + "avatar_url": "https://avatars3.githubusercontent.com/u/15914432?v=4", + "description": "" + }, + "sender": { + "login": "dhollinger", + "id": 2914211, + "avatar_url": "https://avatars1.githubusercontent.com/u/2914211?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/dhollinger", + "html_url": "https://github.com/dhollinger", + "followers_url": "https://api.github.com/users/dhollinger/followers", + "following_url": "https://api.github.com/users/dhollinger/following{/other_user}", + "gists_url": "https://api.github.com/users/dhollinger/gists{/gist_id}", + "starred_url": "https://api.github.com/users/dhollinger/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/dhollinger/subscriptions", + "organizations_url": "https://api.github.com/users/dhollinger/orgs", + "repos_url": "https://api.github.com/users/dhollinger/repos", + "events_url": "https://api.github.com/users/dhollinger/events{/privacy}", + "received_events_url": "https://api.github.com/users/dhollinger/received_events", + "type": "User", + "site_admin": false + } +} \ No newline at end of file diff --git a/spec/fixtures/github/update.json b/spec/fixtures/github/update.json new file mode 100644 index 0000000..90ca504 --- /dev/null +++ b/spec/fixtures/github/update.json @@ -0,0 +1,171 @@ +{ + "ref": "refs/heads/feature_branch", + "before": "0000000000000000000000000000000000000000", + "after": "31dfeec60f7f864b3f91ec6c61264595e1198ab8", + "created": true, + "deleted": false, + "forced": false, + "base_ref": "refs/heads/master", + "compare": "https://github.com/moduletux/puppet-r10k/compare/feature_branch", + "commits": [ + + ], + "head_commit": { + "id": "31dfeec60f7f864b3f91ec6c61264595e1198ab8", + "tree_id": "e81259a29717ca0cee5600f4fec2faaf65a35603", + "distinct": true, + "message": "Add .keep file", + "timestamp": "2017-11-15T16:26:13-06:00", + "url": "https://github.com/moduletux/puppet-r10k/commit/31dfeec60f7f864b3f91ec6c61264595e1198ab8", + "author": { + "name": "David Hollinger", + "email": "david.hollinger@nttsecurity.com", + "username": "dhollinger" + }, + "committer": { + "name": "David Hollinger", + "email": "david.hollinger@nttsecurity.com", + "username": "dhollinger" + }, + "added": [ + ".keep" + ], + "removed": [ + + ], + "modified": [ + + ] + }, + "repository": { + "id": 110895309, + "name": "puppet-r10k", + "full_name": "moduletux/puppet-r10k", + "owner": { + "name": "moduletux", + "email": "david.hollinger@moduletux.com", + "login": "moduletux", + "id": 15914432, + "avatar_url": "https://avatars3.githubusercontent.com/u/15914432?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/moduletux", + "html_url": "https://github.com/moduletux", + "followers_url": "https://api.github.com/users/moduletux/followers", + "following_url": "https://api.github.com/users/moduletux/following{/other_user}", + "gists_url": "https://api.github.com/users/moduletux/gists{/gist_id}", + "starred_url": "https://api.github.com/users/moduletux/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/moduletux/subscriptions", + "organizations_url": "https://api.github.com/users/moduletux/orgs", + "repos_url": "https://api.github.com/users/moduletux/repos", + "events_url": "https://api.github.com/users/moduletux/events{/privacy}", + "received_events_url": "https://api.github.com/users/moduletux/received_events", + "type": "Organization", + "site_admin": false + }, + "private": false, + "html_url": "https://github.com/moduletux/puppet-r10k", + "description": null, + "fork": false, + "url": "https://github.com/moduletux/puppet-r10k", + "forks_url": "https://api.github.com/repos/moduletux/puppet-r10k/forks", + "keys_url": "https://api.github.com/repos/moduletux/puppet-r10k/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/moduletux/puppet-r10k/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/moduletux/puppet-r10k/teams", + "hooks_url": "https://api.github.com/repos/moduletux/puppet-r10k/hooks", + "issue_events_url": "https://api.github.com/repos/moduletux/puppet-r10k/issues/events{/number}", + "events_url": "https://api.github.com/repos/moduletux/puppet-r10k/events", + "assignees_url": "https://api.github.com/repos/moduletux/puppet-r10k/assignees{/user}", + "branches_url": "https://api.github.com/repos/moduletux/puppet-r10k/branches{/branch}", + "tags_url": "https://api.github.com/repos/moduletux/puppet-r10k/tags", + "blobs_url": "https://api.github.com/repos/moduletux/puppet-r10k/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/moduletux/puppet-r10k/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/moduletux/puppet-r10k/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/moduletux/puppet-r10k/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/moduletux/puppet-r10k/statuses/{sha}", + "languages_url": "https://api.github.com/repos/moduletux/puppet-r10k/languages", + "stargazers_url": "https://api.github.com/repos/moduletux/puppet-r10k/stargazers", + "contributors_url": "https://api.github.com/repos/moduletux/puppet-r10k/contributors", + "subscribers_url": "https://api.github.com/repos/moduletux/puppet-r10k/subscribers", + "subscription_url": "https://api.github.com/repos/moduletux/puppet-r10k/subscription", + "commits_url": "https://api.github.com/repos/moduletux/puppet-r10k/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/moduletux/puppet-r10k/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/moduletux/puppet-r10k/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/moduletux/puppet-r10k/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/moduletux/puppet-r10k/contents/{+path}", + "compare_url": "https://api.github.com/repos/moduletux/puppet-r10k/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/moduletux/puppet-r10k/merges", + "archive_url": "https://api.github.com/repos/moduletux/puppet-r10k/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/moduletux/puppet-r10k/downloads", + "issues_url": "https://api.github.com/repos/moduletux/puppet-r10k/issues{/number}", + "pulls_url": "https://api.github.com/repos/moduletux/puppet-r10k/pulls{/number}", + "milestones_url": "https://api.github.com/repos/moduletux/puppet-r10k/milestones{/number}", + "notifications_url": "https://api.github.com/repos/moduletux/puppet-r10k/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/moduletux/puppet-r10k/labels{/name}", + "releases_url": "https://api.github.com/repos/moduletux/puppet-r10k/releases{/id}", + "deployments_url": "https://api.github.com/repos/moduletux/puppet-r10k/deployments", + "created_at": 1510785940, + "updated_at": "2017-11-15T22:45:40Z", + "pushed_at": 1510786028, + "git_url": "git://github.com/moduletux/puppet-r10k.git", + "ssh_url": "git@github.com:moduletux/puppet-r10k.git", + "clone_url": "https://github.com/moduletux/puppet-r10k.git", + "svn_url": "https://github.com/moduletux/puppet-r10k", + "homepage": null, + "size": 0, + "stargazers_count": 0, + "watchers_count": 0, + "language": null, + "has_issues": true, + "has_projects": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": false, + "forks_count": 0, + "mirror_url": null, + "archived": false, + "open_issues_count": 0, + "forks": 0, + "open_issues": 0, + "watchers": 0, + "default_branch": "master", + "stargazers": 0, + "master_branch": "master", + "organization": "moduletux" + }, + "pusher": { + "name": "dhollinger", + "email": "david.hollinger@moduletux.com" + }, + "organization": { + "login": "moduletux", + "id": 15914432, + "url": "https://api.github.com/orgs/moduletux", + "repos_url": "https://api.github.com/orgs/moduletux/repos", + "events_url": "https://api.github.com/orgs/moduletux/events", + "hooks_url": "https://api.github.com/orgs/moduletux/hooks", + "issues_url": "https://api.github.com/orgs/moduletux/issues", + "members_url": "https://api.github.com/orgs/moduletux/members{/member}", + "public_members_url": "https://api.github.com/orgs/moduletux/public_members{/member}", + "avatar_url": "https://avatars3.githubusercontent.com/u/15914432?v=4", + "description": "" + }, + "sender": { + "login": "dhollinger", + "id": 2914211, + "avatar_url": "https://avatars1.githubusercontent.com/u/2914211?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/dhollinger", + "html_url": "https://github.com/dhollinger", + "followers_url": "https://api.github.com/users/dhollinger/followers", + "following_url": "https://api.github.com/users/dhollinger/following{/other_user}", + "gists_url": "https://api.github.com/users/dhollinger/gists{/gist_id}", + "starred_url": "https://api.github.com/users/dhollinger/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/dhollinger/subscriptions", + "organizations_url": "https://api.github.com/users/dhollinger/orgs", + "repos_url": "https://api.github.com/users/dhollinger/repos", + "events_url": "https://api.github.com/users/dhollinger/events{/privacy}", + "received_events_url": "https://api.github.com/users/dhollinger/received_events", + "type": "User", + "site_admin": false + } +} \ No newline at end of file diff --git a/spec/fixtures/gitlab/create.json b/spec/fixtures/gitlab/create.json new file mode 100644 index 0000000..8eb095a --- /dev/null +++ b/spec/fixtures/gitlab/create.json @@ -0,0 +1,45 @@ +{ + "object_kind": "push", + "event_name": "push", + "before": "0000000000000000000000000000000000000000", + "after": "31dfeec60f7f864b3f91ec6c61264595e1198ab8", + "ref": "refs/heads/feature_branch", + "checkout_sha": "31dfeec60f7f864b3f91ec6c61264595e1198ab8", + "message": null, + "user_id": 2, + "user_name": "David Hollinger", + "user_username": "dhollinger", + "user_email": "dhollinger@fuslab.net", + "user_avatar": "https://dev-fusion-gitlab.fuslab.net/uploads/-/system/user/avatar/2/avatar.png", + "project_id": 9367, + "project": { + "name": "puppet-r10k", + "description": "", + "web_url": "https://dev-fusion-gitlab.fuslab.net/dhollinger/puppet-r10k", + "avatar_url": null, + "git_ssh_url": "git@dev-fusion-gitlab.fuslab.net:dhollinger/puppet-r10k.git", + "git_http_url": "https://dev-fusion-gitlab.fuslab.net/dhollinger/puppet-r10k.git", + "namespace": "dhollinger", + "visibility_level": 0, + "path_with_namespace": "dhollinger/puppet-r10k", + "default_branch": "master", + "ci_config_path": null, + "homepage": "https://dev-fusion-gitlab.fuslab.net/dhollinger/puppet-r10k", + "url": "git@dev-fusion-gitlab.fuslab.net:dhollinger/puppet-r10k.git", + "ssh_url": "git@dev-fusion-gitlab.fuslab.net:dhollinger/puppet-r10k.git", + "http_url": "https://dev-fusion-gitlab.fuslab.net/dhollinger/puppet-r10k.git" + }, + "commits": [ + + ], + "total_commits_count": 0, + "repository": { + "name": "puppet-r10k", + "url": "git@dev-fusion-gitlab.fuslab.net:dhollinger/puppet-r10k.git", + "description": "", + "homepage": "https://dev-fusion-gitlab.fuslab.net/dhollinger/puppet-r10k", + "git_http_url": "https://dev-fusion-gitlab.fuslab.net/dhollinger/puppet-r10k.git", + "git_ssh_url": "git@dev-fusion-gitlab.fuslab.net:dhollinger/puppet-r10k.git", + "visibility_level": 0 + } +} \ No newline at end of file diff --git a/spec/fixtures/gitlab/delete.json b/spec/fixtures/gitlab/delete.json new file mode 100644 index 0000000..b697dd7 --- /dev/null +++ b/spec/fixtures/gitlab/delete.json @@ -0,0 +1,45 @@ +{ + "object_kind": "push", + "event_name": "push", + "before": "31dfeec60f7f864b3f91ec6c61264595e1198ab8", + "after": "0000000000000000000000000000000000000000", + "ref": "refs/heads/feature_branch", + "checkout_sha": null, + "message": null, + "user_id": 2, + "user_name": "David Hollinger", + "user_username": "dhollinger", + "user_email": "dhollinger@fuslab.net", + "user_avatar": "https://dev-fusion-gitlab.fuslab.net/uploads/-/system/user/avatar/2/avatar.png", + "project_id": 9367, + "project": { + "name": "puppet-r10k", + "description": "", + "web_url": "https://dev-fusion-gitlab.fuslab.net/dhollinger/puppet-r10k", + "avatar_url": null, + "git_ssh_url": "git@dev-fusion-gitlab.fuslab.net:dhollinger/puppet-r10k.git", + "git_http_url": "https://dev-fusion-gitlab.fuslab.net/dhollinger/puppet-r10k.git", + "namespace": "dhollinger", + "visibility_level": 0, + "path_with_namespace": "dhollinger/puppet-r10k", + "default_branch": "master", + "ci_config_path": null, + "homepage": "https://dev-fusion-gitlab.fuslab.net/dhollinger/puppet-r10k", + "url": "git@dev-fusion-gitlab.fuslab.net:dhollinger/puppet-r10k.git", + "ssh_url": "git@dev-fusion-gitlab.fuslab.net:dhollinger/puppet-r10k.git", + "http_url": "https://dev-fusion-gitlab.fuslab.net/dhollinger/puppet-r10k.git" + }, + "commits": [ + + ], + "total_commits_count": 0, + "repository": { + "name": "puppet-r10k", + "url": "git@dev-fusion-gitlab.fuslab.net:dhollinger/puppet-r10k.git", + "description": "", + "homepage": "https://dev-fusion-gitlab.fuslab.net/dhollinger/puppet-r10k", + "git_http_url": "https://dev-fusion-gitlab.fuslab.net/dhollinger/puppet-r10k.git", + "git_ssh_url": "git@dev-fusion-gitlab.fuslab.net:dhollinger/puppet-r10k.git", + "visibility_level": 0 + } +} \ No newline at end of file diff --git a/spec/fixtures/gitlab/update.json b/spec/fixtures/gitlab/update.json new file mode 100644 index 0000000..8eb095a --- /dev/null +++ b/spec/fixtures/gitlab/update.json @@ -0,0 +1,45 @@ +{ + "object_kind": "push", + "event_name": "push", + "before": "0000000000000000000000000000000000000000", + "after": "31dfeec60f7f864b3f91ec6c61264595e1198ab8", + "ref": "refs/heads/feature_branch", + "checkout_sha": "31dfeec60f7f864b3f91ec6c61264595e1198ab8", + "message": null, + "user_id": 2, + "user_name": "David Hollinger", + "user_username": "dhollinger", + "user_email": "dhollinger@fuslab.net", + "user_avatar": "https://dev-fusion-gitlab.fuslab.net/uploads/-/system/user/avatar/2/avatar.png", + "project_id": 9367, + "project": { + "name": "puppet-r10k", + "description": "", + "web_url": "https://dev-fusion-gitlab.fuslab.net/dhollinger/puppet-r10k", + "avatar_url": null, + "git_ssh_url": "git@dev-fusion-gitlab.fuslab.net:dhollinger/puppet-r10k.git", + "git_http_url": "https://dev-fusion-gitlab.fuslab.net/dhollinger/puppet-r10k.git", + "namespace": "dhollinger", + "visibility_level": 0, + "path_with_namespace": "dhollinger/puppet-r10k", + "default_branch": "master", + "ci_config_path": null, + "homepage": "https://dev-fusion-gitlab.fuslab.net/dhollinger/puppet-r10k", + "url": "git@dev-fusion-gitlab.fuslab.net:dhollinger/puppet-r10k.git", + "ssh_url": "git@dev-fusion-gitlab.fuslab.net:dhollinger/puppet-r10k.git", + "http_url": "https://dev-fusion-gitlab.fuslab.net/dhollinger/puppet-r10k.git" + }, + "commits": [ + + ], + "total_commits_count": 0, + "repository": { + "name": "puppet-r10k", + "url": "git@dev-fusion-gitlab.fuslab.net:dhollinger/puppet-r10k.git", + "description": "", + "homepage": "https://dev-fusion-gitlab.fuslab.net/dhollinger/puppet-r10k", + "git_http_url": "https://dev-fusion-gitlab.fuslab.net/dhollinger/puppet-r10k.git", + "git_ssh_url": "git@dev-fusion-gitlab.fuslab.net:dhollinger/puppet-r10k.git", + "visibility_level": 0 + } +} \ No newline at end of file diff --git a/spec/fixtures/tfs/delete.json b/spec/fixtures/tfs/delete.json new file mode 100644 index 0000000..627e9f0 --- /dev/null +++ b/spec/fixtures/tfs/delete.json @@ -0,0 +1,81 @@ +{ + "id": "515e5a38-4fbf-47d5-8af3-8d1843d2045e", + "eventType": "git.push", + "publisherId": "tfs", + "message": { + "text": "David Hollinger III deleted puppet-r10k:feature_branch\r\n(https://moduletux.visualstudio.com/_git/puppet-r10k/#version=GBfeature_branch)", + "html": "David Hollinger III deleted puppet-r10k:feature_branch", + "markdown": "David Hollinger III deleted [puppet-r10k](https://moduletux.visualstudio.com/_git/puppet-r10k/):feature_branch" + }, + "detailedMessage": { + "text": "David Hollinger III deleted puppet-r10k:feature_branch", + "html": "David Hollinger III deleted puppet-r10k:feature_branch", + "markdown": "David Hollinger III deleted [puppet-r10k](https://moduletux.visualstudio.com/_git/puppet-r10k/):[feature_branch](https://moduletux.visualstudio.com/_git/puppet-r10k/#version=GBfeature_branch)" + }, + "resource": { + "refUpdates": [ + { + "name": "refs/heads/feature_branch", + "oldObjectId": "31dfeec60f7f864b3f91ec6c61264595e1198ab8", + "newObjectId": "0000000000000000000000000000000000000000" + } + ], + "repository": { + "id": "1ae20cf9-a815-46cb-95b6-5585f3157ab4", + "name": "puppet-r10k", + "url": "https://moduletux.visualstudio.com/_apis/git/repositories/1ae20cf9-a815-46cb-95b6-5585f3157ab4", + "project": { + "id": "34e0cd1c-8a9b-46ab-a330-b0b9636acc54", + "name": "puppet-r10k", + "url": "https://moduletux.visualstudio.com/_apis/projects/34e0cd1c-8a9b-46ab-a330-b0b9636acc54", + "state": "wellFormed", + "visibility": "unchanged" + }, + "defaultBranch": "refs/heads/master", + "remoteUrl": "https://moduletux.visualstudio.com/_git/puppet-r10k" + }, + "pushedBy": { + "id": "3577b7f3-804d-64fc-9996-1cfc5b4cbf9e", + "displayName": "David Hollinger III", + "uniqueName": "EagleDelta2@gmail.com", + "url": "https://app.vssps.visualstudio.com/A445d5af8-e131-481e-8fe4-b849286482f0/_apis/Identities/3577b7f3-804d-64fc-9996-1cfc5b4cbf9e", + "imageUrl": "https://moduletux.visualstudio.com/_api/_common/identityImage?id=3577b7f3-804d-64fc-9996-1cfc5b4cbf9e" + }, + "pushId": 9, + "date": "2017-11-16T17:34:43.8652448Z", + "url": "https://moduletux.visualstudio.com/_apis/git/repositories/1ae20cf9-a815-46cb-95b6-5585f3157ab4/pushes/9", + "_links": { + "self": { + "href": "https://moduletux.visualstudio.com/_apis/git/repositories/1ae20cf9-a815-46cb-95b6-5585f3157ab4/pushes/9" + }, + "repository": { + "href": "https://moduletux.visualstudio.com/_apis/git/repositories/1ae20cf9-a815-46cb-95b6-5585f3157ab4" + }, + "commits": { + "href": "https://moduletux.visualstudio.com/_apis/git/repositories/1ae20cf9-a815-46cb-95b6-5585f3157ab4/pushes/9/commits" + }, + "pusher": { + "href": "https://app.vssps.visualstudio.com/A445d5af8-e131-481e-8fe4-b849286482f0/_apis/Identities/3577b7f3-804d-64fc-9996-1cfc5b4cbf9e" + }, + "refs": { + "href": "https://moduletux.visualstudio.com/_apis/git/repositories/1ae20cf9-a815-46cb-95b6-5585f3157ab4/refs" + } + } + }, + "resourceVersion": "1.0", + "resourceContainers": { + "collection": { + "id": "7259039b-4e56-4202-aa03-8e6fed42959d", + "baseUrl": "https://moduletux.visualstudio.com/" + }, + "account": { + "id": "445d5af8-e131-481e-8fe4-b849286482f0", + "baseUrl": "https://moduletux.visualstudio.com/" + }, + "project": { + "id": "34e0cd1c-8a9b-46ab-a330-b0b9636acc54", + "baseUrl": "https://moduletux.visualstudio.com/" + } + }, + "createdDate": "2017-11-16T17:34:47.237Z" +} \ No newline at end of file diff --git a/spec/fixtures/tfs/update.json b/spec/fixtures/tfs/update.json new file mode 100644 index 0000000..f887a17 --- /dev/null +++ b/spec/fixtures/tfs/update.json @@ -0,0 +1,83 @@ +{ + "subscriptionId": "df711b37-de02-4655-be37-cef935040149", + "notificationId": 1, + "id": "592c6c87-803a-4e8c-854b-314add077839", + "eventType": "git.push", + "publisherId": "tfs", + "message": { + "text": "David Hollinger III pushed updates to puppet-r10k:feature_branch\r\n(https://moduletux.visualstudio.com/_git/puppet-r10k/#version=GBfeature_branch)", + "html": "David Hollinger III pushed updates to puppet-r10k:feature_branch", + "markdown": "David Hollinger III pushed updates to [puppet-r10k](https://moduletux.visualstudio.com/_git/puppet-r10k/):[feature_branch](https://moduletux.visualstudio.com/_git/puppet-r10k/#version=GBfeature_branch)" + }, + "detailedMessage": { + "text": "David Hollinger III pushed a commit to puppet-r10k:feature_branch\r\n - Add .keep file 31dfeec6 (https://moduletux.visualstudio.com/_git/puppet-r10k/commit/31dfeec60f7f864b3f91ec6c61264595e1198ab8)", + "html": "David Hollinger III pushed a commit to puppet-r10k:feature_branch\r\n", + "markdown": "David Hollinger III pushed a commit to [puppet-r10k](https://moduletux.visualstudio.com/_git/puppet-r10k/):[feature_branch](https://moduletux.visualstudio.com/_git/puppet-r10k/#version=GBfeature_branch)\r\n* Add .keep file [31dfeec6](https://moduletux.visualstudio.com/_git/puppet-r10k/commit/31dfeec60f7f864b3f91ec6c61264595e1198ab8)" + }, + "resource": { + "refUpdates": [ + { + "name": "refs/heads/feature_branch", + "oldObjectId": "0000000000000000000000000000000000000000", + "newObjectId": "31dfeec60f7f864b3f91ec6c61264595e1198ab8" + } + ], + "repository": { + "id": "1ae20cf9-a815-46cb-95b6-5585f3157ab4", + "name": "puppet-r10k", + "url": "https://moduletux.visualstudio.com/_apis/git/repositories/1ae20cf9-a815-46cb-95b6-5585f3157ab4", + "project": { + "id": "34e0cd1c-8a9b-46ab-a330-b0b9636acc54", + "name": "puppet-r10k", + "url": "https://moduletux.visualstudio.com/_apis/projects/34e0cd1c-8a9b-46ab-a330-b0b9636acc54", + "state": "wellFormed", + "visibility": "unchanged" + }, + "defaultBranch": "refs/heads/master", + "remoteUrl": "https://moduletux.visualstudio.com/_git/puppet-r10k" + }, + "pushedBy": { + "id": "3577b7f3-804d-64fc-9996-1cfc5b4cbf9e", + "displayName": "David Hollinger III", + "uniqueName": "EagleDelta2@gmail.com", + "url": "https://app.vssps.visualstudio.com/A445d5af8-e131-481e-8fe4-b849286482f0/_apis/Identities/3577b7f3-804d-64fc-9996-1cfc5b4cbf9e", + "imageUrl": "https://moduletux.visualstudio.com/_api/_common/identityImage?id=3577b7f3-804d-64fc-9996-1cfc5b4cbf9e" + }, + "pushId": 4, + "date": "2017-11-16T17:28:06.2726562Z", + "url": "https://moduletux.visualstudio.com/_apis/git/repositories/1ae20cf9-a815-46cb-95b6-5585f3157ab4/pushes/4", + "_links": { + "self": { + "href": "https://moduletux.visualstudio.com/_apis/git/repositories/1ae20cf9-a815-46cb-95b6-5585f3157ab4/pushes/4" + }, + "repository": { + "href": "https://moduletux.visualstudio.com/_apis/git/repositories/1ae20cf9-a815-46cb-95b6-5585f3157ab4" + }, + "commits": { + "href": "https://moduletux.visualstudio.com/_apis/git/repositories/1ae20cf9-a815-46cb-95b6-5585f3157ab4/pushes/4/commits" + }, + "pusher": { + "href": "https://app.vssps.visualstudio.com/A445d5af8-e131-481e-8fe4-b849286482f0/_apis/Identities/3577b7f3-804d-64fc-9996-1cfc5b4cbf9e" + }, + "refs": { + "href": "https://moduletux.visualstudio.com/_apis/git/repositories/1ae20cf9-a815-46cb-95b6-5585f3157ab4/refs" + } + } + }, + "resourceVersion": "1.0", + "resourceContainers": { + "collection": { + "id": "7259039b-4e56-4202-aa03-8e6fed42959d", + "baseUrl": "https://moduletux.visualstudio.com/" + }, + "account": { + "id": "445d5af8-e131-481e-8fe4-b849286482f0", + "baseUrl": "https://moduletux.visualstudio.com/" + }, + "project": { + "id": "34e0cd1c-8a9b-46ab-a330-b0b9636acc54", + "baseUrl": "https://moduletux.visualstudio.com/" + } + }, + "createdDate": "2017-11-16T17:28:10.1848746Z" +} \ No newline at end of file diff --git a/spec/unit/parsers/webhook_json_parser_spec.rb b/spec/unit/parsers/webhook_json_parser_spec.rb index af51575..9d11105 100644 --- a/spec/unit/parsers/webhook_json_parser_spec.rb +++ b/spec/unit/parsers/webhook_json_parser_spec.rb @@ -1,28 +1,31 @@ require 'spec_helper' describe Sinatra::Parsers::WebhookJsonParser do + services = %w[stash bitbucket github gitlab tfs] let(:result) { subject.call(payload) } - context 'when payload is from stash' do - describe '#call' do - context 'payload is an update' do - let(:payload) { read_fixture('stash/update.json') } - it 'returns correctly populated params hash' do - expect(result).to include( - branch: 'feature_branch', - deleted: false, - module_name: 'r10k', - repo_name: 'puppet-r10k' - ) + services.each do |service| + context "when payload is from #{service}" do + describe '#call' do + context 'payload is an update' do + let(:payload) { read_fixture("#{service}/update.json") } + it 'returns correctly populated params hash' do + expect(result).to include( + branch: 'feature_branch', + deleted: false, + module_name: 'r10k', + repo_name: 'puppet-r10k' + ) + end + it 'does not populate repo_user', unless: service =~ %r{github|gitlab} do + # The stash payload doesn't contain anything we could use for repo_user + expect(result).not_to include(:repo_user) + end end - it 'doesn\'t populate repo_user' do - # The stash payload doesn't contain anything we could use for repo_user - expect(result).not_to include(:repo_user) - end - end - context 'payload is for a delete' do - let(:payload) { read_fixture('stash/delete.json') } - it 'returns params hash with :deleted => true' do - expect(result).to include(deleted: true) + context 'payload is for a delete' do + let(:payload) { read_fixture("#{service}/delete.json") } + it 'returns params hash with :deleted => true' do + expect(result).to include(deleted: true) + end end end end