summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorRobert Speicher <robert@gitlab.com>2018-01-11 22:27:16 +0000
committerRobert Speicher <robert@gitlab.com>2018-01-11 22:27:16 +0000
commit16e895801e5ba2f27de6d33511c8ac46297048eb (patch)
treebe3f759b4297bb175d2b154e24a363cda14bc884 /spec
parent587242656f57df997b7356f31369cc30d7a79f6c (diff)
parent92d62ff69d5e92730937e909c7e216234d485ba1 (diff)
downloadgitlab-ce-16e895801e5ba2f27de6d33511c8ac46297048eb.tar.gz
Merge branch 'feature/migrate-is-rebase-in-progress-to-gitaly' into 'master'
Migrate rebase_in_progress? to Gitaly Closes gitaly#866 See merge request gitlab-org/gitlab-ce!16286
Diffstat (limited to 'spec')
-rw-r--r--spec/models/merge_request_spec.rb52
1 files changed, 29 insertions, 23 deletions
diff --git a/spec/models/merge_request_spec.rb b/spec/models/merge_request_spec.rb
index 27e9c477d61..8ff82c4f791 100644
--- a/spec/models/merge_request_spec.rb
+++ b/spec/models/merge_request_spec.rb
@@ -1910,38 +1910,44 @@ describe MergeRequest do
end
describe '#rebase_in_progress?' do
- # Create merge request and project before we stub file calls
- before do
- subject
- end
+ shared_examples 'checking whether a rebase is in progress' do
+ let(:repo_path) { subject.source_project.repository.path }
+ let(:rebase_path) { File.join(repo_path, "gitlab-worktree", "rebase-#{subject.id}") }
- it 'returns true when there is a current rebase directory' do
- allow(File).to receive(:exist?).and_return(true)
- allow(File).to receive(:mtime).and_return(Time.now)
+ before do
+ system(*%W(#{Gitlab.config.git.bin_path} -C #{repo_path} worktree add --detach #{rebase_path} master))
+ end
- expect(subject.rebase_in_progress?).to be_truthy
- end
+ it 'returns true when there is a current rebase directory' do
+ expect(subject.rebase_in_progress?).to be_truthy
+ end
- it 'returns false when there is no rebase directory' do
- allow(File).to receive(:exist?).and_return(false)
+ it 'returns false when there is no rebase directory' do
+ FileUtils.rm_rf(rebase_path)
- expect(subject.rebase_in_progress?).to be_falsey
- end
+ expect(subject.rebase_in_progress?).to be_falsey
+ end
+
+ it 'returns false when the rebase directory has expired' do
+ time = 20.minutes.ago.to_time
+ File.utime(time, time, rebase_path)
- it 'returns false when the rebase directory has expired' do
- allow(File).to receive(:exist?).and_return(true)
- allow(File).to receive(:mtime).and_return(20.minutes.ago)
+ expect(subject.rebase_in_progress?).to be_falsey
+ end
- expect(subject.rebase_in_progress?).to be_falsey
+ it 'returns false when the source project has been removed' do
+ allow(subject).to receive(:source_project).and_return(nil)
+
+ expect(subject.rebase_in_progress?).to be_falsey
+ end
end
- it 'returns false when the source project has been removed' do
- allow(subject).to receive(:source_project).and_return(nil)
- allow(File).to receive(:exist?).and_return(true)
- allow(File).to receive(:mtime).and_return(Time.now)
+ context 'when Gitaly rebase_in_progress is enabled' do
+ it_behaves_like 'checking whether a rebase is in progress'
+ end
- expect(File).not_to have_received(:exist?)
- expect(subject.rebase_in_progress?).to be_falsey
+ context 'when Gitaly rebase_in_progress is enabled', :disable_gitaly do
+ it_behaves_like 'checking whether a rebase is in progress'
end
end
end