Fix branch validation for GitHub PR where repo/fork was renamed/deleted

parent 24e5a1e8
...@@ -8,7 +8,7 @@ module Gitlab ...@@ -8,7 +8,7 @@ module Gitlab
end end
def valid? def valid?
repo.present? sha.present? && ref.present?
end end
private private
......
...@@ -49,14 +49,20 @@ describe Gitlab::GithubImport::BranchFormatter, lib: true do ...@@ -49,14 +49,20 @@ describe Gitlab::GithubImport::BranchFormatter, lib: true do
end end
describe '#valid?' do 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)) branch = described_class.new(project, double(raw))
expect(branch.valid?).to eq true expect(branch.valid?).to eq true
end end
it 'returns false when raw repo is blank' do it 'returns false when raw sha is blank' do
branch = described_class.new(project, double(raw.merge(repo: nil))) 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 expect(branch.valid?).to eq false
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment