right_hook 0.5.0 → 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -24,6 +24,8 @@ module RightHook
24
24
  on_pull_request(owner, repo_name, json['action'], json['pull_request'])
25
25
  when Event::ISSUE
26
26
  on_issue(owner, repo_name, json['action'], json['issue'])
27
+ when Event::ISSUE_COMMENT
28
+ on_issue_comment(owner, repo_name, json['issue'], json['comment'])
27
29
  else
28
30
  halt 500, "Server bug"
29
31
  end
@@ -7,6 +7,8 @@ module RightHook
7
7
  'issues'
8
8
  when PULL_REQUEST
9
9
  'pull_request'
10
+ when ISSUE_COMMENT
11
+ 'issue_comment'
10
12
  else
11
13
  raise ArgumentError, "Unrecognized event_type: #{event_type}"
12
14
  end
@@ -15,10 +17,12 @@ module RightHook
15
17
 
16
18
  ISSUE = 'issue'.freeze
17
19
  PULL_REQUEST = 'pull_request'.freeze
20
+ ISSUE_COMMENT = 'issue_comment'.freeze
18
21
 
19
22
  KNOWN_TYPES = [
20
23
  ISSUE,
21
- PULL_REQUEST
24
+ PULL_REQUEST,
25
+ ISSUE_COMMENT
22
26
  ].freeze
23
27
  end
24
28
  end
@@ -1,3 +1,3 @@
1
1
  module RightHook
2
- VERSION = "0.5.0"
2
+ VERSION = "0.5.1"
3
3
  end
@@ -0,0 +1,137 @@
1
+ require 'spec_helper'
2
+
3
+ describe RightHook::App do
4
+ describe 'Issue Comments' do
5
+ class IssueCommentApp < RightHook::App
6
+ class << self
7
+ attr_accessor :owner, :repo_name, :issue_json, :comment_json
8
+ end
9
+
10
+ def on_issue_comment(owner, repo_name, issue_json, comment_json)
11
+ self.class.owner = owner
12
+ self.class.repo_name = repo_name
13
+ self.class.issue_json = issue_json
14
+ self.class.comment_json = comment_json
15
+ end
16
+
17
+ def secret(owner, repo_name, event_type)
18
+ 'issue_comment' if owner == 'mark-rushakoff' && repo_name == 'right_hook' && event_type == 'issue_comment'
19
+ end
20
+ end
21
+
22
+ def app
23
+ IssueCommentApp
24
+ end
25
+
26
+ before do
27
+ app.owner = app.repo_name = app.issue_json = app.comment_json = nil
28
+ end
29
+
30
+ it 'captures the interesting data' do
31
+ post_with_signature(path: '/hook/mark-rushakoff/right_hook/issue_comment', payload: ISSUE_COMMENT_JSON, secret: 'issue_comment')
32
+ expect(last_response.status).to eq(200)
33
+ expect(app.owner).to eq('mark-rushakoff')
34
+ expect(app.repo_name).to eq('right_hook')
35
+
36
+ # if it has one key it probably has them all
37
+ expect(app.issue_json['title']).to eq('Found a bug')
38
+ expect(app.comment_json['body']).to eq('Me too')
39
+ end
40
+
41
+ it 'fails when the secret is wrong' do
42
+ post_with_signature(path: '/hook/mark-rushakoff/right_hook/issue_comment', payload: ISSUE_COMMENT_JSON, secret: 'wrong')
43
+ expect(last_response.status).to eq(202)
44
+ expect(app.owner).to be_nil
45
+ end
46
+ end
47
+ end
48
+
49
+ # from http://developer.github.com/v3/issues/#get-a-single-issue
50
+ ISSUE_COMMENT_JSON = <<-JSON
51
+ {
52
+ "action": "created",
53
+ "issue": {
54
+ "url": "https://api.github.com/repos/octocat/Hello-World/issues/1347",
55
+ "html_url": "https://github.com/octocat/Hello-World/issues/1347",
56
+ "number": 1347,
57
+ "state": "open",
58
+ "title": "Found a bug",
59
+ "body": "I'm having a problem with this.",
60
+ "user": {
61
+ "login": "octocat",
62
+ "id": 1,
63
+ "avatar_url": "https://github.com/images/error/octocat_happy.gif",
64
+ "gravatar_id": "somehexcode",
65
+ "url": "https://api.github.com/users/octocat"
66
+ },
67
+ "labels": [
68
+ {
69
+ "url": "https://api.github.com/repos/octocat/Hello-World/labels/bug",
70
+ "name": "bug",
71
+ "color": "f29513"
72
+ }
73
+ ],
74
+ "assignee": {
75
+ "login": "octocat",
76
+ "id": 1,
77
+ "avatar_url": "https://github.com/images/error/octocat_happy.gif",
78
+ "gravatar_id": "somehexcode",
79
+ "url": "https://api.github.com/users/octocat"
80
+ },
81
+ "milestone": {
82
+ "url": "https://api.github.com/repos/octocat/Hello-World/milestones/1",
83
+ "number": 1,
84
+ "state": "open",
85
+ "title": "v1.0",
86
+ "description": "",
87
+ "creator": {
88
+ "login": "octocat",
89
+ "id": 1,
90
+ "avatar_url": "https://github.com/images/error/octocat_happy.gif",
91
+ "gravatar_id": "somehexcode",
92
+ "url": "https://api.github.com/users/octocat"
93
+ },
94
+ "open_issues": 4,
95
+ "closed_issues": 8,
96
+ "created_at": "2011-04-10T20:09:31Z",
97
+ "due_on": null
98
+ },
99
+ "comments": 0,
100
+ "pull_request": {
101
+ "html_url": "https://github.com/octocat/Hello-World/pull/1347",
102
+ "diff_url": "https://github.com/octocat/Hello-World/pull/1347.diff",
103
+ "patch_url": "https://github.com/octocat/Hello-World/pull/1347.patch"
104
+ },
105
+ "closed_at": null,
106
+ "created_at": "2011-04-22T13:33:48Z",
107
+ "updated_at": "2011-04-22T13:33:48Z"
108
+ },
109
+ "comment": {
110
+ "id": 1,
111
+ "url": "https://api.github.com/repos/octocat/Hello-World/issues/comments/1",
112
+ "html_url": "https://github.com/octocat/Hello-World/issues/1347#issuecomment-1",
113
+ "body": "Me too",
114
+ "user": {
115
+ "login": "octocat",
116
+ "id": 1,
117
+ "avatar_url": "https://github.com/images/error/octocat_happy.gif",
118
+ "gravatar_id": "somehexcode",
119
+ "url": "https://api.github.com/users/octocat",
120
+ "html_url": "https://github.com/octocat",
121
+ "followers_url": "https://api.github.com/users/octocat/followers",
122
+ "following_url": "https://api.github.com/users/octocat/following{/other_user}",
123
+ "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}",
124
+ "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}",
125
+ "subscriptions_url": "https://api.github.com/users/octocat/subscriptions",
126
+ "organizations_url": "https://api.github.com/users/octocat/orgs",
127
+ "repos_url": "https://api.github.com/users/octocat/repos",
128
+ "events_url": "https://api.github.com/users/octocat/events{/privacy}",
129
+ "received_events_url": "https://api.github.com/users/octocat/received_events",
130
+ "type": "User",
131
+ "site_admin": false
132
+ },
133
+ "created_at": "2011-04-14T16:00:49Z",
134
+ "updated_at": "2011-04-14T16:00:49Z"
135
+ }
136
+ }
137
+ JSON
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: right_hook
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-12-03 00:00:00.000000000 Z
12
+ date: 2014-02-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -180,6 +180,7 @@ files:
180
180
  - lib/right_hook/subscriber.rb
