diff options
author | Douwe Maan <douwe@gitlab.com> | 2018-06-19 14:19:18 +0000 |
---|---|---|
committer | Douwe Maan <douwe@gitlab.com> | 2018-06-19 14:19:18 +0000 |
commit | c0f0ccf222a2b8896aeb94b7a50b3923c7684125 (patch) | |
tree | 8755fe7df0552aa55c4e6168e32bce210e6a273d /spec/lib/gitlab | |
parent | 38edd5c33e5d88a950ee13809240260cb78568fc (diff) | |
parent | c2cdefd4413e2b9946d2a50461b338fc60cef1af (diff) | |
download | gitlab-ce-c0f0ccf222a2b8896aeb94b7a50b3923c7684125.tar.gz |
Merge branch 'zj-force-push-opt-out' into 'master'
Force push is handled by Gitaly now
Closes gitaly#348
See merge request gitlab-org/gitlab-ce!19992
Diffstat (limited to 'spec/lib/gitlab')
-rw-r--r-- | spec/lib/gitlab/checks/force_push_spec.rb | 18 | ||||
-rw-r--r-- | spec/lib/gitlab/git/rev_list_spec.rb | 10 |
2 files changed, 7 insertions, 21 deletions
diff --git a/spec/lib/gitlab/checks/force_push_spec.rb b/spec/lib/gitlab/checks/force_push_spec.rb index a65012d2314..0e0788ce974 100644 --- a/spec/lib/gitlab/checks/force_push_spec.rb +++ b/spec/lib/gitlab/checks/force_push_spec.rb @@ -1,21 +1,17 @@ require 'spec_helper' describe Gitlab::Checks::ForcePush do - let(:project) { create(:project, :repository) } - let(:repository) { project.repository.raw } + set(:project) { create(:project, :repository) } - context "exit code checking", :skip_gitaly_mock do - it "does not raise a runtime error if the `popen` call to git returns a zero exit code" do - allow(repository).to receive(:popen).and_return(['normal output', 0]) + describe '.force_push?' do + it 'returns false if the repo is empty' do + allow(project).to receive(:empty_repo?).and_return(true) - expect { described_class.force_push?(project, 'oldrev', 'newrev') }.not_to raise_error + expect(described_class.force_push?(project, 'HEAD', 'HEAD~')).to be(false) end - it "raises a GitError error if the `popen` call to git returns a non-zero exit code" do - allow(repository).to receive(:popen).and_return(['error', 1]) - - expect { described_class.force_push?(project, 'oldrev', 'newrev') } - .to raise_error(Gitlab::Git::Repository::GitError) + it 'checks if old rev is an anchestor' do + expect(described_class.force_push?(project, 'HEAD', 'HEAD~')).to be(true) end end end diff --git a/spec/lib/gitlab/git/rev_list_spec.rb b/spec/lib/gitlab/git/rev_list_spec.rb index 95dc47e2a00..b752c3e8341 100644 --- a/spec/lib/gitlab/git/rev_list_spec.rb +++ b/spec/lib/gitlab/git/rev_list_spec.rb @@ -93,14 +93,4 @@ describe Gitlab::Git::RevList do expect { |b| rev_list.all_objects(&b) }.to yield_with_args(%w[sha1 sha2]) end end - - context "#missed_ref" do - let(:rev_list) { described_class.new(repository, oldrev: 'oldrev', newrev: 'newrev') } - - it 'calls out to `popen`' do - stub_popen_rev_list('--max-count=1', 'oldrev', '^newrev', with_lazy_block: false, output: "sha1\nsha2") - - expect(rev_list.missed_ref).to eq(%w[sha1 sha2]) - end - end end |