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
99e2f4ba
Commit
99e2f4ba
authored
Nov 25, 2021
by
Igor Frenkel
Committed by
Vasilii Iakliushin
Nov 25, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix specs for Import::AttributePermitter
parent
07ae35d8
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
6 additions
and
10 deletions
+6
-10
lib/gitlab/import_export/project/import_export.yml
lib/gitlab/import_export/project/import_export.yml
+0
-5
spec/lib/gitlab/import_export/safe_model_attributes.yml
spec/lib/gitlab/import_export/safe_model_attributes.yml
+1
-0
spec/support/shared_examples/lib/gitlab/import_export/attributes_permitter_shared_examples.rb
...lab/import_export/attributes_permitter_shared_examples.rb
+5
-5
No files found.
lib/gitlab/import_export/project/import_export.yml
View file @
99e2f4ba
...
@@ -126,7 +126,6 @@ included_attributes:
...
@@ -126,7 +126,6 @@ included_attributes:
-
:project_id
-
:project_id
project_badges
:
project_badges
:
-
:created_at
-
:created_at
-
:group_id
-
:image_url
-
:image_url
-
:link_url
-
:link_url
-
:name
-
:name
...
@@ -572,7 +571,6 @@ included_attributes:
...
@@ -572,7 +571,6 @@ included_attributes:
-
:updated_at
-
:updated_at
actions
:
actions
:
-
:event
-
:event
-
:image_v432x230
design
:
&design_definition
design
:
&design_definition
-
:iid
-
:iid
-
:project_id
-
:project_id
...
@@ -731,7 +729,6 @@ excluded_attributes:
...
@@ -731,7 +729,6 @@ excluded_attributes:
-
:verification_checksum
-
:verification_checksum
-
:verification_failure
-
:verification_failure
merge_request_diff_files
:
merge_request_diff_files
:
-
:diff
-
:external_diff_offset
-
:external_diff_offset
-
:external_diff_size
-
:external_diff_size
-
:merge_request_diff_id
-
:merge_request_diff_id
...
@@ -890,8 +887,6 @@ excluded_attributes:
...
@@ -890,8 +887,6 @@ excluded_attributes:
system_note_metadata
:
system_note_metadata
:
-
:description_version_id
-
:description_version_id
-
:note_id
-
:note_id
pipeline_schedules
:
-
:active
methods
:
methods
:
notes
:
notes
:
-
:type
-
:type
...
...
spec/lib/gitlab/import_export/safe_model_attributes.yml
View file @
99e2f4ba
...
@@ -253,6 +253,7 @@ MergeRequestDiffFile:
...
@@ -253,6 +253,7 @@ MergeRequestDiffFile:
-
b_mode
-
b_mode
-
too_large
-
too_large
-
binary
-
binary
-
diff
MergeRequestContextCommit
:
MergeRequestContextCommit
:
-
id
-
id
-
authored_date
-
authored_date
...
...
spec/support/shared_examples/lib/gitlab/import_export/attributes_permitter_shared_examples.rb
View file @
99e2f4ba
# frozen_string_literal: true
# frozen_string_literal: true
RSpec
.
shared_examples
'a permitted attribute'
do
|
relation_sym
,
permitted_attributes
,
additional_attributes
=
[]
|
RSpec
.
shared_examples
'a permitted attribute'
do
|
relation_sym
,
permitted_attributes
,
additional_attributes
=
[]
|
let
(
:prohibited_attributes
)
{
%
i
[remote_url my_attributes my_ids token my_id test]
}
let
(
:prohibited_attributes
)
{
%
w
[remote_url my_attributes my_ids token my_id test]
}
let
(
:import_export_config
)
{
Gitlab
::
ImportExport
::
Config
.
new
.
to_h
}
let
(
:import_export_config
)
{
Gitlab
::
ImportExport
::
Config
.
new
.
to_h
}
let
(
:project_relation_factory
)
{
Gitlab
::
ImportExport
::
Project
::
RelationFactory
}
let
(
:project_relation_factory
)
{
Gitlab
::
ImportExport
::
Project
::
RelationFactory
}
...
@@ -8,7 +8,7 @@ RSpec.shared_examples 'a permitted attribute' do |relation_sym, permitted_attrib
...
@@ -8,7 +8,7 @@ RSpec.shared_examples 'a permitted attribute' do |relation_sym, permitted_attrib
let
(
:relation_hash
)
{
(
permitted_attributes
+
prohibited_attributes
).
map
(
&
:to_s
).
zip
([]).
to_h
}
let
(
:relation_hash
)
{
(
permitted_attributes
+
prohibited_attributes
).
map
(
&
:to_s
).
zip
([]).
to_h
}
let
(
:relation_name
)
{
project_relation_factory
.
overrides
[
relation_sym
]
&
.
to_sym
||
relation_sym
}
let
(
:relation_name
)
{
project_relation_factory
.
overrides
[
relation_sym
]
&
.
to_sym
||
relation_sym
}
let
(
:relation_class
)
{
project_relation_factory
.
relation_class
(
relation_name
)
}
let
(
:relation_class
)
{
project_relation_factory
.
relation_class
(
relation_name
)
}
let
(
:excluded_keys
)
{
import_export_config
.
dig
(
:excluded_keys
,
relation_sym
)
||
[]
}
let
(
:excluded_keys
)
{
(
import_export_config
.
dig
(
:excluded_attributes
,
relation_sym
)
||
[]).
map
(
&
:to_s
)
}
let
(
:cleaned_hash
)
do
let
(
:cleaned_hash
)
do
Gitlab
::
ImportExport
::
AttributeCleaner
.
new
(
Gitlab
::
ImportExport
::
AttributeCleaner
.
new
(
...
@@ -18,7 +18,7 @@ RSpec.shared_examples 'a permitted attribute' do |relation_sym, permitted_attrib
...
@@ -18,7 +18,7 @@ RSpec.shared_examples 'a permitted attribute' do |relation_sym, permitted_attrib
).
clean
).
clean
end
end
let
(
:permitted_hash
)
{
subject
.
permit
(
relation_sym
,
relation_hash
)
}
let
(
:permitted_hash
)
{
subject
.
permit
(
relation_sym
,
relation_hash
)
.
transform_keys
{
|
k
|
k
.
to_s
}
}
if
described_class
.
new
.
permitted_attributes_defined?
(
relation_sym
)
if
described_class
.
new
.
permitted_attributes_defined?
(
relation_sym
)
it
'contains only attributes that are defined as permitted in the import/export config'
do
it
'contains only attributes that are defined as permitted in the import/export config'
do
...
@@ -26,11 +26,11 @@ RSpec.shared_examples 'a permitted attribute' do |relation_sym, permitted_attrib
...
@@ -26,11 +26,11 @@ RSpec.shared_examples 'a permitted attribute' do |relation_sym, permitted_attrib
end
end
it
'does not contain attributes that would be cleaned with AttributeCleaner'
do
it
'does not contain attributes that would be cleaned with AttributeCleaner'
do
expect
(
cleaned_hash
.
keys
+
additional_attributes
.
to_a
).
to
include
(
*
permitted_hash
.
keys
)
expect
(
(
cleaned_hash
.
keys
+
additional_attributes
.
to_a
.
map
(
&
:to_s
))
).
to
include
(
*
permitted_hash
.
keys
)
end
end
it
'does not contain prohibited attributes that are not related to given relation'
do
it
'does not contain prohibited attributes that are not related to given relation'
do
expect
(
permitted_hash
.
keys
).
not_to
include
(
*
prohibited_attributes
.
map
(
&
:to_s
)
)
expect
(
permitted_hash
.
keys
).
not_to
include
(
*
prohibited_attributes
)
end
end
else
else
it
'is disabled'
do
it
'is disabled'
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