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
0
Merge Requests
0
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
Léo-Paul Géneau
gitlab-ce
Commits
7e6befc0
Commit
7e6befc0
authored
Apr 24, 2019
by
charlieablett
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add disallowed fields to AttributeCleaner
parent
b8c3e60e
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
21 additions
and
14 deletions
+21
-14
lib/gitlab/import_export/attribute_cleaner.rb
lib/gitlab/import_export/attribute_cleaner.rb
+13
-1
lib/gitlab/import_export/import_export.yml
lib/gitlab/import_export/import_export.yml
+0
-3
spec/lib/gitlab/import_export/attribute_cleaner_spec.rb
spec/lib/gitlab/import_export/attribute_cleaner_spec.rb
+5
-1
spec/lib/gitlab/import_export/project_tree_restorer_spec.rb
spec/lib/gitlab/import_export/project_tree_restorer_spec.rb
+3
-9
No files found.
lib/gitlab/import_export/attribute_cleaner.rb
View file @
7e6befc0
...
...
@@ -24,7 +24,19 @@ module Gitlab
private
def
prohibited_key?
(
key
)
key
.
end_with?
(
'_id'
)
&&
!
ALLOWED_REFERENCES
.
include?
(
key
)
return
false
if
allowed_reference?
(
key
)
return
true
if
'cached_markdown_version'
.
equal?
(
key
)
prohibited_suffices
=
%w(_id _html)
prohibited_suffices
.
each
do
|
suffix
|
return
true
if
key
.
end_with?
(
suffix
)
end
false
end
def
allowed_reference?
(
key
)
ALLOWED_REFERENCES
.
include?
(
key
)
end
def
excluded_key?
(
key
)
...
...
lib/gitlab/import_export/import_export.yml
View file @
7e6befc0
...
...
@@ -141,9 +141,6 @@ excluded_attributes:
-
:external_diff_size
issues
:
-
:milestone_id
notes
:
-
:note_html
-
:cached_markdown_version
merge_requests
:
-
:milestone_id
-
:ref_fetched
...
...
spec/lib/gitlab/import_export/attribute_cleaner_spec.rb
View file @
7e6befc0
...
...
@@ -18,7 +18,11 @@ describe Gitlab::ImportExport::AttributeCleaner do
'notid'
=>
99
,
'import_source'
=>
'whatever'
,
'import_type'
=>
'whatever'
,
'non_existent_attr'
=>
'whatever'
'non_existent_attr'
=>
'whatever'
,
'some_html'
=>
'<p>dodgy html</p>'
,
'legit_html'
=>
'<p>legit html</p>'
,
'_html'
=>
'<p>perfectly ordinary html</p>'
,
'cached_markdown_version'
=>
12345
}
end
...
...
spec/lib/gitlab/import_export/project_tree_restorer_spec.rb
View file @
7e6befc0
...
...
@@ -10,6 +10,7 @@ describe Gitlab::ImportExport::ProjectTreeRestorer do
create
(
:user
,
username:
'bernard_willms'
),
create
(
:user
,
username:
'saul_will'
)
]
@markdown_classes
=
[
AbuseReport
,
Appearance
,
ApplicationSetting
,
BroadcastMessage
,
Issue
,
Label
,
MergeRequest
,
Milestone
,
Namespace
,
Project
,
Release
,
ResourceLabelEvent
,
Snippet
,
UserStatus
]
RSpec
::
Mocks
.
with_temporary_scope
do
@project
=
create
(
:project
,
:builds_enabled
,
:issues_disabled
,
name:
'project'
,
path:
'project'
)
...
...
@@ -21,8 +22,7 @@ describe Gitlab::ImportExport::ProjectTreeRestorer do
expect_any_instance_of
(
Gitlab
::
Git
::
Repository
).
to
receive
(
:create_branch
).
with
(
'feature'
,
'DCBA'
)
allow_any_instance_of
(
Gitlab
::
Git
::
Repository
).
to
receive
(
:create_branch
)
allow_any_instance_of
(
Project
).
to
receive
(
:latest_cached_markdown_version
).
and_return
(
434343
)
allow_any_instance_of
(
Note
).
to
receive
(
:latest_cached_markdown_version
).
and_return
(
434343
)
@markdown_classes
.
each
{
|
klass
|
allow_any_instance_of
(
klass
).
to
receive
(
:latest_cached_markdown_version
).
and_return
(
434343
)}
@project_tree_restorer
=
described_class
.
new
(
user:
@user
,
shared:
@shared
,
project:
@project
)
...
...
@@ -61,18 +61,12 @@ describe Gitlab::ImportExport::ProjectTreeRestorer do
end
context
'when importing a project with cached_markdown_version and note_html'
do
before
do
expect
(
Gitlab
::
ImportExport
::
RelationFactory
).
not_to
receive
(
:create
).
with
(
hash_including
(
excluded_keys:
[
'whatever'
]))
expect
(
Gitlab
::
ImportExport
::
RelationFactory
).
to
receive
(
:create
).
with
(
hash_including
(
excluded_keys:
%w(note_html, cached_markdown_version)
)).
and_call_original
.
at_least
(
:once
)
allow
(
@project_tree_restorer
).
to
receive
(
:excluded_keys_for_relation
).
and_return
(
%w(note_html, cached_markdown_version)
)
end
let!
(
:issue
)
{
Issue
.
find_by
(
description:
'Aliquam enim illo et possimus.'
)
}
let
(
:note1
)
{
issue
.
notes
.
select
{
|
n
|
n
.
note
.
match
(
/Quo reprehenderit aliquam qui dicta impedit cupiditate eligendi/
)}.
first
}
let
(
:note2
)
{
issue
.
notes
.
select
{
|
n
|
n
.
note
.
match
(
/Est reprehenderit quas aut aspernatur autem recusandae voluptatem/
)}.
first
}
it
'does not import the note_html'
do
expect
(
note1
.
note_html
).
to
match
(
/
Et hic est id similique et non nesciunt voluptate
/
)
expect
(
note1
.
note_html
).
to
match
(
/
Quo reprehenderit aliquam qui dicta impedit cupiditate eligendi
/
)
end
it
'does not set the old cached_markdown_version'
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