omg_pull_request 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -25,6 +25,25 @@ Prowl integration allows you to setup a phone to be alerted when the test suite
25
25
 
26
26
  On running the test suite an animated gif can be generated of the lolcommits that were generated by the pull request. This feature was added for the lulz.
27
27
 
28
+ ### Plugin Support
29
+
30
+ Omg Pull Request supports integration with third party plugins. Plugins can be developed for project specific features, or features that most implementations won't use.
31
+
32
+ To create a Plugin, create a class that has the following method signatures.
33
+
34
+ ```
35
+ initialize(attributes) # Mandatory. The test runner will initialize with a hash containing the key `options` with containing the contents of the parsed configuration yaml file.
36
+ test_run(github_pull_request) # Optional. If present, called when the pull request test suite is run
37
+ pull_request_closed(github_pull_request) # Optional. If present, called when the pull request is no longer opened, and is not in the merged state
38
+ pull_request_merged(github_pull_request) # Optional. If present, called when the pull request is no longer opened, and is in the merged state
39
+ ```
40
+
41
+ In addition, if there is a file located in `[omg_dir]/.omgprrc/initialize.rb` that file will be required when the runner is initialized. This can be used to require files, or define classes that will be plugins.
42
+
43
+ The plugins the runner uses is defined at the root level of the config.yml file as a comma separated array of plugin class names.
44
+
45
+ An example of a plugin that you can use can be found [here](https://gist.github.com/4331610).
46
+
28
47
  ## Installation
29
48
 
30
49
  * In a rails project, add `omg_pull_request` to the Gemfile.
data/bin/omg_pull_request CHANGED
@@ -12,4 +12,7 @@ I18n.load_path = [
12
12
  ]
13
13
  I18n.locale = configuration.locale if configuration.locale
14
14
 
15
+ initialize_file = File.expand_path("initialize.rb", configuration.omg_dir)
16
+ require initialize_file if File.exists?(initialize_file)
17
+
15
18
  TestRunner.start_daemon(configuration)
@@ -37,6 +37,15 @@ module OmgPullRequest
37
37
  file
38
38
  end
39
39
 
40
+ def plugins
41
+ return @plugins if @plugins
42
+ p = self.config['plugins'] || ''
43
+
44
+ @plugins = p.split(',').map(&:constantize).collect do |klass|
45
+ klass.new({ :options => config }.with_indifferent_access)
46
+ end
47
+ end
48
+
40
49
  def omg_dir
41
50
  File.join(local_repo, '.omgprrc')
42
51
  end
@@ -16,6 +16,15 @@ module OmgPullRequest
16
16
  animated_shas[issue_number] = get_animated_shas(issue_number) + shas
17
17
  end
18
18
 
19
+ def get_recently_closed(pull_requests)
20
+ current_ids = pull_requests.collect { |a| a.number.to_s }
21
+ closed = (@active_pull_requests || Array.new) - current_ids
22
+ @active_pull_requests = current_ids
23
+
24
+ closed
25
+ end
26
+
27
+
19
28
  private
20
29
 
21
30
  def ran_hash
@@ -21,7 +21,7 @@ module OmgPullRequest
21
21
  def all_logins(pull_request)
22
22
  logins = [pull_request.user.login]
23
23
 
24
- logins |= github_client.issues.comments.list(repo_owner, repo, pull_request.number).collect do |c|
24
+ logins |= github_client.issues.comments.list(repo_owner, repo, 'issue_id' => pull_request.number).collect do |c|
25
25
  c.user.login
26
26
  end
27
27
 
@@ -71,6 +71,10 @@ module OmgPullRequest
71
71
  gist.files[file_name].raw_url
72
72
  end
73
73
 
74
+ def find_pull_request(id)
75
+ github_client.pull_requests.find(repo_owner, repo, id)
76
+ end
77
+
74
78
  private
75
79
 
76
80
  extend Configuration::Helpers
@@ -11,9 +11,26 @@ module OmgPullRequest
11
11
  :github_wrapper => github_wrapper
12
12
  )
13
13
 
14
+ plugins = configuration.plugins
15
+
14
16
  while(true)
15
17
  begin
