diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-12 09:09:55 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-12 09:09:55 +0000 |
commit | 18f7828977b74bf6e5153594a098ef90e773b3b7 (patch) | |
tree | 49cb1e16d5341d773807ee583357ae6eb167d61f /spec/models/project_spec.rb | |
parent | 8191b1571c017378eac33b3ed296ad5216d0a410 (diff) | |
download | gitlab-ce-18f7828977b74bf6e5153594a098ef90e773b3b7.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/models/project_spec.rb')
-rw-r--r-- | spec/models/project_spec.rb | 86 |
1 files changed, 86 insertions, 0 deletions
diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb index 782e526b69d..6d9b46c9941 100644 --- a/spec/models/project_spec.rb +++ b/spec/models/project_spec.rb @@ -3957,6 +3957,12 @@ describe Project do describe '#remove_export' do let(:project) { create(:project, :with_export) } + before do + allow_next_instance_of(ProjectExportWorker) do |job| + allow(job).to receive(:jid).and_return(SecureRandom.hex(8)) + end + end + it 'removes the export' do project.remove_exports @@ -5813,6 +5819,86 @@ describe Project do end end + describe '#add_export_job' do + context 'if not already present' do + it 'starts project export job' do + user = create(:user) + project = build(:project) + + expect(ProjectExportWorker).to receive(:perform_async).with(user.id, project.id, nil, {}) + + project.add_export_job(current_user: user) + end + end + end + + describe '#export_in_progress?' do + let(:project) { build(:project) } + let!(:project_export_job ) { create(:project_export_job, project: project) } + + context 'when project export is enqueued' do + it { expect(project.export_in_progress?).to be false } + end + + context 'when project export is in progress' do + before do + project_export_job.start! + end + + it { expect(project.export_in_progress?).to be true } + end + + context 'when project export is completed' do + before do + finish_job(project_export_job) + end + + it { expect(project.export_in_progress?).to be false } + end + end + + describe '#export_status' do + let(:project) { build(:project) } + let!(:project_export_job ) { create(:project_export_job, project: project) } + + context 'when project export is enqueued' do + it { expect(project.export_status).to eq :queued } + end + + context 'when project export is in progress' do + before do + project_export_job.start! + end + + it { expect(project.export_status).to eq :started } + end + + context 'when project export is completed' do + before do + finish_job(project_export_job) + allow(project).to receive(:export_file).and_return(double(ImportExportUploader, file: 'exists.zip')) + end + + it { expect(project.export_status).to eq :finished } + end + + context 'when project export is being regenerated' do + let!(:new_project_export_job ) { create(:project_export_job, project: project) } + + before do + finish_job(project_export_job) + allow(project).to receive(:export_file).and_return(double(ImportExportUploader, file: 'exists.zip')) + end + + it { expect(project.export_status).to eq :regeneration_in_progress } + end + end + + def finish_job(export_job) + export_job.start + export_job.finish + end + def rugged_config rugged_repo(project.repository).config end |