Merge branch 'fix/import-event-error' into 'master'
Fix problems with events under notes importing GitLab projects Fixes https://gitlab.com/gitlab-org/gitlab-ce/issues/19588 See merge request !5154
This commit is contained in:
commit
734e44ee79
4 changed files with 41 additions and 2 deletions
|
@ -67,6 +67,9 @@ v 8.10.0 (unreleased)
|
|||
- Add reminder to not paste private SSH keys !4399 (Ingo Blechschmidt)
|
||||
- Remove duplicate `description` field in `MergeRequest` entities (Ben Boeckel)
|
||||
|
||||
v 8.9.6 (unreleased)
|
||||
- Fix importing of events under notes for GitLab projects
|
||||
|
||||
v 8.9.5
|
||||
- Add more debug info to import/export and memory killer. !5108
|
||||
- Fixed avatar alignment in new MR view. !5095
|
||||
|
|
|
@ -69,10 +69,19 @@ module Gitlab
|
|||
# Example:
|
||||
# +relation_key+ issues, loops through the list of *issues* and for each individual
|
||||
# issue, finds any subrelations such as notes, creates them and assign them back to the hash
|
||||
#
|
||||
# Recursively calls this method if the sub-relation is a hash containing more sub-relations
|
||||
def create_sub_relations(relation, tree_hash)
|
||||
relation_key = relation.keys.first.to_s
|
||||
return if tree_hash[relation_key].blank?
|
||||
|
||||
tree_hash[relation_key].each do |relation_item|
|
||||
relation.values.flatten.each do |sub_relation|
|
||||
# We just use author to get the user ID, do not attempt to create an instance.
|
||||
next if sub_relation == :author
|
||||
|
||||
create_sub_relations(sub_relation, relation_item) if sub_relation.is_a?(Hash)
|
||||
|
||||
relation_hash, sub_relation = assign_relation_hash(relation_item, sub_relation)
|
||||
relation_item[sub_relation.to_s] = create_relation(sub_relation, relation_hash) unless relation_hash.blank?
|
||||
end
|
||||
|
|
|
@ -4208,7 +4208,18 @@
|
|||
"name": "User 4"
|
||||
},
|
||||
"events": [
|
||||
|
||||
{
|
||||
"id": 529,
|
||||
"target_type": "Note",
|
||||
"target_id": 2521,
|
||||
"title": "test levels",
|
||||
"data": null,
|
||||
"project_id": 4,
|
||||
"created_at": "2016-07-07T14:35:12.128Z",
|
||||
"updated_at": "2016-07-07T14:35:12.128Z",
|
||||
"action": 6,
|
||||
"author_id": 1
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
|
|
|
@ -24,11 +24,27 @@ describe Gitlab::ImportExport::ProjectTreeRestorer, services: true do
|
|||
expect(Ci::Pipeline.first.notes).not_to be_empty
|
||||
end
|
||||
|
||||
it 'restores the correct event' do
|
||||
it 'restores the correct event with symbolised data' do
|
||||
restored_project_json
|
||||
|
||||
expect(Event.where.not(data: nil).first.data[:ref]).not_to be_empty
|
||||
end
|
||||
|
||||
context 'event at forth level of the tree' do
|
||||
let(:event) { Event.where(title: 'test levels').first }
|
||||
|
||||
before do
|
||||
restored_project_json
|
||||
end
|
||||
|
||||
it 'restores the event' do
|
||||
expect(event).not_to be_nil
|
||||
end
|
||||
|
||||
it 'event belongs to note, belongs to merge request, belongs to a project' do
|
||||
expect(event.note.noteable.project).not_to be_nil
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue