Commit 4f25ca25 authored by Nick Thomas's avatar Nick Thomas

CE->EE merge: fix failing specs in spec/models/project_spec.rb

parent b57f75ad
...@@ -2174,29 +2174,22 @@ describe Project do ...@@ -2174,29 +2174,22 @@ describe Project do
end end
describe '#change_repository_storage' do describe '#change_repository_storage' do
let(:project) { create(:project, :repository, repository_storage: 'a') } let(:project) { create(:project, :repository) }
let(:read_only_project) { create(:project, :repository, repository_storage: 'a', repository_read_only: true) } let(:read_only_project) { create(:project, :repository, repository_read_only: true) }
before do before do
FileUtils.mkdir('tmp/tests/storage_a') FileUtils.mkdir('tmp/tests/extra_storage')
FileUtils.mkdir('tmp/tests/storage_b') stub_storage_settings('extra' => { 'path' => 'tmp/tests/extra_storage' })
storages = {
'a' => { 'path' => 'tmp/tests/storage_a' },
'b' => { 'path' => 'tmp/tests/storage_b' }
}
allow(Gitlab.config.repositories).to receive(:storages).and_return(storages)
end end
after do after do
FileUtils.rm_rf('tmp/tests/storage_a') FileUtils.rm_rf('tmp/tests/extra_storage')
FileUtils.rm_rf('tmp/tests/storage_b')
end end
it 'schedule the transfer of the repository to the new storage and locks the project' do it 'schedule the transfer of the repository to the new storage and locks the project' do
expect(ProjectUpdateRepositoryStorageWorker).to receive(:perform_async).with(project.id, 'b') expect(ProjectUpdateRepositoryStorageWorker).to receive(:perform_async).with(project.id, 'extra')
project.change_repository_storage('b') project.change_repository_storage('extra')
project.save project.save
expect(project).to be_repository_read_only expect(project).to be_repository_read_only
...@@ -2205,21 +2198,21 @@ describe Project do ...@@ -2205,21 +2198,21 @@ describe Project do
it "doesn't schedule the transfer if the repository is already read-only" do it "doesn't schedule the transfer if the repository is already read-only" do
expect(ProjectUpdateRepositoryStorageWorker).not_to receive(:perform_async) expect(ProjectUpdateRepositoryStorageWorker).not_to receive(:perform_async)
read_only_project.change_repository_storage('b') read_only_project.change_repository_storage('extra')
read_only_project.save read_only_project.save
end end
it "doesn't lock or schedule the transfer if the storage hasn't changed" do it "doesn't lock or schedule the transfer if the storage hasn't changed" do
expect(ProjectUpdateRepositoryStorageWorker).not_to receive(:perform_async) expect(ProjectUpdateRepositoryStorageWorker).not_to receive(:perform_async)
project.change_repository_storage('a') project.change_repository_storage(project.repository_storage)
project.save project.save
expect(project).not_to be_repository_read_only expect(project).not_to be_repository_read_only
end end
it 'throws an error if an invalid repository storage is provided' do it 'throws an error if an invalid repository storage is provided' do
expect { project.change_repository_storage('c') }.to raise_error expect { project.change_repository_storage('unknown') }.to raise_error(ArgumentError)
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment