Fix attribute inclusion in import/export config ignored in some cases

This commit is contained in:
James Lopez 2016-08-11 11:03:26 +02:00
parent 34d5426f0e
commit efab1677a7
4 changed files with 12 additions and 7 deletions

View file

@ -90,6 +90,9 @@ v 8.11.0 (unreleased)
- Fix importing GitLab projects with an invalid MR source project
- Sort folders with submodules in Files view !5521
v 8.10.6 (unreleased)
- Fix import/export configuration missing some included attributes
v 8.10.5
- Add a data migration to fix some missing timestamps in the members table. !5670
- Revert the "Defend against 'Host' header injection" change in the source NGINX templates. !5706

View file

@ -57,10 +57,7 @@ module Gitlab
# +value+ existing model to be included in the hash
# +json_config_hash+ the original hash containing the root model
def create_model_value(current_key, value, json_config_hash)
parsed_hash = { include: value }
parse_hash(value, parsed_hash)
json_config_hash[current_key] = parsed_hash
json_config_hash[current_key] = parse_hash(value, { include: value })
end
# Calls attributes finder to parse the hash and add any attributes to it
@ -69,8 +66,8 @@ module Gitlab
# +parsed_hash+ the original hash
def parse_hash(value, parsed_hash)
@attributes_finder.parse(value) do |hash|
parsed_hash = { include: hash_or_merge(value, hash) }
end
{ include: hash_or_merge(value, hash) }
end || parsed_hash
end
# Adds new model configuration to an existing hash with key +current_key+

View file

@ -12,7 +12,8 @@ describe Gitlab::ImportExport::Reader, lib: true do
except: [:iid],
include: [:merge_request_diff, :merge_request_test]
} },
{ commit_statuses: { include: :commit } }]
{ commit_statuses: { include: :commit } },
{ project_members: { include: { user: { only: [:email] } } } }]
}
end

View file

@ -7,6 +7,8 @@ project_tree:
- :merge_request_test
- commit_statuses:
- :commit
- project_members:
- :user
included_attributes:
project:
@ -14,6 +16,8 @@ included_attributes:
- :path
merge_requests:
- :id
user:
- :email
excluded_attributes:
merge_requests: