lita-github_pr_list 0.0.21 → 0.1.0

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.
@@ -1,11 +1,34 @@
1
1
  describe Lita::Handlers::GithubPrList, lita_handler: true do
2
+ let(:issue_comments_passed) { sawyer_resource_array("spec/fixtures/issue_comments_passed.json") }
3
+ let(:issue_comments_passed_design) { sawyer_resource_array("spec/fixtures/issue_comments_passed_design.json") }
4
+ let(:issue_comments_failed) { sawyer_resource_array("spec/fixtures/issue_comments_failed.json") }
5
+ let(:issue_comments_in_review) { sawyer_resource_array("spec/fixtures/issue_comments_in_review.json") }
6
+ let(:issue_comments_fixed) { sawyer_resource_array("spec/fixtures/issue_comments_fixed.json") }
7
+ let(:issue_comments_passed_both) { sawyer_resource_array("spec/fixtures/issue_comments_passed_both.json") }
2
8
  before :each do
3
9
  Lita.config.handlers.github_pr_list.github_organization = 'aaaaaabbbbbbcccccc'
4
10
  Lita.config.handlers.github_pr_list.github_access_token = 'wafflesausages111111'
5
11
  allow_any_instance_of(Lita::Configuration).to receive(:hipchat).and_return(OpenStruct.new({ rooms: ["room"] }))
6
12
  end
7
13
 
14
+ let(:agent) do
15
+ Sawyer::Agent.new "http://example.com/a/" do |conn|
16
+ conn.builder.handlers.delete(Faraday::Adapter::NetHttp)
17
+ conn.adapter :test, Faraday::Adapter::Test::Stubs.new
18
+ end
19
+ end
20
+
21
+ def sawyer_resource_array(file_path)
22
+ resources = []
23
+ JSON.parse(File.read(file_path)).each do |i|
24
+ resources << Sawyer::Resource.new(agent, i)
25
+ end
26
+
27
+ resources
28
+ end
29
+
8
30
  let(:issue_comment_event_passed) { File.read("spec/fixtures/issue_comment_event_passed.json") }
31
+ let(:issue_comment_event_passed_design) { File.read("spec/fixtures/issue_comment_event_passed_design.json") }
9
32
  let(:issue_comment_event_failed) { File.read("spec/fixtures/issue_comment_event_failed.json") }
10
33
  let(:issue_comment_event_failed_hankey) { File.read("spec/fixtures/issue_comment_event_failed_hankey.json") }
11
34
  let(:issue_comment_event_in_review) { File.read("spec/fixtures/issue_comment_event_in_review.json") }
@@ -13,22 +36,52 @@ describe Lita::Handlers::GithubPrList, lita_handler: true do
13
36
 
14
37
  it { is_expected.to route_http(:post, "/comment_hook").to(:comment_hook) }
15
38
 
16
- it "mentions the github user in the room and tell them they passed" do
39
+ it "mentions the github user in the room and tell them they passed , but they need design review" do
40
+ expect_any_instance_of(Octokit::Client).to receive(:issue_comments).and_return(issue_comments_passed)
41
+
17
42
  request = Rack::Request.new("rack.input" => StringIO.new(issue_comment_event_passed))
18
43
  response = Rack::Response.new(['Hello'], 200, { 'Content-Type' => 'text/plain' })
44
+ github_handler = Lita::Handlers::GithubPrList.new robot
45
+ github_handler.comment_hook(request, response)
46
+
47
+ expect(replies.last).to include("@mcwaffle1234 your pull request: Spelling error in the README file has passed DEV REVIEW."\
48
+ " https://github.com/baxterthehacker/public-repo/issues/47"\
49
+ " - You still require DESIGN REVIEW")
50
+ end
51
+
52
+ it "mentions the github user in the room and tell them they passed DESIGN" do
53
+ expect_any_instance_of(Octokit::Client).to receive(:issue_comments).and_return(issue_comments_passed_design)
19
54
 
