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
b70dfdb9
Commit
b70dfdb9
authored
Apr 08, 2021
by
Kassio Borges
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
BulkImports: Avoid exception in EpicsPipeline when there's no Group
parent
9dd41bd6
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
111 additions
and
78 deletions
+111
-78
ee/lib/ee/bulk_imports/pipeline/epic_base.rb
ee/lib/ee/bulk_imports/pipeline/epic_base.rb
+11
-1
ee/spec/lib/ee/bulk_imports/pipeline/epic_base_spec.rb
ee/spec/lib/ee/bulk_imports/pipeline/epic_base_spec.rb
+100
-77
No files found.
ee/lib/ee/bulk_imports/pipeline/epic_base.rb
View file @
b70dfdb9
...
...
@@ -9,13 +9,15 @@ module EE
def
initialize
(
context
)
super
(
context
)
return
if
context
.
group
.
blank?
@epic_iids
=
context
.
group
.
epics
.
order
(
iid: :desc
).
pluck
(
:iid
)
# rubocop: disable CodeReuse/ActiveRecord
set_next_epic
end
def
run
return
skip!
(
'Skipping because group has no epics'
)
if
current_epic_iid
.
blank?
return
skip!
(
skip_reason
)
if
current_epic_iid
.
blank?
super
end
...
...
@@ -43,6 +45,14 @@ module EE
def
current_epic_iid
context
.
extra
[
:epic_iid
]
end
def
skip_reason
if
context
.
group
.
blank?
'Skipping because bulk import has no group'
else
'Skipping because group has no epics'
end
end
end
end
end
...
...
ee/spec/lib/ee/bulk_imports/pipeline/epic_base_spec.rb
View file @
b70dfdb9
...
...
@@ -3,11 +3,6 @@
require
'spec_helper'
RSpec
.
describe
EE
::
BulkImports
::
Pipeline
::
EpicBase
do
let_it_be
(
:group
)
{
create
(
:group
)
}
let_it_be
(
:entity
)
{
create
(
:bulk_import_entity
,
group:
group
)
}
let_it_be
(
:pipeline_tracker
)
{
create
(
:bulk_import_tracker
,
entity:
entity
)
}
let_it_be
(
:context
)
{
BulkImports
::
Pipeline
::
Context
.
new
(
pipeline_tracker
)
}
let
(
:pipeline_class
)
do
Class
.
new
(
EE
::
BulkImports
::
Pipeline
::
EpicBase
)
do
def
extract
(
_
)
...
...
@@ -30,6 +25,33 @@ RSpec.describe EE::BulkImports::Pipeline::EpicBase do
stub_const
(
'MyPipeline'
,
pipeline_class
)
end
context
'when the group was not imported'
do
let_it_be
(
:pipeline_tracker
)
{
create
(
:bulk_import_tracker
)
}
let_it_be
(
:context
)
{
BulkImports
::
Pipeline
::
Context
.
new
(
pipeline_tracker
)
}
it
'skips the pipeline'
do
expect_next_instance_of
(
Gitlab
::
Import
::
Logger
)
do
|
logger
|
expect
(
logger
).
to
receive
(
:warn
)
.
with
(
bulk_import_id:
pipeline_tracker
.
entity
.
bulk_import
.
id
,
bulk_import_entity_id:
pipeline_tracker
.
entity
.
id
,
bulk_import_entity_type:
pipeline_tracker
.
entity
.
source_type
,
message:
'Skipping because bulk import has no group'
,
pipeline_class:
'MyPipeline'
)
end
expect
{
subject
.
run
}
.
to
change
(
pipeline_tracker
,
:status_name
).
to
(
:skipped
)
end
end
context
'when the group was already imported'
do
let_it_be
(
:group
)
{
create
(
:group
)
}
let_it_be
(
:entity
)
{
create
(
:bulk_import_entity
,
group:
group
)
}
let_it_be
(
:pipeline_tracker
)
{
create
(
:bulk_import_tracker
,
entity:
entity
)
}
let_it_be
(
:context
)
{
BulkImports
::
Pipeline
::
Context
.
new
(
pipeline_tracker
)
}
context
'when the group has no epics'
do
it
'skips the pipeline'
do
expect_next_instance_of
(
Gitlab
::
Import
::
Logger
)
do
|
logger
|
...
...
@@ -131,4 +153,5 @@ RSpec.describe EE::BulkImports::Pipeline::EpicBase do
subject
.
run
end
end
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