16
- github_wrapper.pull_requests.each do |pr|
18
+ pull_requests = github_wrapper.pull_requests
19
+ closed_requests = CONTEXT.get_recently_closed(pull_requests)
20
+ closed_requests.each do |closed|
21
+ pr = github_wrapper.find_pull_request(closed)
22
+ merged = pr.merged
23
+
24
+ plugins.each do |plugin|
25
+ if merged && plugin.respond_to?(:pull_request_merged)
26
+ plugin.pull_request_merged(pr)
27
+ elsif !merged && plugin.respond_to?(:pull_request_closed)
28
+ plugin.pull_request_closed(pr)
29
+ end
30
+ end
31
+ end
32
+
33
+ pull_requests.each do |pr|
17
34
  runner = configuration.runner_class.new(
18
35
  :configuration => configuration,
19
36
  :pull_request => pr,
@@ -23,6 +40,12 @@ module OmgPullRequest
23
40
  next if CONTEXT.ran?(runner.request_sha)
24
41
  CONTEXT.ran(runner.request_sha)
25
42
 
43
+ plugins.each do |plugin|
44
+ if plugin.respond_to?(:test_run)
45
+ plugin.test_run(pr)
46
+ end
47
+ end
48
+
26
49
  runner.run
27
50
  end
28
51
 
@@ -1,3 +1,3 @@
1
1
  module OmgPullRequest
2
- VERSION = "0.3.0"
2
+ VERSION = "0.4.0"
3
3
  end
@@ -17,7 +17,7 @@ Gem::Specification.new do |gem|
17
17
 
18
18
  gem.add_runtime_dependency(%q<aws-s3>, ">= 0.6.3")
19
19
  gem.add_runtime_dependency(%q<faraday>, ">= 0.8.4")
20
- gem.add_runtime_dependency(%q<github_api>, ">= 0.7.0")
20
+ gem.add_runtime_dependency(%q<github_api>, ">= 0.8.2")
21
21
  gem.add_runtime_dependency(%q<uuid>, ">= 2.3.5")
22
22
  gem.add_runtime_dependency(%q<rake>, ">= 0.9.2.2")
23
23
  gem.add_runtime_dependency(%q<activesupport>, ">= 3.1.0")
@@ -0,0 +1,282 @@
1
+ HTTP/1.1 200 OK
2
+ Server: nginx/0.8.52
3
+ Date: Fri, 17 Dec 2010 02:02:58 GMT
4
+ Content-Type: application/json; charset=utf-8
5
+ Connection: keep-alive
6
+ Expires: Fri, 17 Dec 2010 02:02:58 UTC
7
+ Cache-Control: no-cache; private; no-store
8
+ Pragma: no-cache
9
+
10
+ {
11
+ "_links": {
12
+ "html": {
13
+ "href": "https://github.com/kenmazaika/pictures/pull/2"
14
+ },
15
+ "self": {
16
+ "href": "https://api.github.com/repos/kenmazaika/pictures/pulls/2"
17
+ },
18
+ "issue": {
19
+ "href": "https://api.github.com/repos/kenmazaika/pictures/issues/2"
20
+ },
21
+ "comments": {
22
+ "href": "https://api.github.com/repos/kenmazaika/pictures/issues/2/comments"
23
+ },
24
+ "review_comments": {
25
+ "href": "https://api.github.com/repos/kenmazaika/pictures/pulls/2/comments"
26
+ }
27
+ },
28
+ "commits_url": "https://github.com/kenmazaika/pictures/pull/2/commits",
29
+ "created_at": "2012-08-25T21:43:20Z",
30
+ "comments_url": "https://api.github.com/repos/kenmazaika/pictures/issues/2/comments",
31
+ "review_comments_url": "https://github.com/kenmazaika/pictures/pull/2/comments",
32
+ "title": "Omg",
33
+ "merged_by": null,
34
+ "milestone": null,
35
+ "merged_at": null,
36
+ "number": 2,
37
+ "issue_url": "https://github.com/kenmazaika/pictures/issues/2",
38
+ "diff_url": "https://github.com/kenmazaika/pictures/pull/2.diff",
39
+ "mergeable": true,
40
+ "changed_files": 73,
41
+ "review_comment_url": "/repos/kenmazaika/pictures/pulls/comments/{number}",
42
+ "body": "> **resolves** [CMGR-2046](https://wherepp.jira.com/browse/CMGR-2046) - Testman Testman\r\n\r\n - Testman Testman\r\n\r\nThis is why I did what I did:\r\n\r\n1.) I thought it was smart\r\n2.) I got paid\r\n3.) I got stabbed in the face",
43
+ "url": "https://api.github.com/repos/kenmazaika/pictures/pulls/2",
44
+ "merged": false,
45
+ "assignee": null,
46
+ "updated_at": "2012-12-17T16:22:48Z",
47
+ "patch_url": "https://github.com/kenmazaika/pictures/pull/2.patch",
48
+ "user": {
49
+ "type": "User",
50
+ "starred_url": "https://api.github.com/users/kenmazaika/starred{/owner}{/repo}",
51
+ "repos_url": "https://api.github.com/users/kenmazaika/repos",
52
+ "url": "https://api.github.com/users/kenmazaika",
53
+ "gravatar_id": "2a9b8f5273d934fe57daa8cf54c3a017",
54
+ "organizations_url": "https://api.github.com/users/kenmazaika/orgs",
55
+ "received_events_url": "https://api.github.com/users/kenmazaika/received_events",
56
+ "followers_url": "https://api.github.com/users/kenmazaika/followers",
57
+ "following_url": "https://api.github.com/users/kenmazaika/following",
58
+ "avatar_url": "https://secure.gravatar.com/avatar/2a9b8f5273d934fe57daa8cf54c3a017?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-user-420.png",
59
+ "gists_url": "https://api.github.com/users/kenmazaika/gists{/gist_id}",
60
+ "events_url": "https://api.github.com/users/kenmazaika/events{/privacy}",
61
+ "subscriptions_url": "https://api.github.com/users/kenmazaika/subscriptions",
62
+ "id": 233615,
63
+ "login": "kenmazaika"
64
+ },
65
+ "mergeable_state": "clean",
66
+ "additions": 88,
67
+ "deletions": 79,
68
+ "state": "open",
69
+ "html_url": "https://github.com/kenmazaika/pictures/pull/2",
70
+ "commits": 4,
71
+ "head": {
72
+ "ref": "omg",
73
+ "repo": {
74
+ "created_at": "2012-04-02T00:55:07Z",
75
+ "homepage": "http://cold-sunset-3667.heroku.com/",
76
+ "has_wiki": true,
77
+ "notifications_url": "https://api.github.com/repos/kenmazaika/pictures/notifications{?since,all,participating}",
78
+ "milestones_url": "https://api.github.com/repos/kenmazaika/pictures/milestones{/number}",
79
+ "archive_url": "https://api.github.com/repos/kenmazaika/pictures/{archive_format}{/ref}",
80
+ "commits_url": "https://api.github.com/repos/kenmazaika/pictures/commits{/sha}",
81
+ "branches_url": "https://api.github.com/repos/kenmazaika/pictures/branches{/branch}",
82
+ "pushed_at": "2012-08-03T22:08:21Z",
83
+ "language": "Ruby",
84
+ "compare_url": "https://api.github.com/repos/kenmazaika/pictures/compare/{base}...{head}",
85
+ "comments_url": "https://api.github.com/repos/kenmazaika/pictures/comments{/number}",
86
+ "subscribers_url": "https://api.github.com/repos/kenmazaika/pictures/subscribers",
87
+ "collaborators_url": "https://api.github.com/repos/kenmazaika/pictures/collaborators{/collaborator}",
88
+ "keys_url": "https://api.github.com/repos/kenmazaika/pictures/keys{/key_id}",
89
+ "owner": {
90
+ "type": "User",
91
+ "starred_url": "https://api.github.com/users/kenmazaika/starred{/owner}{/repo}",
92
+ "repos_url": "https://api.github.com/users/kenmazaika/repos",
93
+ "url": "https://api.github.com/users/kenmazaika",
94
+ "gravatar_id": "2a9b8f5273d934fe57daa8cf54c3a017",
95
+ "organizations_url": "https://api.github.com/users/kenmazaika/orgs",
96
+ "received_events_url": "https://api.github.com/users/kenmazaika/received_events",
97
+ "followers_url": "https://api.github.com/users/kenmazaika/followers",
98
+ "following_url": "https://api.github.com/users/kenmazaika/following",
99
+ "avatar_url": "https://secure.gravatar.com/avatar/2a9b8f5273d934fe57daa8cf54c3a017?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-user-420.png",
100
+ "gists_url": "https://api.github.com/users/kenmazaika/gists{/gist_id}",
101
+ "events_url": "https://api.github.com/users/kenmazaika/events{/privacy}",
102
+ "subscriptions_url": "https://api.github.com/users/kenmazaika/subscriptions",
103
+ "id": 233615,
104
+ "login": "kenmazaika"
105
+ },
106
+ "forks": 0,
107
+ "open_issues": 1,
108
+ "clone_url": "https://github.com/kenmazaika/pictures.git",
109
+ "pulls_url": "https://api.github.com/repos/kenmazaika/pictures/pulls{/number}",
110
+ "issue_comment_url": "https://api.github.com/repos/kenmazaika/pictures/issues/comments/{number}",
111
+ "blobs_url": "https://api.github.com/repos/kenmazaika/pictures/git/blobs{/sha}",
112
+ "subscription_url": "https://api.github.com/repos/kenmazaika/pictures/subscription",
113
+ "teams_url": "https://api.github.com/repos/kenmazaika/pictures/teams",
114
+ "url": "https://api.github.com/repos/kenmazaika/pictures",
115
+ "description": "The example project for file_upload_cache",
116
+ "watchers": 1,
117
+ "git_url": "git://github.com/kenmazaika/pictures.git",
118
+ "has_issues": true,
119
+ "forks_count": 0,
120
+ "labels_url": "https://api.github.com/repos/kenmazaika/pictures/labels{/name}",
121
+ "stargazers_url": "https://api.github.com/repos/kenmazaika/pictures/stargazers",
122
+ "git_tags_url": "https://api.github.com/repos/kenmazaika/pictures/git/tags{/sha}",
123
+ "updated_at": "2012-09-18T18:53:51Z",
124
+ "git_commits_url": "https://api.github.com/repos/kenmazaika/pictures/git/commits{/sha}",
125
+ "contributors_url": "https://api.github.com/repos/kenmazaika/pictures/contributors",
126
+ "hooks_url": "https://api.github.com/repos/kenmazaika/pictures/hooks",
127
+ "watchers_count": 1,
128
+ "open_issues_count": 1,
129
+ "downloads_url": "https://api.github.com/repos/kenmazaika/pictures/downloads",
130
+ "git_refs_url": "https://api.github.com/repos/kenmazaika/pictures/git/refs{/sha}",
131
+ "tags_url": "https://api.github.com/repos/kenmazaika/pictures/tags{/tag}",
132
+ "size": 17952,
133
+ "has_downloads": true,
134
+ "mirror_url": null,
135
+ "contents_url": "https://api.github.com/repos/kenmazaika/pictures/contents/{+path}",
136
+ "issue_events_url": "https://api.github.com/repos/kenmazaika/pictures/issues/events{/number}",
137
+ "fork": false,
138
+ "html_url": "https://github.com/kenmazaika/pictures",
139
+ "languages_url": "https://api.github.com/repos/kenmazaika/pictures/languages",
140
+ "trees_url": "https://api.github.com/repos/kenmazaika/pictures/git/trees{/sha}",
141
+ "events_url": "https://api.github.com/repos/kenmazaika/pictures/events",
142
+ "forks_url": "https://api.github.com/repos/kenmazaika/pictures/forks",
143
+ "name": "pictures",
144
+ "ssh_url": "git@github.com:kenmazaika/pictures.git",
145
+ "merges_url": "https://api.github.com/repos/kenmazaika/pictures/merges",
146
+ "assignees_url": "https://api.github.com/repos/kenmazaika/pictures/assignees{/user}",
147
+ "private": false,
148
+ "full_name": "kenmazaika/pictures",
149
+ "id": 3896551,
150
+ "svn_url": "https://github.com/kenmazaika/pictures",
151
+ "issues_url": "https://api.github.com/repos/kenmazaika/pictures/issues{/number}",
152
+ "statuses_url": "https://api.github.com/repos/kenmazaika/pictures/statuses/{sha}"
153
+ },
154
+ "sha": "ad0a65aeecaba3a1a487f7d066bab25209086b8c",
155
+ "user": {
156
+ "type": "User",
157
+ "starred_url": "https://api.github.com/users/kenmazaika/starred{/owner}{/repo}",
158
+ "repos_url": "https://api.github.com/users/kenmazaika/repos",
159
+ "url": "https://api.github.com/users/kenmazaika",
160
+ "gravatar_id": "2a9b8f5273d934fe57daa8cf54c3a017",
161
+ "organizations_url": "https://api.github.com/users/kenmazaika/orgs",
162
+ "received_events_url": "https://api.github.com/users/kenmazaika/received_events",
163
+ "followers_url": "https://api.github.com/users/kenmazaika/followers",
164
+ "following_url": "https://api.github.com/users/kenmazaika/following",
165
+ "avatar_url": "https://secure.gravatar.com/avatar/2a9b8f5273d934fe57daa8cf54c3a017?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-user-420.png",
166
+ "gists_url": "https://api.github.com/users/kenmazaika/gists{/gist_id}",
167
+ "events_url": "https://api.github.com/users/kenmazaika/events{/privacy}",
168
+ "subscriptions_url": "https://api.github.com/users/kenmazaika/subscriptions",
169
+ "id": 233615,
170
+ "login": "kenmazaika"
171
+ },
172
+ "label": "kenmazaika:omg"
173
+ },
174
+ "comments": 140,
175
+ "id": 2162200,
176
+ "review_comments": 0,
177
+ "base": {
178
+ "ref": "master",
179
+ "repo": {
180
+ "created_at": "2012-04-02T00:55:07Z",
181
+ "homepage": "http://cold-sunset-3667.heroku.com/",
182
+ "has_wiki": true,
183
+ "notifications_url": "https://api.github.com/repos/kenmazaika/pictures/notifications{?since,all,participating}",
184
+ "milestones_url": "https://api.github.com/repos/kenmazaika/pictures/milestones{/number}",
185
+ "archive_url": "https://api.github.com/repos/kenmazaika/pictures/{archive_format}{/ref}",
186
+ "commits_url": "https://api.github.com/repos/kenmazaika/pictures/commits{/sha}",
187
+ "branches_url": "https://api.github.com/repos/kenmazaika/pictures/branches{/branch}",
188
+ "pushed_at": "2012-08-03T22:08:21Z",
189
+ "language": "Ruby",
190
+ "compare_url": "https://api.github.com/repos/kenmazaika/pictures/compare/{base}...{head}",
191
+ "comments_url": "https://api.github.com/repos/kenmazaika/pictures/comments{/number}",
192
+ "subscribers_url": "https://api.github.com/repos/kenmazaika/pictures/subscribers",
193
+ "collaborators_url": "https://api.github.com/repos/kenmazaika/pictures/collaborators{/collaborator}",
194
+ "keys_url": "https://api.github.com/repos/kenmazaika/pictures/keys{/key_id}",
195
+ "owner": {
196
+ "type": "User",
197
+ "starred_url": "https://api.github.com/users/kenmazaika/starred{/owner}{/repo}",
198
+ "repos_url": "https://api.github.com/users/kenmazaika/repos",
199
+ "url": "https://api.github.com/users/kenmazaika",
200
+ "gravatar_id": "2a9b8f5273d934fe57daa8cf54c3a017",
201
+ "organizations_url": "https://api.github.com/users/kenmazaika/orgs",
202
+ "received_events_url": "https://api.github.com/users/kenmazaika/received_events",
203
+ "followers_url": "https://api.github.com/users/kenmazaika/followers",
204
+ "following_url": "https://api.github.com/users/kenmazaika/following",
205
+ "avatar_url": "https://secure.gravatar.com/avatar/2a9b8f5273d934fe57daa8cf54c3a017?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-user-420.png",
206
+ "gists_url": "https://api.github.com/users/kenmazaika/gists{/gist_id}",
207
+ "events_url": "https://api.github.com/users/kenmazaika/events{/privacy}",
208
+ "subscriptions_url": "https://api.github.com/users/kenmazaika/subscriptions",
209
+ "id": 233615,
210
+ "login": "kenmazaika"
211
+ },
212
+ "forks": 0,
213
+ "open_issues": 1,
214
+ "clone_url": "https://github.com/kenmazaika/pictures.git",
215
+ "pulls_url": "https://api.github.com/repos/kenmazaika/pictures/pulls{/number}",
216
+ "issue_comment_url": "https://api.github.com/repos/kenmazaika/pictures/issues/comments/{number}",
217
+ "blobs_url": "https://api.github.com/repos/kenmazaika/pictures/git/blobs{/sha}",
218
+ "subscription_url": "https://api.github.com/repos/kenmazaika/pictures/subscription",
219
+ "teams_url": "https://api.github.com/repos/kenmazaika/pictures/teams",
220
+ "url": "https://api.github.com/repos/kenmazaika/pictures",
221
+ "description": "The example project for file_upload_cache",
222
+ "watchers": 1,
223
+ "git_url": "git://github.com/kenmazaika/pictures.git",
224
+ "has_issues": true,
225
+ "forks_count": 0,
226
+ "labels_url": "https://api.github.com/repos/kenmazaika/pictures/labels{/name}",
227
+ "stargazers_url": "https://api.github.com/repos/kenmazaika/pictures/stargazers",
228
+ "git_tags_url": "https://api.github.com/repos/kenmazaika/pictures/git/tags{/sha}",
229
+ "updated_at": "2012-09-18T18:53:51Z",
230
+ "git_commits_url": "https://api.github.com/repos/kenmazaika/pictures/git/commits{/sha}",
231
+ "contributors_url": "https://api.github.com/repos/kenmazaika/pictures/contributors",
232
+ "hooks_url": "https://api.github.com/repos/kenmazaika/pictures/hooks",
233
+ "watchers_count": 1,
234
+ "open_issues_count": 1,
235
+ "downloads_url": "https://api.github.com/repos/kenmazaika/pictures/downloads",
236
+ "git_refs_url": "https://api.github.com/repos/kenmazaika/pictures/git/refs{/sha}",
237
+ "tags_url": "https://api.github.com/repos/kenmazaika/pictures/tags{/tag}",
238
+ "size": 17952,
239
+ "has_downloads": true,
240
+ "mirror_url": null,
241
+ "contents_url": "https://api.github.com/repos/kenmazaika/pictures/contents/{+path}",
242
+ "issue_events_url": "https://api.github.com/repos/kenmazaika/pictures/issues/events{/number}",
243
+ "fork": false,
244
+ "html_url": "https://github.com/kenmazaika/pictures",
245
+ "languages_url": "https://api.github.com/repos/kenmazaika/pictures/languages",
246
+ "trees_url": "https://api.github.com/repos/kenmazaika/pictures/git/trees{/sha}",
247
+ "events_url": "https://api.github.com/repos/kenmazaika/pictures/events",
248
+ "forks_url": "https://api.github.com/repos/kenmazaika/pictures/forks",
249
+ "name": "pictures",
250
+ "ssh_url": "git@github.com:kenmazaika/pictures.git",
251
+ "merges_url": "https://api.github.com/repos/kenmazaika/pictures/merges",
252
+ "assignees_url": "https://api.github.com/repos/kenmazaika/pictures/assignees{/user}",
253
+ "private": false,
254
+ "full_name": "kenmazaika/pictures",
255
+ "id": 3896551,
256
+ "svn_url": "https://github.com/kenmazaika/pictures",
257
+ "issues_url": "https://api.github.com/repos/kenmazaika/pictures/issues{/number}",
258
+ "statuses_url": "https://api.github.com/repos/kenmazaika/pictures/statuses/{sha}"
259
+ },
260
+ "sha": "e7212923fbea50c72f3122ac05d954cfdcf6761e",
261
+ "user": {
262
+ "type": "User",
263
+ "starred_url": "https://api.github.com/users/kenmazaika/starred{/owner}{/repo}",
264
+ "repos_url": "https://api.github.com/users/kenmazaika/repos",
265
+ "url": "https://api.github.com/users/kenmazaika",
266
+ "gravatar_id": "2a9b8f5273d934fe57daa8cf54c3a017",
267
+ "organizations_url": "https://api.github.com/users/kenmazaika/orgs",
268
+ "received_events_url": "https://api.github.com/users/kenmazaika/received_events",
269
+ "followers_url": "https://api.github.com/users/kenmazaika/followers",
270
+ "following_url": "https://api.github.com/users/kenmazaika/following",
271
+ "avatar_url": "https://secure.gravatar.com/avatar/2a9b8f5273d934fe57daa8cf54c3a017?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-user-420.png",
272
+ "gists_url": "https://api.github.com/users/kenmazaika/gists{/gist_id}",
273
+ "events_url": "https://api.github.com/users/kenmazaika/events{/privacy}",
274
+ "subscriptions_url": "https://api.github.com/users/kenmazaika/subscriptions",
275
+ "id": 233615,
276
+ "login": "kenmazaika"
277
+ },
278
+ "label": "kenmazaika:master"
279
+ },
280
+ "merge_commit_sha": "33c129dc47f7f5b0fb74285389bae4e3934977f9",
281
+ "closed_at": null
282
+ }
@@ -54,7 +54,7 @@ class RunnerTest < MiniTest::Unit::TestCase
54
54
 
55
55
  runner.run
56
56
 
57
- posts = github.issues.comments.list(config[:login], 'omg', pr.number)
57
+ posts = github.issues.comments.list(config[:login], 'omg', 'issue_id' => pr.number)
58
58
  statuses = github.repos.statuses.list(config[:login], 'omg', pr.head.sha)
59
59
  assert_equal 2, posts.count
60
60
  assert_equal "success", statuses.first.state
@@ -79,7 +79,7 @@ class RunnerTest < MiniTest::Unit::TestCase
79
79
 
80
80
  runner.run
81
81
 
82
- posts = github.issues.comments.list(config[:login], 'omg', pr.number)
82
+ posts = github.issues.comments.list(config[:login], 'omg', 'issue_id' => pr.number)
83
83
  statuses = github.repos.statuses.list(config[:login], 'omg', pr.head.sha)
84
84
  assert_equal 2, posts.count
85
85
  assert_equal "pending", statuses.at(1).state
@@ -104,7 +104,7 @@ class RunnerTest < MiniTest::Unit::TestCase
104
104
 
105
105
  runner.run
106
106
 
107
- posts = github.issues.comments.list(config[:login], 'omg', pr.number)
107
+ posts = github.issues.comments.list(config[:login], 'omg', 'issue_id' => pr.number)
108
108
  statuses = github.repos.statuses.list(config[:login], 'omg', pr.head.sha)
109
109
  assert_equal 2, posts.count
110
110
  assert_equal "failure", statuses.first.state
@@ -129,7 +129,7 @@ class RunnerTest < MiniTest::Unit::TestCase
129
129
 
130
130
  runner.run
131
131
 
132
- posts = github.issues.comments.list(config[:login], 'omg', pr.number)
132
+ posts = github.issues.comments.list(config[:login], 'omg', 'issue_id' => pr.number)
133
133
  statuses = github.repos.statuses.list(config[:login], 'omg', pr.head.sha)
134
134
  assert_equal 2, posts.count
135
135
  assert_equal "error", statuses.first.state
@@ -1,26 +1,20 @@
1
1
  class MockPullRequest
2
- def number
3
- 10
2
+ def initialize(attributes={})
3
+ default_attributes = {
4
+ :number => 10,
5
+ :user => MockUser.new,
6
+ :title => "Omg",
7
+ :html_url => "http://omg.com/html_url",
8
+ :head => MockSha.new("HEAD_SHA"),
9
+ :base => MockSha.new("BASE_SHA")
10
+ }
11
+ @attributes = default_attributes.merge(attributes)
4
12
  end
5
13
 
6
- def user
7
- MockUser.new
8
- end
9
-
10
- def html_url
11
- "http://omg.com/html_url"
12
- end
13
-
14
- def head
15
- MockSha.new("HEAD_SHA")
16
- end
17
-
18
- def base
19
- MockSha.new("BASE_SHA")
20
- end
21
-
22
- def title
23
- "Omg"
14
+ [:number, :user, :title, :html_url, :head, :base].each do |field|
15
+ define_method field do
16
+ @attributes[field]
17
+ end
24
18
  end
25
19
 
26
20
  class MockUser
data/test/test_helper.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  require 'minitest/autorun'
2
2
  require 'fakeweb'
3
- require 'mocha'
3
+ require 'mocha/setup'
4
4
 
5
5
  ENV['yml'] = File.join(File.expand_path("..", __FILE__), "fixtures/config.yml")
6
6
  require './lib/omg_pull_request'
@@ -31,6 +31,12 @@ MOCK_STORE = MOCK_CONFIGURATION.storage_class.new(
31
31
  :github_wrapper => MOCK_GITHUB_WRAPPER
32
32
  )
33
33
 
34
+ def fakeweb_find_pull_request
35
+ FakeWeb.register_uri(:get,
36
+ "https://omg:pull_request@api.github.com/repos/kenmazaika/pictures/pulls/2",
37
+ :response => File.expand_path('test/fixtures/find_pull_request'))
38
+ end
39
+
34
40
  def fakeweb_get_pull_request_commits
35
41
  FakeWeb.register_uri(:get,
36
42
  "https://omg:pull_request@api.github.com/repos/kenmazaika/pictures/pulls/10/commits",
@@ -79,3 +85,4 @@ def fakeweb_make_gist
79
85
  "https://omg:pull_request@api.github.com/gists",
80
86
  :response => File.expand_path('test/fixtures/make_gist'))
81
87
  end
88
+
@@ -0,0 +1,39 @@
1
+ require './test/test_helper.rb'
2
+
3
+ module OmgPullRequest
4
+ class ConfigurationTest < MiniTest::Unit::TestCase
5
+ def test_plugins
6
+ conf = { 'plugins' => 'OmgPullRequest::ConfigurationTest::MockPlugin1,OmgPullRequest::ConfigurationTest::MockPlugin2' }
7
+
8
+ configuration = OmgPullRequest::Configuration.new('config' => conf)
9
+ plugins = configuration.plugins
10
+
11
+ plugins.each do |plugin|
12
+ assert_equal({:options => conf }.with_indifferent_access, plugin.attributes)
13
+ assert_equal('mock_plugin_yeah', plugin.to_s)
14
+ end
15
+ end
16
+
17
+ class MockPlugin1
18
+ attr_accessor :attributes
19
+ def initialize(attributes=Hash.new)
20
+ self.attributes = attributes
21
+ end
22
+
23
+ def to_s
24
+ "mock_plugin_yeah"
25
+ end
26
+ end
27
+
28
+ class MockPlugin2
29
+ attr_accessor :attributes
30
+ def initialize(attributes=Hash.new)
31
+ self.attributes = attributes
32
+ end
33
+
34
+ def to_s
35
+ "mock_plugin_yeah"
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,27 @@
1
+ require './test/test_helper.rb'
2
+
3
+ module OmgPullRequest
4
+ class ContextTest < MiniTest::Unit::TestCase
5
+ def test_get_recently_closed
6
+ context = OmgPullRequest::Context.new
7
+
8
+ prs = [
9
+ MockPullRequest.new(:number => 2),
10
+ MockPullRequest.new(:number => 3),
11
+ MockPullRequest.new(:number => 4)
12
+ ]
13
+
14
+ assert_equal [], context.get_recently_closed(prs)
15
+
16
+ prs = [
17
+ MockPullRequest.new(:number => 2),
18
+ MockPullRequest.new(:number => 4),
19
+ MockPullRequest.new(:number => 5)
20
+ ]
21
+
22
+ assert_equal ["3"], context.get_recently_closed(prs)
23
+
24
+ end
25
+
26
+ end
27
+ end
@@ -50,6 +50,12 @@ module OmgPullRequest
50
50
  assert_equal expected_url, github_wrapper.make_gist("omg", "file_name")
51
51
  end
52
52
 
53
+ def test_find_pull_request
54
+ fakeweb_find_pull_request
55
+ pr = github_wrapper.find_pull_request(2)
56
+ assert_equal 2, pr.number
57
+ end
58
+
53
59
  protected
54
60
 
55
61
  def github_wrapper
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omg_pull_request
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -12,11 +12,11 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2012-11-16 00:00:00.000000000 Z
15
+ date: 2012-12-18 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: aws-s3
19
- requirement: !ruby/object:Gem::Requirement
19
+ requirement: &70291716629820 !ruby/object:Gem::Requirement
20
20
  none: false
21
21
  requirements:
22
22
  - - ! '>='
@@ -24,15 +24,10 @@ dependencies:
24
24
  version: 0.6.3
25
25
  type: :runtime
26
26
  prerelease: false
27
- version_requirements: !ruby/object:Gem::Requirement
28
- none: false
29
- requirements:
30
- - - ! '>='
31
- - !ruby/object:Gem::Version
32
- version: 0.6.3
27
+ version_requirements: *70291716629820
33
28
  - !ruby/object:Gem::Dependency
34
29
  name: faraday
35
- requirement: !ruby/object:Gem::Requirement
30
+ requirement: &70291716643700 !ruby/object:Gem::Requirement
36
31
  none: false
37
32
  requirements:
38
33
  - - ! '>='
@@ -40,31 +35,21 @@ dependencies:
40
35
  version: 0.8.4
41
36
  type: :runtime
42
37
  prerelease: false
43
- version_requirements: !ruby/object:Gem::Requirement
44
- none: false
45
- requirements:
46
- - - ! '>='
47
- - !ruby/object:Gem::Version
48
- version: 0.8.4
38
+ version_requirements: *70291716643700
49
39
  - !ruby/object:Gem::Dependency
50
40
  name: github_api
51
- requirement: !ruby/object:Gem::Requirement
41
+ requirement: &70291716662620 !ruby/object:Gem::Requirement
52
42
  none: false
53
43
  requirements:
54
44
  - - ! '>='
55
45
  - !ruby/object:Gem::Version
56
- version: 0.7.0
46
+ version: 0.8.2
57
47
  type: :runtime
58
48
  prerelease: false
59
- version_requirements: !ruby/object:Gem::Requirement
60
- none: false
61
- requirements:
62
- - - ! '>='
63
- - !ruby/object:Gem::Version
64
- version: 0.7.0
49
+ version_requirements: *70291716662620
65
50
  - !ruby/object:Gem::Dependency
66
51
  name: uuid
67
- requirement: !ruby/object:Gem::Requirement
52
+ requirement: &70291716658640 !ruby/object:Gem::Requirement
68
53
  none: false
69
54
  requirements:
70
55
  - - ! '>='
@@ -72,15 +57,10 @@ dependencies:
72
57
  version: 2.3.5
73
58
  type: :runtime
74
59
  prerelease: false
75
- version_requirements: !ruby/object:Gem::Requirement
76
- none: false
77
- requirements:
78
- - - ! '>='
79
- - !ruby/object:Gem::Version
80
- version: 2.3.5
60
+ version_requirements: *70291716658640
81
61
  - !ruby/object:Gem::Dependency
82
62
  name: rake
83
- requirement: !ruby/object:Gem::Requirement
63
+ requirement: &70291716657800 !ruby/object:Gem::Requirement
84
64
  none: false
85
65
  requirements:
86
66
  - - ! '>='
@@ -88,15 +68,10 @@ dependencies:
88
68
  version: 0.9.2.2
89
69
  type: :runtime
90
70
  prerelease: false
91
- version_requirements: !ruby/object:Gem::Requirement
92
- none: false
93
- requirements:
94
- - - ! '>='
95
- - !ruby/object:Gem::Version
96
- version: 0.9.2.2
71
+ version_requirements: *70291716657800
97
72
  - !ruby/object:Gem::Dependency
98
73
  name: activesupport
99
- requirement: !ruby/object:Gem::Requirement
74
+ requirement: &70291716656240 !ruby/object:Gem::Requirement
100
75
  none: false
101
76
  requirements:
102
77
  - - ! '>='
@@ -104,15 +79,10 @@ dependencies:
104
79
  version: 3.1.0
105
80
  type: :runtime
106
81
  prerelease: false
107
- version_requirements: !ruby/object:Gem::Requirement
108
- none: false
109
- requirements:
110
- - - ! '>='
111
- - !ruby/object:Gem::Version
112
- version: 3.1.0
82
+ version_requirements: *70291716656240
113
83
  - !ruby/object:Gem::Dependency
114
84
  name: i18n
115
- requirement: !ruby/object:Gem::Requirement
85
+ requirement: &70291716669020 !ruby/object:Gem::Requirement
116
86
  none: false
117
87
  requirements:
118
88
  - - ! '>='
@@ -120,12 +90,7 @@ dependencies:
120
90
  version: 0.6.0
121
91
  type: :runtime
122
92
  prerelease: false
123
- version_requirements: !ruby/object:Gem::Requirement
124
- none: false
125
- requirements:
126
- - - ! '>='
127
- - !ruby/object:Gem::Version
128
- version: 0.6.0
93
+ version_requirements: *70291716669020
129
94
  description: Have tests run automatically for your Github Pull Request
130
95
  email:
131
96
  - kenmazaika@gmail.com
@@ -164,6 +129,7 @@ files:
164
129
  - test/fixtures/config.yml
165
130
  - test/fixtures/create_comment
166
131
  - test/fixtures/create_status
132
+ - test/fixtures/find_pull_request
167
133
  - test/fixtures/get_statuses
168
134
  - test/fixtures/github_commits
169
135
  - test/fixtures/kenmazaika
@@ -174,6 +140,8 @@ files:
174
140
  - test/mocks/pull_request.rb
175
141
  - test/omg_pull_request/.gitkeep
176
142
  - test/test_helper.rb
143
+ - test/units/omg_pull_request/configuration_test.rb
144
+ - test/units/omg_pull_request/context_test.rb
177
145
  - test/units/omg_pull_request/git_client_test.rb
178
146
  - test/units/omg_pull_request/github_wrapper_test.rb
179
147
  - test/units/omg_pull_request/lolcommits_test.rb
@@ -202,7 +170,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
202
170
  version: '0'
203
171
  requirements: []
204
172
  rubyforge_project:
205
- rubygems_version: 1.8.23
173
+ rubygems_version: 1.8.10
206
174
  signing_key:
207
175
  specification_version: 3
208
176
  summary: Have tests run automatically for your Github Pull Request
@@ -211,6 +179,7 @@ test_files:
211
179
  - test/fixtures/config.yml
212
180
  - test/fixtures/create_comment
213
181
  - test/fixtures/create_status
182
+ - test/fixtures/find_pull_request
214
183
  - test/fixtures/get_statuses
215
184
  - test/fixtures/github_commits
216
185
  - test/fixtures/kenmazaika
@@ -221,6 +190,8 @@ test_files:
221
190
  - test/mocks/pull_request.rb
222
191
  - test/omg_pull_request/.gitkeep
223
192
  - test/test_helper.rb
193
+ - test/units/omg_pull_request/configuration_test.rb
194
+ - test/units/omg_pull_request/context_test.rb
224
195
  - test/units/omg_pull_request/git_client_test.rb
225
196
  - test/units/omg_pull_request/github_wrapper_test.rb
226
197
  - test/units/omg_pull_request/lolcommits_test.rb