Commit 3e7c4a91 authored by Gabriel Mazetto's avatar Gabriel Mazetto

Backport EE changes to make test possible when prepending modules

parent de63b9c3
...@@ -17,6 +17,10 @@ module Projects ...@@ -17,6 +17,10 @@ module Projects
move_folder!(old_path, new_path) move_folder!(old_path, new_path)
project.save! project.save!
if block_given?
yield
end
end end
private private
......
...@@ -37,7 +37,11 @@ module Projects ...@@ -37,7 +37,11 @@ module Projects
project.repository_read_only = false project.repository_read_only = false
project.save! project.save!
block_given? ? yield : result if result && block_given?
yield
end
result
end end
private private
......
...@@ -6,32 +6,36 @@ describe Projects::HashedStorageMigrationService do ...@@ -6,32 +6,36 @@ describe Projects::HashedStorageMigrationService do
describe '#execute' do describe '#execute' do
context 'repository migration' do context 'repository migration' do
let(:repository_service) { Projects::HashedStorage::MigrateRepositoryService.new(project, subject.logger) }
it 'delegates migration to Projects::HashedStorage::MigrateRepositoryService' do it 'delegates migration to Projects::HashedStorage::MigrateRepositoryService' do
expect(Projects::HashedStorage::MigrateRepositoryService).to receive(:new).with(project, subject.logger).and_call_original expect(Projects::HashedStorage::MigrateRepositoryService).to receive(:new).with(project, subject.logger).and_return(repository_service)
expect_any_instance_of(Projects::HashedStorage::MigrateRepositoryService).to receive(:execute) expect(repository_service).to receive(:execute)
service.execute service.execute
end end
it 'does not delegate migration if repository is already migrated' do it 'does not delegate migration if repository is already migrated' do
project.storage_version = ::Project::LATEST_STORAGE_VERSION project.storage_version = ::Project::LATEST_STORAGE_VERSION
expect_any_instance_of(Projects::HashedStorage::MigrateRepositoryService).not_to receive(:execute) expect(Projects::HashedStorage::MigrateRepositoryService).not_to receive(:new)
service.execute service.execute
end end
end end
context 'attachments migration' do context 'attachments migration' do
let(:attachments_service) { Projects::HashedStorage::MigrateAttachmentsService.new(project, subject.logger) }
it 'delegates migration to Projects::HashedStorage::MigrateRepositoryService' do it 'delegates migration to Projects::HashedStorage::MigrateRepositoryService' do
expect(Projects::HashedStorage::MigrateAttachmentsService).to receive(:new).with(project, subject.logger).and_call_original expect(Projects::HashedStorage::MigrateAttachmentsService).to receive(:new).with(project, subject.logger).and_return(attachments_service)
expect_any_instance_of(Projects::HashedStorage::MigrateAttachmentsService).to receive(:execute) expect(attachments_service).to receive(:execute)
service.execute service.execute
end end
it 'does not delegate migration if attachments are already migrated' do it 'does not delegate migration if attachments are already migrated' do
project.storage_version = ::Project::LATEST_STORAGE_VERSION project.storage_version = ::Project::LATEST_STORAGE_VERSION
expect_any_instance_of(Projects::HashedStorage::MigrateAttachmentsService).not_to receive(:execute) expect(Projects::HashedStorage::MigrateAttachmentsService).not_to receive(:new)
service.execute service.execute
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