diff options
author | Simon Knox <simon@gitlab.com> | 2018-11-08 07:02:44 +0000 |
---|---|---|
committer | Sean McGivern <sean@mcgivern.me.uk> | 2018-11-08 07:02:44 +0000 |
commit | 11a606fe275251a7a64aee4ca526c36ae12c5735 (patch) | |
tree | cbdfb334aed24a958e81d22d185df969efcd5170 /spec/lib | |
parent | df8f663689aba29424406ebf2a9e786fb6dcdd14 (diff) | |
download | gitlab-ce-11a606fe275251a7a64aee4ca526c36ae12c5735.tar.gz |
backport changes from gitlab-ee!7903
Diffstat (limited to 'spec/lib')
-rw-r--r-- | spec/lib/gitlab/import_export/attribute_configuration_spec.rb | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/spec/lib/gitlab/import_export/attribute_configuration_spec.rb b/spec/lib/gitlab/import_export/attribute_configuration_spec.rb index 65f073b2df3..87ab81d8169 100644 --- a/spec/lib/gitlab/import_export/attribute_configuration_spec.rb +++ b/spec/lib/gitlab/import_export/attribute_configuration_spec.rb @@ -23,15 +23,23 @@ describe 'Import/Export attribute configuration' do let(:safe_attributes_file) { 'spec/lib/gitlab/import_export/safe_model_attributes.yml' } let(:safe_model_attributes) { YAML.load_file(safe_attributes_file) } + let(:ee_safe_attributes_file) { 'ee/spec/lib/gitlab/import_export/safe_model_attributes.yml' } + let(:ee_safe_model_attributes) { File.exist?(ee_safe_attributes_file) ? YAML.load_file(ee_safe_attributes_file) : {} } + it 'has no new columns' do relation_names.each do |relation_name| relation_class = relation_class_for_name(relation_name) relation_attributes = relation_class.new.attributes.keys - expect(safe_model_attributes[relation_class.to_s]).not_to be_nil, "Expected exported class #{relation_class} to exist in safe_model_attributes" - current_attributes = parsed_attributes(relation_name, relation_attributes) - safe_attributes = safe_model_attributes[relation_class.to_s] + safe_attributes = safe_model_attributes[relation_class.to_s].dup || [] + + ee_safe_model_attributes[relation_class.to_s].to_a.each do |attribute| + safe_attributes << attribute + end + + expect(safe_attributes).not_to be_nil, "Expected exported class #{relation_class} to exist in safe_model_attributes" + new_attributes = current_attributes - safe_attributes expect(new_attributes).to be_empty, failure_message(relation_class.to_s, new_attributes) @@ -43,6 +51,7 @@ describe 'Import/Export attribute configuration' do It looks like #{relation_class}, which is exported using the project Import/Export, has new attributes: #{new_attributes.join(',')} Please add the attribute(s) to SAFE_MODEL_ATTRIBUTES if you consider this can be exported. + #{"If the model/associations are EE-specific, use `#{File.expand_path(ee_safe_attributes_file)}`.\n" if ee_safe_model_attributes.any?} Otherwise, please blacklist the attribute(s) in IMPORT_EXPORT_CONFIG by adding it to its correspondent model in the +excluded_attributes+ section. |