20
- github_handler = Lita::Handlers::GithubPrList.new
55
+ request = Rack::Request.new("rack.input" => StringIO.new(issue_comment_event_passed_design))
56
+ response = Rack::Response.new(['Hello'], 200, { 'Content-Type' => 'text/plain' })
57
+
58
+ github_handler = Lita::Handlers::GithubPrList.new robot
21
59
  github_handler.comment_hook(request, response)
60
+ expect(replies.last).to include("@mcwaffle1234 your pull request: Spelling error in the README file has passed DESIGN."\
61
+ " https://github.com/baxterthehacker/public-repo/issues/47"\
62
+ " - You still require DEV REVIEW")
63
+ end
22
64
 
65
+ it "mentions the github user in the room and tell them they passed DESIGN - DEV already passed" do
66
+ expect_any_instance_of(Octokit::Client).to receive(:issue_comments).and_return(issue_comments_passed_both)
67
+
68
+ request = Rack::Request.new("rack.input" => StringIO.new(issue_comment_event_passed_design))
69
+ response = Rack::Response.new(['Hello'], 200, { 'Content-Type' => 'text/plain' })
70
+
71
+ github_handler = Lita::Handlers::GithubPrList.new robot
72
+ github_handler.comment_hook(request, response)
23
73
  expect(replies.last).to include("@mcwaffle1234 your pull request: Spelling error in the README file has passed."\
24
74
  " https://github.com/baxterthehacker/public-repo/issues/47")
75
+ expect(replies.last).to_not include(" - You still require DEV REVIEW")
25
76
  end
26
77
 
78
+
27
79
  it "mentions the github user in the room and tell them they failed" do
80
+ expect_any_instance_of(Octokit::Client).to receive(:issue_comments).and_return(issue_comments_failed)
28
81
  request = Rack::Request.new("rack.input" => StringIO.new(issue_comment_event_failed))
29
82
  response = Rack::Response.new(['Hello'], 200, { 'Content-Type' => 'text/plain' })
30
83
 
31
- github_handler = Lita::Handlers::GithubPrList.new
84
+ github_handler = Lita::Handlers::GithubPrList.new robot
32
85
  github_handler.comment_hook(request, response)
33
86
 
