Commit 5a8fc5b7 authored by Shinya Maeda's avatar Shinya Maeda

Merge branch '21300-add-options-to-project-export-worker' into 'master'

Add options to ProjectExportWorker

See merge request gitlab-org/gitlab!30734
parents 8e97ebba cb548960
...@@ -9,7 +9,7 @@ class ProjectExportWorker # rubocop:disable Scalability/IdempotentWorker ...@@ -9,7 +9,7 @@ class ProjectExportWorker # rubocop:disable Scalability/IdempotentWorker
worker_resource_boundary :memory worker_resource_boundary :memory
urgency :throttled urgency :throttled
def perform(current_user_id, project_id, after_export_strategy = {}, params = {}) def perform(current_user_id, project_id, after_export_strategy = {}, params = {}, options = {})
current_user = User.find(current_user_id) current_user = User.find(current_user_id)
project = Project.find(project_id) project = Project.find(project_id)
export_job = project.export_jobs.safe_find_or_create_by(jid: self.jid) export_job = project.export_jobs.safe_find_or_create_by(jid: self.jid)
...@@ -17,7 +17,7 @@ class ProjectExportWorker # rubocop:disable Scalability/IdempotentWorker ...@@ -17,7 +17,7 @@ class ProjectExportWorker # rubocop:disable Scalability/IdempotentWorker
export_job&.start export_job&.start
::Projects::ImportExport::ExportService.new(project, current_user, params).execute(after_export) ::Projects::ImportExport::ExportService.new(project, current_user, params).execute(after_export, options)
export_job&.finish export_job&.finish
rescue ActiveRecord::RecordNotFound, Gitlab::ImportExport::AfterExportStrategyBuilder::StrategyNotFoundError => e rescue ActiveRecord::RecordNotFound, Gitlab::ImportExport::AfterExportStrategyBuilder::StrategyNotFoundError => e
......
...@@ -17,14 +17,32 @@ describe ProjectExportWorker do ...@@ -17,14 +17,32 @@ describe ProjectExportWorker do
context 'when it succeeds' do context 'when it succeeds' do
it 'calls the ExportService' do it 'calls the ExportService' do
expect_any_instance_of(::Projects::ImportExport::ExportService).to receive(:execute) expect_next_instance_of(::Projects::ImportExport::ExportService) do |service|
expect(service).to receive(:execute)
end
subject.perform(user.id, project.id, { 'klass' => 'Gitlab::ImportExport::AfterExportStrategies::DownloadNotificationStrategy' }) subject.perform(user.id, project.id, { 'klass' => 'Gitlab::ImportExport::AfterExportStrategies::DownloadNotificationStrategy' })
end end
context 'with measurement options provided' do
it 'calls the ExportService with measurement options' do
measurement_options = { measurement_enabled: true }
params = {}
after_export_strategy = { 'klass' => 'Gitlab::ImportExport::AfterExportStrategies::DownloadNotificationStrategy' }
expect_next_instance_of(::Projects::ImportExport::ExportService) do |service|
expect(service).to receive(:execute).with(instance_of(Gitlab::ImportExport::AfterExportStrategies::DownloadNotificationStrategy), measurement_options)
end
subject.perform(user.id, project.id, after_export_strategy, params, measurement_options)
end
end
context 'export job' do context 'export job' do
before do before do
allow_any_instance_of(::Projects::ImportExport::ExportService).to receive(:execute) allow_next_instance_of(::Projects::ImportExport::ExportService) do |service|
allow(service).to receive(:execute)
end
end end
it 'creates an export job record for the project' do it 'creates an export job record for the project' do
......
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