squashed - refactor to cope with sub sub N relations probably using the sub_relations method recursively.
This commit is contained in:
parent
e7319d0a25
commit
0e5f0276ea
4 changed files with 63 additions and 2 deletions
25
CHANGELOG
25
CHANGELOG
|
@ -32,6 +32,31 @@ v 8.10.0 (unreleased)
|
|||
- Add basic system information like memory and disk usage to the admin panel
|
||||
|
||||
v 8.9.5 (unreleased)
|
||||
- Don't garbage collect commits that have related DB records like comments
|
||||
- More descriptive message for git hooks and file locks
|
||||
- Handle custom Git hook result in GitLab UI
|
||||
- Allow '?', or '&' for label names
|
||||
- Fix importer for GitHub Pull Requests when a branch was reused across Pull Requests
|
||||
- Add date when user joined the team on the member page
|
||||
- Fix 404 redirect after validation fails importing a GitLab project
|
||||
- Added setting to set new users by default as external !4545 (Dravere)
|
||||
|
||||
v 8.9.6
|
||||
- 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
|
||||
- Fix diff comments not showing up in activity feed. !5069
|
||||
- Add index on both Award Emoji user and name. !5061
|
||||
- Downgrade to Redis 3.2.2 due to massive memory leak with Sidekiq. !5056
|
||||
- Re-enable import button when import process fails due to namespace already being taken. !5053
|
||||
- Fix snippets comments not displayed. !5045
|
||||
- Fix emoji paths in relative root configurations. !5027
|
||||
- Fix issues importing events in Import/Export. !4987
|
||||
- Fixed 'use shortcuts' button on docs. !4979
|
||||
- Admin should be able to turn shared runners into specific ones. !4961
|
||||
- Update RedCloth to 4.3.2 for CVE-2012-6684. !4929 (Takuya Noguchi)
|
||||
- Improve the request / withdraw access button. !4860
|
||||
- Fix assigning shared runners as admins. !4961
|
||||
- Show "locked" label for locked runners on runners admin. !4961
|
||||
|
|
|
@ -70,10 +70,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
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
|
|
|
@ -25,11 +25,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