34
87
  expect(replies.last).to include("@mcwaffle1234 your pull request: Spelling error in the README file has failed."\
@@ -36,10 +89,11 @@ describe Lita::Handlers::GithubPrList, lita_handler: true do
36
89
  end
37
90
 
38
91
  it "mentions the github user in the room and tell them they failed for hankey too" do
92
+ expect_any_instance_of(Octokit::Client).to receive(:issue_comments).and_return(issue_comments_failed)
39
93
  request = Rack::Request.new("rack.input" => StringIO.new(issue_comment_event_failed_hankey))
40
94
  response = Rack::Response.new(['Hello'], 200, { 'Content-Type' => 'text/plain' })
41
95
 
42
- github_handler = Lita::Handlers::GithubPrList.new
96
+ github_handler = Lita::Handlers::GithubPrList.new robot
43
97
  github_handler.comment_hook(request, response)
44
98
 
45
99
  expect(replies.last).to include("@mcwaffle1234 your pull request: Spelling error in the README file has failed."\
@@ -47,10 +101,12 @@ describe Lita::Handlers::GithubPrList, lita_handler: true do
47
101
  end
48
102
 
49
103
  it "mentions the github user in the room and tell them they are reviewing" do
104
+ expect_any_instance_of(Octokit::Client).to receive(:issue_comments).and_return(issue_comments_in_review)
105
+
50
106
  request = Rack::Request.new("rack.input" => StringIO.new(issue_comment_event_in_review))
51
107
  response = Rack::Response.new(['Hello'], 200, { 'Content-Type' => 'text/plain' })
52
108
 
53
- github_handler = Lita::Handlers::GithubPrList.new
109
+ github_handler = Lita::Handlers::GithubPrList.new robot
54
110
  github_handler.comment_hook(request, response)
55
111
 
56
112
  expect(replies.last).to include("@baxterthehacker is currently reviewing: Spelling error in the README file."\
@@ -58,10 +114,11 @@ describe Lita::Handlers::GithubPrList, lita_handler: true do
58
114
  end
59
115
 
60
116
  it "mentions the github user in the room and tell them it has been fixed" do
117
+ expect_any_instance_of(Octokit::Client).to receive(:issue_comments).and_return(issue_comments_fixed)
61
118
  request = Rack::Request.new("rack.input" => StringIO.new(issue_comment_event_fixed))
62
119
  response = Rack::Response.new(['Hello'], 200, { 'Content-Type' => 'text/plain' })
63
120
 
64
- github_handler = Lita::Handlers::GithubPrList.new
121
+ github_handler = Lita::Handlers::GithubPrList.new robot
65
122
  github_handler.comment_hook(request, response)
66
123
 
67
124
  expect(replies.last).to include("Spelling error in the README file has been fixed:"\
@@ -12,8 +12,7 @@ describe Lita::Handlers::GithubPrList, lita_handler: true do
12
12
  it "sends a message to hipchat - pull request opened" do
13
13
  request = Rack::Request.new("rack.input" => StringIO.new(open_pull_request_response.first))
14
14
  response = Rack::Response.new(['Hello'], 200, {'Content-Type' => 'text/plain'})
15
-
16
- github_handler = Lita::Handlers::GithubPrList.new
15
+ github_handler = Lita::Handlers::GithubPrList.new robot
17
16
  github_handler.pull_request_open_message_hook(request, response)
18
17
 
19
18
  expect(replies.last).to include("@baxterthehacker opened pull request: 'Update the README with new information' in 'baxterthehacker/public-repo'. https://github.com/baxterthehacker/public-repo/pull/48")
@@ -24,7 +24,9 @@ describe Lita::Handlers::GithubPrList, lita_handler: true do
24
24
 
25
25
  let(:one_issue) { sawyer_resource_array("spec/fixtures/one_org_issue_list.json") }
26
26
  let(:two_issues) { sawyer_resource_array("spec/fixtures/two_org_issue_list.json") }
27
+ let(:three_issues) { sawyer_resource_array("spec/fixtures/three_org_issue_list.json") }
27
28
  let(:issue_comments_passed) { sawyer_resource_array("spec/fixtures/issue_comments_passed.json") }
29
+ let(:issue_comments_passed_design) { sawyer_resource_array("spec/fixtures/issue_comments_passed_design.json") }
28
30
  let(:issue_comments_failed) { sawyer_resource_array("spec/fixtures/issue_comments_failed.json") }
29
31
  let(:issue_comments_in_review) { sawyer_resource_array("spec/fixtures/issue_comments_in_review.json") }
30
32
  let(:issue_comments_fixed) { sawyer_resource_array("spec/fixtures/issue_comments_fixed.json") }
@@ -36,8 +38,8 @@ describe Lita::Handlers::GithubPrList, lita_handler: true do
36
38
  it { is_expected.to route_http(:post, "/merge_request_action").to(:merge_request_action) }
37
39
 
38
40
  it "displays a list of pull requests" do
39
- expect_any_instance_of(Octokit::Client).to receive(:org_issues).and_return(two_issues)
40
- expect_any_instance_of(Octokit::Client).to receive(:issue_comments).and_return(issue_comments_passed, issue_comments_failed)
41
+ expect_any_instance_of(Octokit::Client).to receive(:org_issues).and_return(three_issues)
42
+ expect_any_instance_of(Octokit::Client).to receive(:issue_comments).and_return(issue_comments_passed, issue_comments_failed, issue_comments_passed_design)
41
43
 
42
44
  send_command("pr list")
43
45
 
@@ -45,13 +47,14 @@ describe Lita::Handlers::GithubPrList, lita_handler: true do
45
47
  end
46
48
 
47
49
  it "displays the status of the PR (pass/fail)" do
48
- expect_any_instance_of(Octokit::Client).to receive(:org_issues).and_return(two_issues)
49
- expect_any_instance_of(Octokit::Client).to receive(:issue_comments).and_return(issue_comments_passed, issue_comments_failed)
50
+ expect_any_instance_of(Octokit::Client).to receive(:org_issues).and_return(three_issues)
51
+ expect_any_instance_of(Octokit::Client).to receive(:issue_comments).and_return(issue_comments_passed, issue_comments_failed, issue_comments_passed_design)
50
52
 
51
53
  send_command("pr list")
52
54
 
53
- expect(replies.last).to include("waffles (elephant)(elephant)(elephant) Found a bug https://github.com/octocat/Hello-World/pull/1347")
54
- expect(replies.last).to include("waffles (poop) Found a waffle https://github.com/octocat/Hello-World/pull/1347")
55
+ expect(replies.last).to include("waffles (elephant)(art)(art)(art) Found a waffle https://github.com/octocat/Hello-World/pull/1347")
56
+ expect(replies.last).to include("waffles (elephant)(elephant)(elephant)(art) Found a bug https://github.com/octocat/Hello-World/pull/1347")
57
+ expect(replies.last).to include("waffles (poop)(elephant)(art) Found a waffle https://github.com/octocat/Hello-World/pull/1347")
55
58
  end
56
59
 
57
60
  it "displays the status of the PR (in review/fixed)" do
@@ -59,9 +62,8 @@ describe Lita::Handlers::GithubPrList, lita_handler: true do
59
62
  expect_any_instance_of(Octokit::Client).to receive(:issue_comments).and_return(issue_comments_in_review, issue_comments_fixed)
60
63
 
61
64
  send_command("pr list")
62
-
63
- expect(replies.last).to include("waffles (book) Found a bug https://github.com/octocat/Hello-World/pull/1347")
64
- expect(replies.last).to include("waffles (wave) Found a waffle https://github.com/octocat/Hello-World/pull/1347")
65
+ expect(replies.last).to include("waffles (book)(elephant)(art) Found a bug https://github.com/octocat/Hello-World/pull/1347")
66
+ expect(replies.last).to include("waffles (wave)(elephant)(art) Found a waffle https://github.com/octocat/Hello-World/pull/1347")
65
67
  end
66
68
 
67
69
  it "displays the status of the PR (new)" do
@@ -70,7 +72,7 @@ describe Lita::Handlers::GithubPrList, lita_handler: true do
70
72
 
71
73
  send_command("pr list")
72
74
 
73
- expect(replies.last).to include("waffles (new) Found a bug https://github.com/octocat/Hello-World/pull/1347")
75
+ expect(replies.last).to include("waffles (new)(elephant)(art) Found a bug https://github.com/octocat/Hello-World/pull/1347")
74
76
  end
75
77
 
76
78
  it "lists gitlab merge requests" do
@@ -89,7 +91,6 @@ describe Lita::Handlers::GithubPrList, lita_handler: true do
89
91
  expect_any_instance_of(Octokit::Client).to receive(:issue_comments).and_return(issue_comments_new)
90
92
 
91
93
  subject.merge_request_action(gitlab_request_closed, nil)
92
-
93
94
  send_command("pr list")
94
95
 
95
96
  expect(replies.last).to_not include("rails_envs (new) Fixed the things https://gitlab.corp.ads/ama/rails_envs/merge_requests/99")
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lita-github_pr_list
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.21
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael van den Beuken
@@ -10,121 +10,123 @@ authors:
10
10
  - Mathieu Gilbert
11
11
  - Ryan Jones
12
12
  - Darko Dosenovic
13
+ - Jonathan Weyermann
14
+ - Adam Melnyk
13
15
  autorequire:
14
16
  bindir: bin
15
17
  cert_chain: []
16
- date: 2015-07-20 00:00:00.000000000 Z
18
+ date: 2015-11-04 00:00:00.000000000 Z
17
19
  dependencies:
18
20
  - !ruby/object:Gem::Dependency
19
21
  name: lita
20
22
  requirement: !ruby/object:Gem::Requirement
21
23
  requirements:
22
- - - ">="
24
+ - - '>='
23
25
  - !ruby/object:Gem::Version
24
26
  version: '0'
25
27
  type: :runtime
26
28
  prerelease: false
27
29
  version_requirements: !ruby/object:Gem::Requirement
28
30
  requirements:
29
- - - ">="
31
+ - - '>='
30
32
  - !ruby/object:Gem::Version
31
33
  version: '0'
32
34
  - !ruby/object:Gem::Dependency
33
35
  name: octokit
34
36
  requirement: !ruby/object:Gem::Requirement
35
37
  requirements:
36
- - - "~>"
38
+ - - ~>
37
39
  - !ruby/object:Gem::Version
38
40
  version: '3.0'
39
41
  type: :runtime
40
42
  prerelease: false
41
43
  version_requirements: !ruby/object:Gem::Requirement
42
44
  requirements:
43
- - - "~>"
45
+ - - ~>
44
46
  - !ruby/object:Gem::Version
45
47
  version: '3.0'
46
48
  - !ruby/object:Gem::Dependency
47
49
  name: bundler
48
50
  requirement: !ruby/object:Gem::Requirement
49
51
  requirements:
50
- - - "~>"
52
+ - - ~>
51
53
  - !ruby/object:Gem::Version
52
54
  version: '1.6'
53
55
  type: :development
54
56
  prerelease: false
55
57
  version_requirements: !ruby/object:Gem::Requirement
56
58
  requirements:
57
- - - "~>"
59
+ - - ~>
58
60
  - !ruby/object:Gem::Version
59
61
  version: '1.6'
60
62
  - !ruby/object:Gem::Dependency
61
63
  name: rake
62
64
  requirement: !ruby/object:Gem::Requirement
63
65
  requirements:
64
- - - ">="
66
+ - - '>='
65
67
  - !ruby/object:Gem::Version
66
68
  version: '0'
67
69
  type: :development
68
70
  prerelease: false
69
71
  version_requirements: !ruby/object:Gem::Requirement
70
72
  requirements:
71
- - - ">="
73
+ - - '>='
72
74
  - !ruby/object:Gem::Version
73
75
  version: '0'
74
76
  - !ruby/object:Gem::Dependency
75
77
  name: pry
76
78
  requirement: !ruby/object:Gem::Requirement
77
79
  requirements:
78
- - - ">="
80
+ - - '>='
79
81
  - !ruby/object:Gem::Version
80
82
  version: '0'
81
83
  type: :development
82
84
  prerelease: false
83
85
  version_requirements: !ruby/object:Gem::Requirement
84
86
  requirements:
85
- - - ">="
87
+ - - '>='
86
88
  - !ruby/object:Gem::Version
87
89
  version: '0'
88
90
  - !ruby/object:Gem::Dependency
89
91
  name: rspec
90
92
  requirement: !ruby/object:Gem::Requirement
91
93
  requirements:
92
- - - ">="
94
+ - - '>='
93
95
  - !ruby/object:Gem::Version
94
96
  version: '0'
95
97
  type: :development
96
98
  prerelease: false
97
99
  version_requirements: !ruby/object:Gem::Requirement
98
100
  requirements:
99
- - - ">="
101
+ - - '>='
100
102
  - !ruby/object:Gem::Version
101
103
  version: '0'
102
104
  - !ruby/object:Gem::Dependency
103
105
  name: rspec-instafail
104
106
  requirement: !ruby/object:Gem::Requirement
105
107
  requirements:
106
- - - ">="
108
+ - - '>='
107
109
  - !ruby/object:Gem::Version
108
110
  version: '0'
109
111
  type: :development
110
112
  prerelease: false
111
113
  version_requirements: !ruby/object:Gem::Requirement
112
114
  requirements:
113
- - - ">="
115
+ - - '>='
114
116
  - !ruby/object:Gem::Version
115
117
  version: '0'
116
118
  - !ruby/object:Gem::Dependency
117
119
  name: simplecov
118
120
  requirement: !ruby/object:Gem::Requirement
119
121
  requirements:
120
- - - ">="
122
+ - - '>='
121
123
  - !ruby/object:Gem::Version
122
124
  version: '0'
123
125
  type: :development
124
126
  prerelease: false
125
127
  version_requirements: !ruby/object:Gem::Requirement
126
128
  requirements:
127
- - - ">="
129
+ - - '>='
128
130
  - !ruby/object:Gem::Version
129
131
  version: '0'
130
132
  description: List open pull requests for an organization.
@@ -135,16 +137,18 @@ email:
135
137
  - mathieu.gilbert@ama.ab.ca
136
138
  - ryan.michael.jones@gmail.com
137
139
  - darko.dosenovic@ama.ab.ca
140
+ - jonathan.weyermann@ama.ab.ca
141
+ - adam.melnyk@ama.ab.ca
138
142
  executables:
139
143
  - rake
140
144
  - rspec
141
145
  extensions: []
142
146
  extra_rdoc_files: []
143
147
  files:
144
- - ".gitignore"
145
- - ".hound.yml"
146
- - ".rspec"
147
- - ".travis.yml"
148
+ - .gitignore
149
+ - .hound.yml
150
+ - .rspec
151
+ - .travis.yml
148
152
  - Gemfile
149
153
  - LICENSE
150
154
  - README.md
@@ -173,15 +177,19 @@ files:
173
177
  - spec/fixtures/issue_comment_event_fixed.json
174
178
  - spec/fixtures/issue_comment_event_in_review.json
175
179
  - spec/fixtures/issue_comment_event_passed.json
180
+ - spec/fixtures/issue_comment_event_passed_design.json
176
181
  - spec/fixtures/issue_comments_failed.json
177
182
  - spec/fixtures/issue_comments_fixed.json
178
183
  - spec/fixtures/issue_comments_in_review.json
179
184
  - spec/fixtures/issue_comments_new.json
180
185
  - spec/fixtures/issue_comments_passed.json
186
+ - spec/fixtures/issue_comments_passed_both.json
187
+ - spec/fixtures/issue_comments_passed_design.json
181
188
  - spec/fixtures/one_org_issue_list.json
182
189
  - spec/fixtures/open_pull_request_response.json
183
190
  - spec/fixtures/repository_hooks.json
184
191
  - spec/fixtures/repository_list.json
192
+ - spec/fixtures/three_org_issue_list.json
185
193
  - spec/fixtures/two_org_issue_list.json
186
194
  - spec/fixtures/update_pull_request_response.json
187
195
  - spec/lita/handlers/alias_spec.rb
@@ -201,17 +209,17 @@ require_paths:
201
209
  - lib
202
210
  required_ruby_version: !ruby/object:Gem::Requirement
203
211
  requirements:
204
- - - ">="
212
+ - - '>='
205
213
  - !ruby/object:Gem::Version
206
214
  version: '0'
207
215
  required_rubygems_version: !ruby/object:Gem::Requirement
208
216
  requirements:
209
- - - ">="
217
+ - - '>='
210
218
  - !ruby/object:Gem::Version
211
219
  version: '0'
212
220
  requirements: []
213
221
  rubyforge_project:
214
- rubygems_version: 2.2.0
222
+ rubygems_version: 2.0.3
215
223
  signing_key:
216
224
  specification_version: 4
217
225
  summary: List open pull requests for an organization.
@@ -225,15 +233,19 @@ test_files:
225
233
  - spec/fixtures/issue_comment_event_fixed.json
226
234
  - spec/fixtures/issue_comment_event_in_review.json
227
235
  - spec/fixtures/issue_comment_event_passed.json
236
+ - spec/fixtures/issue_comment_event_passed_design.json
228
237
  - spec/fixtures/issue_comments_failed.json
229
238
  - spec/fixtures/issue_comments_fixed.json
230
239
  - spec/fixtures/issue_comments_in_review.json
231
240
  - spec/fixtures/issue_comments_new.json
232
241
  - spec/fixtures/issue_comments_passed.json
242
+ - spec/fixtures/issue_comments_passed_both.json
243
+ - spec/fixtures/issue_comments_passed_design.json
233
244
  - spec/fixtures/one_org_issue_list.json
234
245
  - spec/fixtures/open_pull_request_response.json
235
246
  - spec/fixtures/repository_hooks.json
236
247
  - spec/fixtures/repository_list.json
248
+ - spec/fixtures/three_org_issue_list.json
237
249
  - spec/fixtures/two_org_issue_list.json
238
250
  - spec/fixtures/update_pull_request_response.json
239
251
  - spec/lita/handlers/alias_spec.rb