Commit cb548960 authored by Nikola Milojevic's avatar Nikola Milojevic Committed by Shinya Maeda

Add options to ProjectExportWorker

parent d38f1c03
......@@ -9,7 +9,7 @@ class ProjectExportWorker # rubocop:disable Scalability/IdempotentWorker
worker_resource_boundary :memory
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)
project = Project.find(project_id)
export_job = project.export_jobs.safe_find_or_create_by(jid: self.jid)
......@@ -17,7 +17,7 @@ class ProjectExportWorker # rubocop:disable Scalability/IdempotentWorker
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
rescue ActiveRecord::RecordNotFound, Gitlab::ImportExport::AfterExportStrategyBuilder::StrategyNotFoundError => e
......
......@@ -17,14 +17,32 @@ describe ProjectExportWorker do
context 'when it succeeds' 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' })
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
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
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