lita-reviewme 0.1.1 → 0.2.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fa2d1d7d4d1f1202e1f69d3337d0c2ad5db03847
4
- data.tar.gz: a97b026f8c99771b4c1bf2c8a935c5a75372e8c3
3
+ metadata.gz: 296d9fe4b696d9c8be819c918e3a12956e0011c1
4
+ data.tar.gz: 8fc85b368d684949d10d965fb201c37a5cc2442c
5
5
  SHA512:
6
- metadata.gz: 11d1a2e9924542f61b590f48f172fc42196aa5f54f65208cc9f4e0db3f12988883db8fdf92d306960ae8bf7c433534618d72c2777c1d017488fdaa20684478c4
7
- data.tar.gz: ec9ae4f1e848b4c6611be04b5a2ed1785f42001d1cc734c11dd372baeaf18aa3ba96527ec2d62798cbade5cf751315d22adae6bc0d58d45dbb5e2940ba796bc9
6
+ metadata.gz: 26d277331b7d6e75a962888f799298a5ff4d94aa5dcab135c014bed979a8fafd0f1c67aa166cae576f21a9e0e60899694b8f8d971e78afd26b1cb62e872a36ab
7
+ data.tar.gz: a23072dac424063faa19fbc2f7a796718515fef97b4528199fa4afa1cdd26376bb2d0f6aaa86126848a7f84ca45bbacc6d1738fc6f87d7ac367f34328a035e97
@@ -4,6 +4,11 @@ This project adheres to [Semantic Versioning](http://semver.org/).
4
4
 
5
5
  ## [Unreleased]
6
6
 
7
+ ## [0.2.0] - 2016-01-29
8
+
9
+ ### Added
10
+ - Prevent assignment to review your own PR (#36)
11
+
7
12
  ### Changed
8
13
  - Respond publicly w.r.t. private reply to `reviewers`.
9
14
  - Include room name in private reply to `reviewers`.
@@ -19,6 +24,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
19
24
  ### Added
20
25
  - Start versioning gem.
21
26
 
22
- [Unreleased]: https://github.com/iamvery/lita-reviewme/compare/v0.1.0...HEAD
27
+ [Unreleased]: https://github.com/iamvery/lita-reviewme/compare/v0.2.0...HEAD
28
+ [0.2.0]: https://github.com/iamvery/lita-reviewme/compare/v0.1.0...v0.2.0
23
29
  [0.1.0]: https://github.com/iamvery/lita-reviewme/compare/v0.0.1...v0.1.0
24
30
  [0.0.1]: https://github.com/iamvery/lita-reviewme/compare/a02548...v0.0.1
@@ -85,7 +85,15 @@ module Lita
85
85
  def comment_on_github(response, room: get_room(response))
86
86
  repo = response.match_data[:repo]
87
87
  id = response.match_data[:id]
88
+
88
89
  reviewer = next_reviewer(room)
90
+ begin
91
+ pull_request = github_client.pull_request(repo, id)
92
+ owner = pull_request.user.login
93
+ reviewer = next_reviewer(room) if owner == reviewer
94
+ rescue Octokit::Error
95
+ response.reply("Unable to check who issued the pull request. Sorry if you end up being assigned your own PR!")
96
+ end
89
97
  comment = github_comment(reviewer)
90
98
 
91
99
  begin
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = "lita-reviewme"
3
- spec.version = "0.1.1"
3
+ spec.version = "0.2.0"
4
4
  spec.authors = ["Jay Hayes"]
5
5
  spec.email = ["ur@iamvery.com"]
6
6
  spec.description = %q{A lita handler that helps with code review}
@@ -1,4 +1,5 @@
1
1
  require "spec_helper"
2
+ require "ostruct"
2
3
 
3
4
  describe Lita::Handlers::Reviewme, lita_handler: true do
4
5
  it { is_expected.to route_command("add iamvery to reviews").to :add_reviewer }
@@ -52,17 +53,41 @@ describe Lita::Handlers::Reviewme, lita_handler: true do
52
53
  end
53
54
 
54
55
  describe "#comment_on_github" do
55
- it "posts comment on github" do
56
- repo = "gh_user/repo"
57
- id = "123"
56
+ let(:repo) { "gh_user/repo" }
57
+ let(:id) { "123" }
58
+ let(:pr) do
59
+ OpenStruct.new({ user: OpenStruct.new({ login: "pr-owner" }) })
60
+ end
61
+
62
+ before do
63
+ # Prevent hitting the network for PR info.
64
+ allow_any_instance_of(Octokit::Client).to receive(:pull_request)
65
+ .and_return(pr)
66
+ end
58
67
 
68
+ it "posts comment on github" do
59
69
  expect_any_instance_of(Octokit::Client).to receive(:add_comment)
60
70
  .with(repo, id, ":eyes: @iamvery")
61
71
 
62
72
  send_command("add iamvery to reviews")
63
73
  send_command("review https://github.com/#{repo}/pull/#{id}")
64
74
 
65
- expect(replies.last).to eq("iamvery should be on it...")
75
+ expect(reply).to eq("iamvery should be on it...")
76
+ end
77
+
78
+ it "skips assigning to the GitHub PR owner" do
79
+ expect_any_instance_of(Octokit::Client).to receive(:pull_request)
80
+ .with(repo, id).and_return(pr)
81
+
82
+ expected_reviewer = 'NOT THE PR OWNER'
83
+ expect_any_instance_of(Octokit::Client).to receive(:add_comment)
84
+ .with(repo, id, ":eyes: @#{expected_reviewer}")
85
+
86
+ send_command("add #{pr.user.login} to reviews")
87
+ send_command("add #{expected_reviewer} to reviews")
88
+ send_command("review https://github.com/#{repo}/pull/#{id}")
89
+
90
+ expect(reply).to eq("#{expected_reviewer} should be on it...")
66
91
  end
67
92
 
68
93
  it "handles errors gracefully" do
@@ -74,7 +99,7 @@ describe Lita::Handlers::Reviewme, lita_handler: true do
74
99
  send_command("add iamvery to reviews")
75
100
  send_command("review #{url}")
76
101
 
77
- expect(replies.last).to eq("I couldn't post a comment. (Are the permissions right?) iamvery: :eyes: #{url}")
102
+ expect(reply).to eq("I couldn't post a comment. (Are the permissions right?) iamvery: :eyes: #{url}")
78
103
  end
79
104
  end
80
105
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lita-reviewme
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jay Hayes
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-01-15 00:00:00.000000000 Z
11
+ date: 2016-01-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: lita