diff options
Diffstat (limited to 'spec/models/merge_request_spec.rb')
-rw-r--r-- | spec/models/merge_request_spec.rb | 62 |
1 files changed, 40 insertions, 22 deletions
diff --git a/spec/models/merge_request_spec.rb b/spec/models/merge_request_spec.rb index ad55c280399..a58dc8e25e8 100644 --- a/spec/models/merge_request_spec.rb +++ b/spec/models/merge_request_spec.rb @@ -30,38 +30,48 @@ describe MergeRequest do end describe '#squash_in_progress?' do - let(:repo_path) do - Gitlab::GitalyClient::StorageSettings.allow_disk_access do - subject.source_project.repository.path + shared_examples 'checking whether a squash is in progress' do + let(:repo_path) do + Gitlab::GitalyClient::StorageSettings.allow_disk_access do + subject.source_project.repository.path + end end - end - let(:squash_path) { File.join(repo_path, "gitlab-worktree", "squash-#{subject.id}") } + let(:squash_path) { File.join(repo_path, "gitlab-worktree", "squash-#{subject.id}") } - before do - system(*%W(#{Gitlab.config.git.bin_path} -C #{repo_path} worktree add --detach #{squash_path} master)) - end + before do + system(*%W(#{Gitlab.config.git.bin_path} -C #{repo_path} worktree add --detach #{squash_path} master)) + end - it 'returns true when there is a current squash directory' do - expect(subject.squash_in_progress?).to be_truthy - end + it 'returns true when there is a current squash directory' do + expect(subject.squash_in_progress?).to be_truthy + end - it 'returns false when there is no squash directory' do - FileUtils.rm_rf(squash_path) + it 'returns false when there is no squash directory' do + FileUtils.rm_rf(squash_path) - expect(subject.squash_in_progress?).to be_falsey - end + expect(subject.squash_in_progress?).to be_falsey + end - it 'returns false when the squash directory has expired' do - time = 20.minutes.ago.to_time - File.utime(time, time, squash_path) + it 'returns false when the squash directory has expired' do + time = 20.minutes.ago.to_time + File.utime(time, time, squash_path) + + expect(subject.squash_in_progress?).to be_falsey + end + + it 'returns false when the source project has been removed' do + allow(subject).to receive(:source_project).and_return(nil) - expect(subject.squash_in_progress?).to be_falsey + expect(subject.squash_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) + context 'when Gitaly squash_in_progress is enabled' do + it_behaves_like 'checking whether a squash is in progress' + end - expect(subject.squash_in_progress?).to be_falsey + context 'when Gitaly squash_in_progress is disabled', :disable_gitaly do + it_behaves_like 'checking whether a squash is in progress' end end @@ -2577,6 +2587,14 @@ describe MergeRequest do expect(subject.rebase_in_progress?).to be_falsey end end + + context 'when Gitaly rebase_in_progress is enabled' do + it_behaves_like 'checking whether a rebase is in progress' + end + + context 'when Gitaly rebase_in_progress is enabled', :disable_gitaly do + it_behaves_like 'checking whether a rebase is in progress' + end end describe '#allow_collaboration' do |