Commit d08fbf5e authored by Aleksei Lipniagov's avatar Aleksei Lipniagov

Additional spec and fix for edge case

I am still investigating if this case is something considered normal in
our data model.
But in out gitlabhq tarball we have such cases.
I am also checking why this was not failing on master.
Probably we are not passing keys with empty arrays into RelationFactory
at all?
parent 48e4ff95
...@@ -277,7 +277,7 @@ module Gitlab ...@@ -277,7 +277,7 @@ module Gitlab
end end
def setup_pipeline def setup_pipeline
@relation_hash.fetch('stages').each do |stage| @relation_hash.fetch('stages', []).each do |stage|
stage.statuses.each do |status| stage.statuses.each do |status|
status.pipeline = imported_object status.pipeline = imported_object
end end
......
...@@ -6680,6 +6680,25 @@ ...@@ -6680,6 +6680,25 @@
] ]
} }
] ]
},
{
"id": 41,
"project_id": 5,
"ref": "master",
"sha": "2ea1f3dec713d940208fb5ce4a38765ecb5d3f73",
"before_sha": null,
"push_data": null,
"created_at": "2016-03-22T15:20:35.763Z",
"updated_at": "2016-03-22T15:20:35.763Z",
"tag": null,
"yaml_errors": null,
"committed_at": null,
"status": "failed",
"started_at": null,
"finished_at": null,
"duration": null,
"stages": [
]
} }
], ],
"triggers": [ "triggers": [
......
...@@ -260,9 +260,9 @@ describe Gitlab::ImportExport::ProjectTreeRestorer do ...@@ -260,9 +260,9 @@ describe Gitlab::ImportExport::ProjectTreeRestorer do
end end
it 'has the correct number of pipelines and statuses' do it 'has the correct number of pipelines and statuses' do
expect(@project.ci_pipelines.size).to eq(5) expect(@project.ci_pipelines.size).to eq(6)
@project.ci_pipelines.zip([2, 2, 2, 2, 2]) @project.ci_pipelines.zip([0, 2, 2, 2, 2, 2])
.each do |(pipeline, expected_status_size)| .each do |(pipeline, expected_status_size)|
expect(pipeline.statuses.size).to eq(expected_status_size) expect(pipeline.statuses.size).to eq(expected_status_size)
end end
...@@ -271,7 +271,7 @@ describe Gitlab::ImportExport::ProjectTreeRestorer do ...@@ -271,7 +271,7 @@ describe Gitlab::ImportExport::ProjectTreeRestorer do
context 'when restoring hierarchy of pipeline, stages and jobs' do context 'when restoring hierarchy of pipeline, stages and jobs' do
it 'restores pipelines' do it 'restores pipelines' do
expect(Ci::Pipeline.all.count).to be 5 expect(Ci::Pipeline.all.count).to be 6
end end
it 'restores pipeline stages' do it 'restores pipeline stages' do
......
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