Support project key in audit
This commit is contained in:
@@ -4,14 +4,18 @@ module Bitbucket
|
||||
class Audit
|
||||
include IssueParser
|
||||
|
||||
def initialize(issue_content, _)
|
||||
def initialize(issue_content, command)
|
||||
@workspace = parameter_from_issue("Workspace", issue_content)
|
||||
|
||||
@project_key = command.options["project-key"]
|
||||
end
|
||||
|
||||
def to_a
|
||||
return if @workspace.nil?
|
||||
args = []
|
||||
args.push(["--workspace", @workspace]) unless @workspace.nil?
|
||||
args.push(["--project-key", @project_key]) unless @project_key.nil?
|
||||
|
||||
[["--workspace", @workspace]]
|
||||
return args unless args.empty?
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
RSpec.describe Bitbucket::Audit do
|
||||
let(:audit) { described_class.new(issue_content, nil) }
|
||||
|
||||
describe "#to_a" do
|
||||
let(:audit) { described_class.new(issue_content, command) }
|
||||
let(:command) { Command.new(comment_body) }
|
||||
let(:comment_body) { "/audit" }
|
||||
|
||||
subject { audit.to_a }
|
||||
|
||||
context "when issue_content contains no args" do
|
||||
@@ -16,7 +18,7 @@ RSpec.describe Bitbucket::Audit do
|
||||
it { is_expected.to be_nil }
|
||||
end
|
||||
|
||||
context "when issue_content contains a organization" do
|
||||
context "when issue_content contains a workspace" do
|
||||
let(:issue_content) do
|
||||
<<~ISSUE
|
||||
Workspace: testing
|
||||
@@ -25,5 +27,16 @@ RSpec.describe Bitbucket::Audit do
|
||||
|
||||
it { is_expected.to eq([["--workspace", "testing"]]) }
|
||||
end
|
||||
|
||||
context "when the comment body contains a project key" do
|
||||
let(:issue_content) do
|
||||
<<~ISSUE
|
||||
Workspace: testing
|
||||
ISSUE
|
||||
end
|
||||
let(:comment_body) { "/audit --project-key SW" }
|
||||
|
||||
it { is_expected.to eq([["--workspace", "testing"], ["--project-key", "SW"]]) }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user