diff options
author | Zeger-Jan van de Weg <git@zjvandeweg.nl> | 2018-06-28 14:41:59 +0300 |
---|---|---|
committer | Zeger-Jan van de Weg <git@zjvandeweg.nl> | 2018-06-28 14:42:10 +0300 |
commit | ec78d29a6eee9b91299cbaef4e7497f392af0310 (patch) | |
tree | a7671faa17bd9463fd62637c29b076ae43562698 /spec/lib/gitlab/git/commit_spec.rb | |
parent | eaa9d4fd75252861bb733951b7571d7aea66fd66 (diff) |
FindAllCommits mandatory
Closes https://gitlab.com/gitlab-org/gitaly/issues/326
Diffstat (limited to 'spec/lib/gitlab/git/commit_spec.rb')
-rw-r--r-- | spec/lib/gitlab/git/commit_spec.rb | 102 |
1 files changed, 36 insertions, 66 deletions
diff --git a/spec/lib/gitlab/git/commit_spec.rb b/spec/lib/gitlab/git/commit_spec.rb index 0d7c930127c..ee74c2769eb 100644 --- a/spec/lib/gitlab/git/commit_spec.rb +++ b/spec/lib/gitlab/git/commit_spec.rb @@ -331,84 +331,54 @@ describe Gitlab::Git::Commit, seed_helper: true do end describe '.find_all' do - shared_examples 'finding all commits' do - it 'should return a return a collection of commits' do - commits = described_class.find_all(repository) + it 'should return a return a collection of commits' do + commits = described_class.find_all(repository) - expect(commits).to all( be_a_kind_of(described_class) ) - end - - context 'max_count' do - subject do - commits = described_class.find_all( - repository, - max_count: 50 - ) - - commits.map(&:id) - end + expect(commits).to all( be_a_kind_of(described_class) ) + end - it 'has 34 elements' do - expect(subject.size).to eq(34) - end + context 'max_count' do + subject do + commits = described_class.find_all( + repository, + max_count: 50 + ) - it 'includes the expected commits' do - expect(subject).to include( - SeedRepo::Commit::ID, - SeedRepo::Commit::PARENT_ID, - SeedRepo::FirstCommit::ID - ) - end + commits.map(&:id) end - context 'ref + max_count + skip' do - subject do - commits = described_class.find_all( - repository, - ref: 'master', - max_count: 50, - skip: 1 - ) - - commits.map(&:id) - end - - it 'has 24 elements' do - expect(subject.size).to eq(24) - end - - it 'includes the expected commits' do - expect(subject).to include(SeedRepo::Commit::ID, SeedRepo::FirstCommit::ID) - expect(subject).not_to include(SeedRepo::LastCommit::ID) - end + it 'has 34 elements' do + expect(subject.size).to eq(34) end - end - context 'when Gitaly find_all_commits feature is enabled' do - it_behaves_like 'finding all commits' + it 'includes the expected commits' do + expect(subject).to include( + SeedRepo::Commit::ID, + SeedRepo::Commit::PARENT_ID, + SeedRepo::FirstCommit::ID + ) + end end - context 'when Gitaly find_all_commits feature is disabled', :skip_gitaly_mock do - it_behaves_like 'finding all commits' - - context 'while applying a sort order based on the `order` option' do - it "allows ordering topologically (no parents shown before their children)" do - expect_any_instance_of(Rugged::Walker).to receive(:sorting).with(Rugged::SORT_TOPO) - - described_class.find_all(repository, order: :topo) - end - - it "allows ordering by date" do - expect_any_instance_of(Rugged::Walker).to receive(:sorting).with(Rugged::SORT_DATE | Rugged::SORT_TOPO) + context 'ref + max_count + skip' do + subject do + commits = described_class.find_all( + repository, + ref: 'master', + max_count: 50, + skip: 1 + ) - described_class.find_all(repository, order: :date) - end + commits.map(&:id) + end - it "applies no sorting by default" do - expect_any_instance_of(Rugged::Walker).to receive(:sorting).with(Rugged::SORT_NONE) + it 'has 24 elements' do + expect(subject.size).to eq(24) + end - described_class.find_all(repository) - end + it 'includes the expected commits' do + expect(subject).to include(SeedRepo::Commit::ID, SeedRepo::FirstCommit::ID) + expect(subject).not_to include(SeedRepo::LastCommit::ID) end end end |