Commit 8165e520 authored by James Lopez's avatar James Lopez

add author on notes to export - so we can add to a note if project member is not found

parent b2b7b38c
# Model relationships to be included in the project import/export # Model relationships to be included in the project import/export
project_tree: project_tree:
- issues: - issues:
- :notes - notes:
:author
- :labels - :labels
- :milestones - :milestones
- :snippets - :snippets
...@@ -10,8 +11,9 @@ project_tree: ...@@ -10,8 +11,9 @@ project_tree:
- project_members: - project_members:
- :user - :user
- merge_requests: - merge_requests:
- notes:
:author
- :merge_request_diff - :merge_request_diff
- :notes
- ci_commits: - ci_commits:
- :statuses - :statuses
...@@ -31,6 +33,8 @@ included_attributes: ...@@ -31,6 +33,8 @@ included_attributes:
- :id - :id
- :email - :email
- :username - :username
author:
- :name
# Do not include the following attributes for the models specified. # Do not include the following attributes for the models specified.
excluded_attributes: excluded_attributes:
......
...@@ -37,10 +37,22 @@ module Gitlab ...@@ -37,10 +37,22 @@ module Gitlab
@attributes_parser.parse(current_key) { |hash| @json_config_hash[current_key] ||= hash } @attributes_parser.parse(current_key) { |hash| @json_config_hash[current_key] ||= hash }
handle_model_object(current_key, model_object) handle_model_object(current_key, model_object)
process_sub_model(current_key, model_object) if model_object.is_a?(Hash)
end end
@json_config_hash @json_config_hash
end end
def process_sub_model(current_key, model_object)
sub_model_json = build_json_config_hash(model_object).dup
@json_config_hash.slice!(current_key)
if @json_config_hash[current_key] && @json_config_hash[current_key][:include]
@json_config_hash[current_key][:include] << sub_model_json
else
@json_config_hash[current_key] = { include: sub_model_json }
end
end
def handle_model_object(current_key, model_object) def handle_model_object(current_key, model_object)
if @json_config_hash[current_key] if @json_config_hash[current_key]
add_model_value(current_key, model_object) add_model_value(current_key, model_object)
......
...@@ -65,6 +65,10 @@ describe Gitlab::ImportExport::ProjectTreeSaver, services: true do ...@@ -65,6 +65,10 @@ describe Gitlab::ImportExport::ProjectTreeSaver, services: true do
expect(saved_project_json['issues'].first['notes']).not_to be_empty expect(saved_project_json['issues'].first['notes']).not_to be_empty
end end
it 'has author on issue comments' do
expect(saved_project_json['issues'].first['notes'].first['author']).not_to be_empty
end
it 'has project members' do it 'has project members' do
expect(saved_project_json['project_members']).not_to be_empty expect(saved_project_json['project_members']).not_to be_empty
end end
...@@ -77,6 +81,9 @@ describe Gitlab::ImportExport::ProjectTreeSaver, services: true do ...@@ -77,6 +81,9 @@ describe Gitlab::ImportExport::ProjectTreeSaver, services: true do
expect(saved_project_json['merge_requests'].first['notes']).not_to be_empty expect(saved_project_json['merge_requests'].first['notes']).not_to be_empty
end end
it 'has author on merge requests comments' do
expect(saved_project_json['merge_requests'].first['notes'].first['author']).not_to be_empty
end
it 'has commit statuses' do it 'has commit statuses' do
expect(saved_project_json['ci_commits'].first['statuses']).not_to be_empty expect(saved_project_json['ci_commits'].first['statuses']).not_to be_empty
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment