-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #408 from europ/Review_command
Review request command
- Loading branch information
Showing
9 changed files
with
72 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
module GithubService | ||
module Commands | ||
class AddReviewer < Base | ||
private | ||
|
||
def _execute(issuer:, value:) | ||
user = value.strip.delete('@') | ||
|
||
if valid_assignee?(user) | ||
issue.add_reviewer(user) | ||
else | ||
issue.add_comment("@#{issuer} '#{user}' is an invalid reviewer, ignoring...") | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
require 'spec_helper' | ||
|
||
RSpec.describe GithubService::Commands::AddReviewer do | ||
subject { described_class.new(issue) } | ||
let(:issue) { double(:fq_repo_name => "org/repo") } | ||
let(:command_issuer) { "nickname" } | ||
|
||
before do | ||
allow(GithubService).to receive(:valid_assignee?).with("org/repo", "good_user") { true } | ||
allow(GithubService).to receive(:valid_assignee?).with("org/repo", "bad_user") { false } | ||
end | ||
|
||
after do | ||
subject.execute!(:issuer => command_issuer, :value => command_value) | ||
end | ||
|
||
context "with a valid user" do | ||
let(:command_value) { "good_user" } | ||
|
||
it "review request that user" do | ||
expect(issue).to receive(:add_reviewer).with("good_user") | ||
end | ||
end | ||
|
||
context "with an invalid user" do | ||
let(:command_value) { "bad_user" } | ||
|
||
it "does not review request, reports failure" do | ||
expect(issue).not_to receive(:add_reviewer) | ||
expect(issue).to receive(:add_comment).with("@#{command_issuer} 'bad_user' is an invalid reviewer, ignoring...") | ||
end | ||
end | ||
end |