summaryrefslogtreecommitdiff
path: root/spec/lib/gitlab/import_export/attribute_cleaner_spec.rb
diff options
context:
space:
mode:
authorJames Lopez <james@jameslopez.es>2016-08-12 12:04:33 +0200
committerJames Lopez <james@jameslopez.es>2016-09-27 15:48:10 +0200
commit4c480be39b0862f41043e94a6dc5b943b6f8e8f0 (patch)
tree7c3f18944c33d0bc53a0bae99d92adc8fce5ab40 /spec/lib/gitlab/import_export/attribute_cleaner_spec.rb
parent0ee03af814c34d9c1cad8535b46ad65e96426c8e (diff)
downloadgitlab-ce-4c480be39b0862f41043e94a6dc5b943b6f8e8f0.tar.gz
Prevent claiming associated model IDs via import and added relevant specs
Diffstat (limited to 'spec/lib/gitlab/import_export/attribute_cleaner_spec.rb')
-rw-r--r--spec/lib/gitlab/import_export/attribute_cleaner_spec.rb34
1 files changed, 34 insertions, 0 deletions
diff --git a/spec/lib/gitlab/import_export/attribute_cleaner_spec.rb b/spec/lib/gitlab/import_export/attribute_cleaner_spec.rb
new file mode 100644
index 00000000000..b8e7932eb4a
--- /dev/null
+++ b/spec/lib/gitlab/import_export/attribute_cleaner_spec.rb
@@ -0,0 +1,34 @@
+require 'spec_helper'
+
+describe Gitlab::ImportExport::AttributeCleaner, lib: true do
+ let(:unsafe_hash) do
+ {
+ 'service_id' => 99,
+ 'moved_to_id' => 99,
+ 'namespace_id' => 99,
+ 'ci_id' => 99,
+ 'random_project_id' => 99,
+ 'random_id' => 99,
+ 'milestone_id' => 99,
+ 'project_id' => 99,
+ 'user_id' => 99,
+ 'random_id_in_the_middle' => 99,
+ 'notid' => 99
+ }
+ end
+
+ let(:post_safe_hash) do
+ {
+ 'project_id' => 99,
+ 'user_id' => 99,
+ 'random_id_in_the_middle' => 99,
+ 'notid' => 99
+ }
+ end
+
+ it 'removes unwanted attributes from the hash' do
+ described_class.clean!(relation_hash: unsafe_hash)
+
+ expect(unsafe_hash).to eq(post_safe_hash)
+ end
+end