summaryrefslogtreecommitdiff
path: root/spec/models
diff options
context:
space:
mode:
authorAlejandro Rodríguez <alejorro70@gmail.com>2017-05-11 17:26:51 -0300
committerAlejandro Rodríguez <alejorro70@gmail.com>2017-05-16 11:43:37 -0400
commitcf09c826a534d782de9cee4d28d3cdfa504099e7 (patch)
tree110d2fb4805c79eca8e009ac5b525315a61103fd /spec/models
parent9a10a6bfd563043b9e767f442c23c73f8af5e09b (diff)
downloadgitlab-ce-cf09c826a534d782de9cee4d28d3cdfa504099e7.tar.gz
Re-enable gitaly migration for ref_name_for_sha after bugfixesreenable-gitaly-ref-name
Diffstat (limited to 'spec/models')
-rw-r--r--spec/models/repository_spec.rb33
1 files changed, 14 insertions, 19 deletions
diff --git a/spec/models/repository_spec.rb b/spec/models/repository_spec.rb
index 61b748429d7..718b7d5e86b 100644
--- a/spec/models/repository_spec.rb
+++ b/spec/models/repository_spec.rb
@@ -110,22 +110,11 @@ describe Repository, models: true do
end
describe '#ref_name_for_sha' do
- context 'ref found' do
- it 'returns the ref' do
- allow_any_instance_of(Gitlab::Popen).to receive(:popen).
- and_return(["b8d95eb4969eefacb0a58f6a28f6803f8070e7b9 commit\trefs/environments/production/77\n", 0])
+ it 'returns the ref' do
+ allow(repository.raw_repository).to receive(:ref_name_for_sha).
+ and_return('refs/environments/production/77')
- expect(repository.ref_name_for_sha('bla', '0' * 40)).to eq 'refs/environments/production/77'
- end
- end
-
- context 'ref not found' do
- it 'returns nil' do
- allow_any_instance_of(Gitlab::Popen).to receive(:popen).
- and_return(["", 0])
-
- expect(repository.ref_name_for_sha('bla', '0' * 40)).to eq nil
- end
+ expect(repository.ref_name_for_sha('bla', '0' * 40)).to eq 'refs/environments/production/77'
end
end
@@ -1917,12 +1906,18 @@ describe Repository, models: true do
describe '#is_ancestor?' do
context 'Gitaly is_ancestor feature enabled' do
- it "asks Gitaly server if it's an ancestor" do
- commit = repository.commit
- expect(repository.raw_repository).to receive(:is_ancestor?).and_call_original
+ let(:commit) { repository.commit }
+ let(:ancestor) { commit.parents.first }
+
+ before do
+ allow(Gitlab::GitalyClient).to receive(:enabled?).and_return(true)
allow(Gitlab::GitalyClient).to receive(:feature_enabled?).with(:is_ancestor).and_return(true)
+ end
+
+ it "asks Gitaly server if it's an ancestor" do
+ expect_any_instance_of(Gitlab::GitalyClient::Commit).to receive(:is_ancestor).with(ancestor.id, commit.id)
- expect(repository.is_ancestor?(commit.id, commit.id)).to be true
+ repository.is_ancestor?(ancestor.id, commit.id)
end
end
end