summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcharlieablett <cablett@gitlab.com>2019-04-29 21:31:16 +1200
committercharlieablett <cablett@gitlab.com>2019-04-29 21:31:16 +1200
commitb240012c4f474fc9ac24afb3286fbc967cde86d4 (patch)
treea95e519e3144b91d3acc704d4aca106a9c4c6cd7
parent4bd331a568cff64f4097fdf0cc4e45727750f740 (diff)
downloadgitlab-ce-b240012c4f474fc9ac24afb3286fbc967cde86d4.tar.gz
Further clarify `attribute_cleaner`
-rw-r--r--lib/gitlab/import_export/attribute_cleaner.rb14
1 files changed, 4 insertions, 10 deletions
diff --git a/lib/gitlab/import_export/attribute_cleaner.rb b/lib/gitlab/import_export/attribute_cleaner.rb
index f476905b6db..537cb36c89b 100644
--- a/lib/gitlab/import_export/attribute_cleaner.rb
+++ b/lib/gitlab/import_export/attribute_cleaner.rb
@@ -4,6 +4,7 @@ module Gitlab
module ImportExport
class AttributeCleaner
ALLOWED_REFERENCES = RelationFactory::PROJECT_REFERENCES + RelationFactory::USER_REFERENCES + ['group_id']
+ PROHIBITED_SUFFIXES = %w(_id _html).freeze
def self.clean(*args)
new(*args).clean
@@ -17,24 +18,17 @@ module Gitlab
def clean
@relation_hash.reject do |key, _value|
- prohibited_key?(key) || !@relation_class.attribute_method?(key) || excluded_key?(key)
+ (prohibited_key?(key) && !permitted_key?(key)) || !@relation_class.attribute_method?(key) || excluded_key?(key)
end.except('id')
end
private
def prohibited_key?(key)
- return false if allowed_reference?(key)
-
- return true if 'cached_markdown_version'.equal?(key)
-
- prohibited_suffixes = %w(_id _html)
- prohibited_suffixes.any? do |suffix|
- true if key.end_with?(suffix)
- end
+ 'cached_markdown_version' == key || PROHIBITED_SUFFIXES.any? {|suffix| key.end_with?(suffix)}
end
- def allowed_reference?(key)
+ def permitted_key?(key)
ALLOWED_REFERENCES.include?(key)
end