2016-11-03 12:29:30 +05:30
|
|
|
require 'spec_helper'
|
|
|
|
|
2017-09-10 17:25:29 +05:30
|
|
|
describe Gitlab::ImportExport::AttributeCleaner do
|
2018-03-17 18:26:18 +05:30
|
|
|
let(:relation_class) { double('relation_class').as_null_object }
|
2016-11-03 12:29:30 +05:30
|
|
|
let(:unsafe_hash) do
|
|
|
|
{
|
|
|
|
'id' => 101,
|
|
|
|
'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
|
|
|
|
# allow(relation_class).to receive(:attribute_method?).and_return(true)
|
|
|
|
parsed_hash = described_class.clean(relation_hash: unsafe_hash, relation_class: relation_class)
|
|
|
|
|
|
|
|
expect(parsed_hash).to eq(post_safe_hash)
|
|
|
|
end
|
|
|
|
end
|