summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Lopez <james@jameslopez.es>2016-12-19 11:26:57 +0100
committerJames Lopez <james@jameslopez.es>2016-12-19 11:26:57 +0100
commitd6edecdeec9b41b4509775ae5b2e01ee15b6d9dc (patch)
tree0bfbaec46907dd93d82ecce1f6416335454a0fc4
parent2c49c1af660a8e69446be442df81f9beaf0cf168 (diff)
downloadgitlab-ce-fix/import-export-build-token.tar.gz
Fix duplicated build token problem and added relevant specfix/import-export-build-token
-rw-r--r--changelogs/unreleased/fix-import-export-build-token.yml4
-rw-r--r--lib/gitlab/import_export/relation_factory.rb2
-rw-r--r--spec/lib/gitlab/import_export/project.json4
-rw-r--r--spec/lib/gitlab/import_export/project_tree_restorer_spec.rb8
4 files changed, 17 insertions, 1 deletions
diff --git a/changelogs/unreleased/fix-import-export-build-token.yml b/changelogs/unreleased/fix-import-export-build-token.yml
new file mode 100644
index 00000000000..622487e6829
--- /dev/null
+++ b/changelogs/unreleased/fix-import-export-build-token.yml
@@ -0,0 +1,4 @@
+---
+title: Fix Import/Export duplicated builds error
+merge_request:
+author:
diff --git a/lib/gitlab/import_export/relation_factory.rb b/lib/gitlab/import_export/relation_factory.rb
index a0e80fccad9..9b590bcee8d 100644
--- a/lib/gitlab/import_export/relation_factory.rb
+++ b/lib/gitlab/import_export/relation_factory.rb
@@ -99,6 +99,8 @@ module Gitlab
def generate_imported_object
if BUILD_MODELS.include?(@relation_name) # call #trace= method after assigning the other attributes
trace = @relation_hash.delete('trace')
+ @relation_hash.delete('token')
+
imported_object do |object|
object.trace = trace
object.commit_id = nil
diff --git a/spec/lib/gitlab/import_export/project.json b/spec/lib/gitlab/import_export/project.json
index ed9df468ced..1e5901651ae 100644
--- a/spec/lib/gitlab/import_export/project.json
+++ b/spec/lib/gitlab/import_export/project.json
@@ -6548,7 +6548,9 @@
"url": null
},
"erased_by_id": null,
- "erased_at": null
+ "erased_at": null,
+ "type": "Ci::Build",
+ "token": "abcd"
},
{
"id": 72,
diff --git a/spec/lib/gitlab/import_export/project_tree_restorer_spec.rb b/spec/lib/gitlab/import_export/project_tree_restorer_spec.rb
index 3038ab53ad8..13f593fb2db 100644
--- a/spec/lib/gitlab/import_export/project_tree_restorer_spec.rb
+++ b/spec/lib/gitlab/import_export/project_tree_restorer_spec.rb
@@ -189,6 +189,14 @@ describe Gitlab::ImportExport::ProjectTreeRestorer, services: true do
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