diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-06-18 14:18:50 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-06-18 14:18:50 +0300 |
commit | 8c7f4e9d5f36cff46365a7f8c4b9c21578c1e781 (patch) | |
tree | a77e7fe7a93de11213032ed4ab1f33a3db51b738 /spec/models/project_repository_storage_move_spec.rb | |
parent | 00b35af3db1abfe813a778f643dad221aad51fca (diff) |
Add latest changes from gitlab-org/gitlab@13-1-stable-ee
Diffstat (limited to 'spec/models/project_repository_storage_move_spec.rb')
-rw-r--r-- | spec/models/project_repository_storage_move_spec.rb | 46 |
1 files changed, 39 insertions, 7 deletions
diff --git a/spec/models/project_repository_storage_move_spec.rb b/spec/models/project_repository_storage_move_spec.rb index 146fc13bee0..83711085c92 100644 --- a/spec/models/project_repository_storage_move_spec.rb +++ b/spec/models/project_repository_storage_move_spec.rb @@ -30,25 +30,36 @@ RSpec.describe ProjectRepositoryStorageMove, type: :model do expect(subject.errors[:destination_storage_name].first).to match(/is not included in the list/) end end + + context 'project repository read-only' do + subject { build(:project_repository_storage_move, project: project) } + + let(:project) { build(:project, repository_read_only: true) } + + it "does not allow the project to be read-only on create" do + expect(subject).not_to be_valid + expect(subject.errors[:project].first).to match(/is read only/) + end + end end describe 'state transitions' do - using RSpec::Parameterized::TableSyntax + let(:project) { create(:project) } + + before do + stub_storage_settings('test_second_storage' => { 'path' => 'tmp/tests/extra_storage' }) + end context 'when in the default state' do subject(:storage_move) { create(:project_repository_storage_move, project: project, destination_storage_name: 'test_second_storage') } - let(:project) { create(:project) } - - before do - stub_storage_settings('test_second_storage' => { 'path' => 'tmp/tests/extra_storage' }) - end - context 'and transits to scheduled' do it 'triggers ProjectUpdateRepositoryStorageWorker' do expect(ProjectUpdateRepositoryStorageWorker).to receive(:perform_async).with(project.id, 'test_second_storage', storage_move.id) storage_move.schedule! + + expect(project).to be_repository_read_only end end @@ -59,5 +70,26 @@ RSpec.describe ProjectRepositoryStorageMove, type: :model do end end end + + context 'when started' do + subject(:storage_move) { create(:project_repository_storage_move, :started, project: project, destination_storage_name: 'test_second_storage') } + + context 'and transits to finished' do + it 'sets the repository storage and marks the project as writable' do + storage_move.finish! + + expect(project.repository_storage).to eq('test_second_storage') + expect(project).not_to be_repository_read_only + end + end + + context 'and transits to failed' do + it 'marks the project as writable' do + storage_move.do_fail! + + expect(project).not_to be_repository_read_only + end + end + end end end |