summaryrefslogtreecommitdiff
path: root/spec/models/repository_spec.rb
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2019-03-01 14:21:16 -0800
committerStan Hu <stanhu@gmail.com>2019-03-04 12:21:31 -0800
commit9d294467bda78c358c868bd2ba3e39c01aea44f8 (patch)
treef13ce8dd6d6ef9751e034d25b2905c001c2073fb /spec/models/repository_spec.rb
parentdb70f74dfdb0c74866a3b753a302777e7c784241 (diff)
downloadgitlab-ce-9d294467bda78c358c868bd2ba3e39c01aea44f8.tar.gz
Bring back Rugged implementation of CommitIsAncestor
This brings back some of the changes in https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/20095. For users using Gitaly on top of NFS, accessing the Git data directly via Rugged is more performant than Gitaly. This merge request introduces the feature flag `rugged_commit_is_ancestor` to activate the Rugged path. Part of four Rugged changes identified in https://gitlab.com/gitlab-org/gitlab-ce/issues/57317.
Diffstat (limited to 'spec/models/repository_spec.rb')
-rw-r--r--spec/models/repository_spec.rb16
1 files changed, 15 insertions, 1 deletions
diff --git a/spec/models/repository_spec.rb b/spec/models/repository_spec.rb
index 17201d8b90a..70630467d24 100644
--- a/spec/models/repository_spec.rb
+++ b/spec/models/repository_spec.rb
@@ -2237,7 +2237,7 @@ describe Repository do
rugged.references.create("refs/remotes/#{remote_name}/#{branch_name}", target.id)
end
- describe '#ancestor?' do
+ shared_examples '#ancestor?' do
let(:commit) { repository.commit }
let(:ancestor) { commit.parents.first }
@@ -2261,6 +2261,20 @@ describe Repository do
end
end
+ describe '#ancestor? with Gitaly enabled' do
+ it_behaves_like "#ancestor?"
+ end
+
+ describe '#ancestor? with Rugged enabled', :enable_rugged do
+ it 'calls out to the Rugged implementation' do
+ allow_any_instance_of(Rugged).to receive(:merge_base).with(repository.commit.id, Gitlab::Git::BLANK_SHA).and_call_original
+
+ repository.ancestor?(repository.commit.id, Gitlab::Git::BLANK_SHA)
+ end
+
+ it_behaves_like '#ancestor?'
+ end
+
describe '#archive_metadata' do
let(:ref) { 'master' }
let(:storage_path) { '/tmp' }