diff options
author | Zeger-Jan van de Weg <git@zjvandeweg.nl> | 2018-07-17 13:17:43 +0300 |
---|---|---|
committer | Zeger-Jan van de Weg <git@zjvandeweg.nl> | 2018-07-18 15:46:27 +0300 |
commit | 9348efc6bae3f5eee948fc6871fa4bf5afbbfd4e (patch) | |
tree | 53ecaa1ad4beaa9c823ca9781097c6fbecf4fb4a /spec/models/repository_spec.rb | |
parent | 740ae2d194f3833e224c326cc909d833c5807484 (diff) |
Client implementation for Repository#new_commits
After trying to remove the whole method in
8f69014af2902d8d53fe931268bec60f6858f160, this is a more gentle
approach to the method. :)
Prior to this change, new commit detection wasn't implemented in Gitaly,
this was done through: https://gitlab.com/gitlab-org/gitaly/merge_requests/779
As the new implemented got moved around a bit, the whole RevList class
got removed.
Part of https://gitlab.com/gitlab-org/gitaly/issues/1233
Diffstat (limited to 'spec/models/repository_spec.rb')
-rw-r--r-- | spec/models/repository_spec.rb | 46 |
1 files changed, 31 insertions, 15 deletions
diff --git a/spec/models/repository_spec.rb b/spec/models/repository_spec.rb index 02d31098cfd..e65214808e1 100644 --- a/spec/models/repository_spec.rb +++ b/spec/models/repository_spec.rb @@ -296,24 +296,40 @@ describe Repository do end describe '#new_commits' do - let(:new_refs) do - double(:git_rev_list, new_refs: %w[ - c1acaa58bbcbc3eafe538cb8274ba387047b69f8 - 5937ac0a7beb003549fc5fd26fc247adbce4a52e - ]) - end + shared_examples 'finding unreferenced commits' do + set(:project) { create(:project, :repository) } + let(:repository) { project.repository } - it 'delegates to Gitlab::Git::RevList' do - expect(Gitlab::Git::RevList).to receive(:new).with( - repository.raw, - newrev: 'aaaabbbbccccddddeeeeffffgggghhhhiiiijjjj').and_return(new_refs) + subject { repository.new_commits(rev) } - commits = repository.new_commits('aaaabbbbccccddddeeeeffffgggghhhhiiiijjjj') + context 'when there are no new commits' do + let(:rev) { repository.commit.id } - expect(commits).to eq([ - repository.commit('c1acaa58bbcbc3eafe538cb8274ba387047b69f8'), - repository.commit('5937ac0a7beb003549fc5fd26fc247adbce4a52e') - ]) + it 'returns an empty array' do + expect(subject).to eq([]) + end + end + + context 'when new commits are found' do + let(:branch) { 'orphaned-branch' } + let!(:rev) { repository.commit(branch).id } + + it 'returns the commits' do + repository.delete_branch(branch) + + expect(subject).not_to be_empty + expect(subject).to all( be_a(::Commit) ) + expect(subject.size).to eq(1) + end + end + end + + context 'when Gitaly handles the request' do + it_behaves_like 'finding unreferenced commits' + end + + context 'when Gitaly is disabled', :disable_gitaly do + it_behaves_like 'finding unreferenced commits' end end |