Fix specs

This commit is contained in:
Douwe Maan 2016-01-28 15:10:48 +01:00
parent 5cce1278ad
commit 30b0d06e9f
4 changed files with 7 additions and 4 deletions

View file

@ -183,7 +183,7 @@ class MergeRequest < ActiveRecord::Base
def diff_base_commit
if merge_request_diff
merge_request_diff.base_commit
else
elsif source_sha
self.target_project.merge_base_commit(self.source_sha, self.target_branch)
end
end
@ -489,7 +489,7 @@ class MergeRequest < ActiveRecord::Base
end
def source_sha
last_commit.sha
last_commit.try(:sha)
end
def fetch_ref

View file

@ -349,7 +349,8 @@ class Project < ActiveRecord::Base
end
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
def saved?

View file

@ -589,6 +589,8 @@ class Repository
def merge_base(first_commit_id, second_commit_id)
rugged.merge_base(first_commit_id, second_commit_id)
rescue Rugged::ReferenceError
nil
end
def is_ancestor?(ancestor_id, descendant_id)

View file

@ -1,7 +1,7 @@
require 'spec_helper'
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(:build) { FactoryGirl.create :ci_build, commit: commit }