Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
cb548960
Commit
cb548960
authored
Apr 30, 2020
by
Nikola Milojevic
Committed by
Shinya Maeda
Apr 30, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add options to ProjectExportWorker
parent
d38f1c03
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
4 deletions
+22
-4
app/workers/project_export_worker.rb
app/workers/project_export_worker.rb
+2
-2
spec/workers/project_export_worker_spec.rb
spec/workers/project_export_worker_spec.rb
+20
-2
No files found.
app/workers/project_export_worker.rb
View file @
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
...
...
spec/workers/project_export_worker_spec.rb
View file @
cb548960
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment