Read about our upcoming Code of Conduct on this issue

This instance will be upgraded to Heptapod 0.28.1 on 2022-01-26 at 16:00 UTC+1 (a few minutes of down time)

Commit 30b0d06e authored by Douwe Maan's avatar Douwe Maan
Browse files

Fix specs

parent d227aa137e29
...@@ -183,7 +183,7 @@ def first_commit ...@@ -183,7 +183,7 @@ def first_commit
def diff_base_commit def diff_base_commit
if merge_request_diff if merge_request_diff
merge_request_diff.base_commit merge_request_diff.base_commit
else elsif source_sha
self.target_project.merge_base_commit(self.source_sha, self.target_branch) self.target_project.merge_base_commit(self.source_sha, self.target_branch)
end end
end end
...@@ -489,7 +489,7 @@ def target_sha ...@@ -489,7 +489,7 @@ def target_sha
end end
def source_sha def source_sha
last_commit.sha last_commit.try(:sha)
end end
def fetch_ref def fetch_ref
......
...@@ -349,7 +349,8 @@ def commit(id = 'HEAD') ...@@ -349,7 +349,8 @@ def commit(id = 'HEAD')
end end
def merge_base_commit(first_commit_id, second_commit_id) def merge_base_commit(first_commit_id, second_commit_id)
repository.commit(repository.merge_base(first_commit_id, second_commit_id)) sha = repository.merge_base(first_commit_id, second_commit_id)
repository.commit(sha) if sha
end end
def saved? def saved?
......
...@@ -589,6 +589,8 @@ def merged_to_root_ref?(branch_name) ...@@ -589,6 +589,8 @@ def merged_to_root_ref?(branch_name)
def merge_base(first_commit_id, second_commit_id) def merge_base(first_commit_id, second_commit_id)
rugged.merge_base(first_commit_id, second_commit_id) rugged.merge_base(first_commit_id, second_commit_id)
rescue Rugged::ReferenceError
nil
end end
def is_ancestor?(ancestor_id, descendant_id) def is_ancestor?(ancestor_id, descendant_id)
......
require 'spec_helper' require 'spec_helper'
describe Ci::Build, models: true do describe Ci::Build, models: true do
let(:project) { FactoryGirl.create :empty_project } let(:project) { FactoryGirl.create :project }
let(:commit) { FactoryGirl.create :ci_commit, project: project } let(:commit) { FactoryGirl.create :ci_commit, project: project }
let(:build) { FactoryGirl.create :ci_build, commit: commit } let(:build) { FactoryGirl.create :ci_build, commit: commit }
......
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