summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouglas Barbosa Alexandre <dbalexandre@gmail.com>2016-12-01 00:03:12 -0200
committerDouglas Barbosa Alexandre <dbalexandre@gmail.com>2016-12-01 00:03:12 -0200
commit8ca040d8ae66be461f61f52673a87022e6c84204 (patch)
treeab09b2b7588ddf533c4f76f81bfc1ed088c9cb32
parent24e5a1e8db943be346b4f7f4fb49326ad0e5eb9e (diff)
downloadgitlab-ce-8ca040d8ae66be461f61f52673a87022e6c84204.tar.gz
Fix branch validation for GitHub PR where repo/fork was renamed/deleted
-rw-r--r--lib/gitlab/github_import/branch_formatter.rb2
-rw-r--r--spec/lib/gitlab/github_import/branch_formatter_spec.rb12
2 files changed, 10 insertions, 4 deletions
diff --git a/lib/gitlab/github_import/branch_formatter.rb b/lib/gitlab/github_import/branch_formatter.rb
index 4750675ae9d..0a8d05b5fe1 100644
--- a/lib/gitlab/github_import/branch_formatter.rb
+++ b/lib/gitlab/github_import/branch_formatter.rb
@@ -8,7 +8,7 @@ module Gitlab
end
def valid?
- repo.present?
+ sha.present? && ref.present?
end
private
diff --git a/spec/lib/gitlab/github_import/branch_formatter_spec.rb b/spec/lib/gitlab/github_import/branch_formatter_spec.rb
index e5300dbba1e..462caa5b5fe 100644
--- a/spec/lib/gitlab/github_import/branch_formatter_spec.rb
+++ b/spec/lib/gitlab/github_import/branch_formatter_spec.rb
@@ -49,14 +49,20 @@ describe Gitlab::GithubImport::BranchFormatter, lib: true do
end
describe '#valid?' do
- it 'returns true when raw repo is present' do
+ it 'returns true when raw sha and ref are present' do
branch = described_class.new(project, double(raw))
expect(branch.valid?).to eq true
end
- it 'returns false when raw repo is blank' do
- branch = described_class.new(project, double(raw.merge(repo: nil)))
+ it 'returns false when raw sha is blank' do
+ branch = described_class.new(project, double(raw.merge(sha: nil)))
+
+ expect(branch.valid?).to eq false
+ end
+
+ it 'returns false when raw ref is blank' do
+ branch = described_class.new(project, double(raw.merge(ref: nil)))
expect(branch.valid?).to eq false
end