diff options
author | Sean McGivern <sean@gitlab.com> | 2018-11-20 10:36:52 +0000 |
---|---|---|
committer | Sean McGivern <sean@gitlab.com> | 2018-11-20 10:36:52 +0000 |
commit | 2742b871fe44c649b4b503d10f5875276fb8fd87 (patch) | |
tree | 4c022342bd0b7f2f9464b2fe6ee5a8d1e8a58a34 /spec/lib/gitlab/git/commit_spec.rb | |
parent | 799486373e74711db65c2f77d11b1ec77fd7f4d9 (diff) | |
download | gitlab-ce-2742b871fe44c649b4b503d10f5875276fb8fd87.tar.gz |
Revert "Merge branch 'zj-improve-gitaly-pb' into 'master'"revert-e2aa2177
This reverts merge request !23140
Diffstat (limited to 'spec/lib/gitlab/git/commit_spec.rb')
-rw-r--r-- | spec/lib/gitlab/git/commit_spec.rb | 194 |
1 files changed, 111 insertions, 83 deletions
diff --git a/spec/lib/gitlab/git/commit_spec.rb b/spec/lib/gitlab/git/commit_spec.rb index 74d542060d5..6be35eee0fd 100644 --- a/spec/lib/gitlab/git/commit_spec.rb +++ b/spec/lib/gitlab/git/commit_spec.rb @@ -183,100 +183,110 @@ describe Gitlab::Git::Commit, :seed_helper do end end - context 'path is empty string' do - subject do - commits = described_class.where( - repo: repository, - ref: 'master', - path: '', - limit: 10 - ) + shared_examples '.where' do + context 'path is empty string' do + subject do + commits = described_class.where( + repo: repository, + ref: 'master', + path: '', + limit: 10 + ) - commits.map { |c| c.id } - end + commits.map { |c| c.id } + end - it 'has 10 elements' do - expect(subject.size).to eq(10) + it 'has 10 elements' do + expect(subject.size).to eq(10) + end + it { is_expected.to include(SeedRepo::EmptyCommit::ID) } end - it { is_expected.to include(SeedRepo::EmptyCommit::ID) } - end - context 'path is nil' do - subject do - commits = described_class.where( - repo: repository, - ref: 'master', - path: nil, - limit: 10 - ) + context 'path is nil' do + subject do + commits = described_class.where( + repo: repository, + ref: 'master', + path: nil, + limit: 10 + ) - commits.map { |c| c.id } - end + commits.map { |c| c.id } + end - it 'has 10 elements' do - expect(subject.size).to eq(10) + it 'has 10 elements' do + expect(subject.size).to eq(10) + end + it { is_expected.to include(SeedRepo::EmptyCommit::ID) } end - it { is_expected.to include(SeedRepo::EmptyCommit::ID) } - end - context 'ref is branch name' do - subject do - commits = described_class.where( - repo: repository, - ref: 'master', - path: 'files', - limit: 3, - offset: 1 - ) + context 'ref is branch name' do + subject do + commits = described_class.where( + repo: repository, + ref: 'master', + path: 'files', + limit: 3, + offset: 1 + ) - commits.map { |c| c.id } - end + commits.map { |c| c.id } + end - it 'has 3 elements' do - expect(subject.size).to eq(3) + it 'has 3 elements' do + expect(subject.size).to eq(3) + end + it { is_expected.to include("d14d6c0abdd253381df51a723d58691b2ee1ab08") } + it { is_expected.not_to include("eb49186cfa5c4338011f5f590fac11bd66c5c631") } end - it { is_expected.to include("d14d6c0abdd253381df51a723d58691b2ee1ab08") } - it { is_expected.not_to include("eb49186cfa5c4338011f5f590fac11bd66c5c631") } - end - context 'ref is commit id' do - subject do - commits = described_class.where( - repo: repository, - ref: "874797c3a73b60d2187ed6e2fcabd289ff75171e", - path: 'files', - limit: 3, - offset: 1 - ) + context 'ref is commit id' do + subject do + commits = described_class.where( + repo: repository, + ref: "874797c3a73b60d2187ed6e2fcabd289ff75171e", + path: 'files', + limit: 3, + offset: 1 + ) - commits.map { |c| c.id } - end + commits.map { |c| c.id } + end - it 'has 3 elements' do - expect(subject.size).to eq(3) + it 'has 3 elements' do + expect(subject.size).to eq(3) + end + it { is_expected.to include("2f63565e7aac07bcdadb654e253078b727143ec4") } + it { is_expected.not_to include(SeedRepo::Commit::ID) } end - it { is_expected.to include("2f63565e7aac07bcdadb654e253078b727143ec4") } - it { is_expected.not_to include(SeedRepo::Commit::ID) } - end - context 'ref is tag' do - subject do - commits = described_class.where( - repo: repository, - ref: 'v1.0.0', - path: 'files', - limit: 3, - offset: 1 - ) + context 'ref is tag' do + subject do + commits = described_class.where( + repo: repository, + ref: 'v1.0.0', + path: 'files', + limit: 3, + offset: 1 + ) - commits.map { |c| c.id } - end + commits.map { |c| c.id } + end - it 'has 3 elements' do - expect(subject.size).to eq(3) + it 'has 3 elements' do + expect(subject.size).to eq(3) + end + it { is_expected.to include("874797c3a73b60d2187ed6e2fcabd289ff75171e") } + it { is_expected.not_to include(SeedRepo::Commit::ID) } end - it { is_expected.to include("874797c3a73b60d2187ed6e2fcabd289ff75171e") } - it { is_expected.not_to include(SeedRepo::Commit::ID) } + end + + describe '.where with gitaly' do + it_should_behave_like '.where' + end + + describe '.where without gitaly', :skip_gitaly_mock do + it_should_behave_like '.where' end describe '.between' do @@ -498,7 +508,7 @@ describe Gitlab::Git::Commit, :seed_helper do end end - describe '#stats' do + shared_examples '#stats' do subject { commit.stats } describe '#additions' do @@ -517,6 +527,14 @@ describe Gitlab::Git::Commit, :seed_helper do end end + describe '#stats with gitaly on' do + it_should_behave_like '#stats' + end + + describe '#stats with gitaly disabled', :skip_gitaly_mock do + it_should_behave_like '#stats' + end + describe '#has_zero_stats?' do it { expect(commit.has_zero_stats?).to eq(false) } end @@ -559,15 +577,25 @@ describe Gitlab::Git::Commit, :seed_helper do commit_ids.map { |id| described_class.get_message(repository, id) } end - it 'gets commit messages' do - expect(subject).to contain_exactly( - "Added contributing guide\n\nSigned-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>\n", - "Add submodule\n\nSigned-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>\n" - ) + shared_examples 'getting commit messages' do + it 'gets commit messages' do + expect(subject).to contain_exactly( + "Added contributing guide\n\nSigned-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>\n", + "Add submodule\n\nSigned-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>\n" + ) + end + end + + context 'when Gitaly commit_messages feature is enabled' do + it_behaves_like 'getting commit messages' + + it 'gets messages in one batch', :request_store do + expect { subject.map(&:itself) }.to change { Gitlab::GitalyClient.get_request_count }.by(1) + end end - it 'gets messages in one batch', :request_store do - expect { subject.map(&:itself) }.to change { Gitlab::GitalyClient.get_request_count }.by(1) + context 'when Gitaly commit_messages feature is disabled', :disable_gitaly do + it_behaves_like 'getting commit messages' end end |