181
181
  - lib/right_hook/version.rb
182
182
  - right_hook.gemspec
183
+ - spec/app/issue_comment_spec.rb
183
184
  - spec/app/issue_spec.rb
184
185
  - spec/app/pull_request_spec.rb
185
186
  - spec/app_spec.rb
@@ -203,12 +204,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
203
204
  - - ! '>='
204
205
  - !ruby/object:Gem::Version
205
206
  version: '0'
207
+ segments:
208
+ - 0
209
+ hash: -495302186993546898
206
210
  required_rubygems_version: !ruby/object:Gem::Requirement
207
211
  none: false
208
212
  requirements:
209
213
  - - ! '>='
210
214
  - !ruby/object:Gem::Version
211
215
  version: '0'
216
+ segments:
217
+ - 0
218
+ hash: -495302186993546898
212
219
  requirements: []
213
220
  rubyforge_project:
214
221
  rubygems_version: 1.8.23
@@ -217,6 +224,7 @@ specification_version: 3
217
224
  summary: Right Hook is a foundation to use when you just want to write a GitHub service
218
225
  hook.
219
226
  test_files:
227
+ - spec/app/issue_comment_spec.rb
220
228
  - spec/app/issue_spec.rb
221
229
  - spec/app/pull_request_spec.rb
222
230
  - spec/app_spec.rb
@@ -227,4 +235,3 @@ test_files:
227
235
  - spec/event_spec.rb
228
236
  - spec/spec_helper.rb
229
237
  - spec/subscriber_spec.rb
230
- has_rdoc: