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
3fa034df
Commit
3fa034df
authored
Dec 09, 2021
by
Illya Klymov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Address reviewer comments
* use Array.wrap in bulk import service for better DX
parent
007f6f27
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
4 additions
and
4 deletions
+4
-4
app/controllers/import/bulk_imports_controller.rb
app/controllers/import/bulk_imports_controller.rb
+1
-1
app/services/bulk_imports/create_service.rb
app/services/bulk_imports/create_service.rb
+1
-1
spec/controllers/import/bulk_imports_controller_spec.rb
spec/controllers/import/bulk_imports_controller_spec.rb
+2
-2
No files found.
app/controllers/import/bulk_imports_controller.rb
View file @
3fa034df
...
@@ -40,7 +40,7 @@ class Import::BulkImportsController < ApplicationController
...
@@ -40,7 +40,7 @@ class Import::BulkImportsController < ApplicationController
end
end
def
create
def
create
responses
=
create_params
.
map
{
|
entry
|
::
BulkImports
::
CreateService
.
new
(
current_user
,
[
entry
]
,
credentials
).
execute
}
responses
=
create_params
.
map
{
|
entry
|
::
BulkImports
::
CreateService
.
new
(
current_user
,
entry
,
credentials
).
execute
}
render
json:
responses
.
map
{
|
response
|
{
success:
response
.
success?
,
id:
response
.
payload
[
:id
],
message:
response
.
message
}
}
render
json:
responses
.
map
{
|
response
|
{
success:
response
.
success?
,
id:
response
.
payload
[
:id
],
message:
response
.
message
}
}
end
end
...
...
app/services/bulk_imports/create_service.rb
View file @
3fa034df
...
@@ -59,7 +59,7 @@ module BulkImports
...
@@ -59,7 +59,7 @@ module BulkImports
)
)
bulk_import
.
create_configuration!
(
credentials
.
slice
(
:url
,
:access_token
))
bulk_import
.
create_configuration!
(
credentials
.
slice
(
:url
,
:access_token
))
params
.
each
do
|
entity
|
Array
.
wrap
(
params
)
.
each
do
|
entity
|
BulkImports
::
Entity
.
create!
(
BulkImports
::
Entity
.
create!
(
bulk_import:
bulk_import
,
bulk_import:
bulk_import
,
source_type:
entity
[
:source_type
],
source_type:
entity
[
:source_type
],
...
...
spec/controllers/import/bulk_imports_controller_spec.rb
View file @
3fa034df
...
@@ -233,11 +233,11 @@ RSpec.describe Import::BulkImportsController do
...
@@ -233,11 +233,11 @@ RSpec.describe Import::BulkImportsController do
error_response
=
ServiceResponse
.
error
(
message:
'Record invalid'
,
http_status: :unprocessable_entity
)
error_response
=
ServiceResponse
.
error
(
message:
'Record invalid'
,
http_status: :unprocessable_entity
)
expect_next_instance_of
(
expect_next_instance_of
(
::
BulkImports
::
CreateService
,
user
,
[
bulk_import_params
[
0
]
],
{
url:
instance_url
,
access_token:
pat
})
do
|
service
|
::
BulkImports
::
CreateService
,
user
,
bulk_import_params
[
0
],
{
url:
instance_url
,
access_token:
pat
})
do
|
service
|
allow
(
service
).
to
receive
(
:execute
).
and_return
(
ServiceResponse
.
success
(
payload:
bulk_import
))
allow
(
service
).
to
receive
(
:execute
).
and_return
(
ServiceResponse
.
success
(
payload:
bulk_import
))
end
end
expect_next_instance_of
(
expect_next_instance_of
(
::
BulkImports
::
CreateService
,
user
,
[
bulk_import_params
[
1
]
],
{
url:
instance_url
,
access_token:
pat
})
do
|
service
|
::
BulkImports
::
CreateService
,
user
,
bulk_import_params
[
1
],
{
url:
instance_url
,
access_token:
pat
})
do
|
service
|
allow
(
service
).
to
receive
(
:execute
).
and_return
(
error_response
)
allow
(
service
).
to
receive
(
:execute
).
and_return
(
error_response
)
end
end
...
...
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