Commit d6edecde authored by James Lopez's avatar James Lopez

Fix duplicated build token problem and added relevant spec

parent 2c49c1af
---
title: Fix Import/Export duplicated builds error
merge_request:
author:
...@@ -99,6 +99,8 @@ module Gitlab ...@@ -99,6 +99,8 @@ module Gitlab
def generate_imported_object def generate_imported_object
if BUILD_MODELS.include?(@relation_name) # call #trace= method after assigning the other attributes if BUILD_MODELS.include?(@relation_name) # call #trace= method after assigning the other attributes
trace = @relation_hash.delete('trace') trace = @relation_hash.delete('trace')
@relation_hash.delete('token')
imported_object do |object| imported_object do |object|
object.trace = trace object.trace = trace
object.commit_id = nil object.commit_id = nil
......
...@@ -6548,7 +6548,9 @@ ...@@ -6548,7 +6548,9 @@
"url": null "url": null
}, },
"erased_by_id": null, "erased_by_id": null,
"erased_at": null "erased_at": null,
"type": "Ci::Build",
"token": "abcd"
}, },
{ {
"id": 72, "id": 72,
......
...@@ -189,6 +189,14 @@ describe Gitlab::ImportExport::ProjectTreeRestorer, services: true do ...@@ -189,6 +189,14 @@ describe Gitlab::ImportExport::ProjectTreeRestorer, services: true do
end end
end end
end end
context 'existing builds' do
it 'do not throw errors' do
create(:ci_build, token: 'abcd')
expect(restored_project_json).to be true
end
end
end end
end end
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