Commit be0c266c authored by James Lopez's avatar James Lopez

Merge branches 'feature/project-export-ui-experimental' and...

Merge branches 'feature/project-export-ui-experimental' and 'feature/project-import' of gitlab.com:gitlab-org/gitlab-ce into feature/project-export-ui-experimental
parents 797504a8 0de533ed
...@@ -2,9 +2,10 @@ module Gitlab ...@@ -2,9 +2,10 @@ module Gitlab
module ImportExport module ImportExport
class AttributesFinder class AttributesFinder
def initialize(included_attributes:, excluded_attributes:) def initialize(included_attributes:, excluded_attributes:, methods:)
@included_attributes = included_attributes || {} @included_attributes = included_attributes || {}
@excluded_attributes = excluded_attributes || {} @excluded_attributes = excluded_attributes || {}
@methods = methods || {}
end end
def find(model_object) def find(model_object)
...@@ -27,10 +28,15 @@ module Gitlab ...@@ -27,10 +28,15 @@ module Gitlab
@excluded_attributes[key].nil? ? {} : { except: @excluded_attributes[key] } @excluded_attributes[key].nil? ? {} : { except: @excluded_attributes[key] }
end end
def find_method(value)
key = key_from_hash(value)
@methods[key].nil? ? {} : { methods: @methods[key] }
end
private private
def find_attributes_only(value) def find_attributes_only(value)
find_included(value).merge(find_excluded(value)) find_included(value).merge(find_excluded(value)).merge(find_method(value))
end end
def key_from_hash(value) def key_from_hash(value)
......
...@@ -46,3 +46,7 @@ included_attributes: ...@@ -46,3 +46,7 @@ included_attributes:
excluded_attributes: excluded_attributes:
snippets: snippets:
- :expired_at - :expired_at
methods:
statuses:
- :type
\ No newline at end of file
...@@ -9,7 +9,8 @@ module Gitlab ...@@ -9,7 +9,8 @@ module Gitlab
config_hash = YAML.load_file(config).deep_symbolize_keys config_hash = YAML.load_file(config).deep_symbolize_keys
@tree = config_hash[:project_tree] @tree = config_hash[:project_tree]
@attributes_parser = Gitlab::ImportExport::AttributesFinder.new(included_attributes: config_hash[:included_attributes], @attributes_parser = Gitlab::ImportExport::AttributesFinder.new(included_attributes: config_hash[:included_attributes],
excluded_attributes: config_hash[:excluded_attributes]) excluded_attributes: config_hash[:excluded_attributes],
methods: config_hash[:methods])
end end
def project_tree def project_tree
......
...@@ -34,4 +34,3 @@ module Gitlab ...@@ -34,4 +34,3 @@ module Gitlab
end end
end end
end end
...@@ -84,10 +84,15 @@ describe Gitlab::ImportExport::ProjectTreeSaver, services: true do ...@@ -84,10 +84,15 @@ describe Gitlab::ImportExport::ProjectTreeSaver, services: true do
it 'has author on merge requests comments' do it 'has author on merge requests comments' do
expect(saved_project_json['merge_requests'].first['notes'].first['author']).not_to be_empty expect(saved_project_json['merge_requests'].first['notes'].first['author']).not_to be_empty
end end
it 'has commit statuses' do it 'has commit statuses' do
expect(saved_project_json['ci_commits'].first['statuses']).not_to be_empty expect(saved_project_json['ci_commits'].first['statuses']).not_to be_empty
end end
it 'has CI builds' do
expect(saved_project_json['ci_commits'].first['statuses'].first['type']).to eq('Ci::Build')
end
it 'has ci commits' do it 'has ci commits' do
expect(saved_project_json['ci_commits']).not_to be_empty expect(saved_project_json['ci_commits']).not_to be_empty
end end
...@@ -99,7 +104,6 @@ describe Gitlab::ImportExport::ProjectTreeSaver, services: true do ...@@ -99,7 +104,6 @@ describe Gitlab::ImportExport::ProjectTreeSaver, services: true do
merge_request = create(:merge_request) merge_request = create(:merge_request)
label = create(:label) label = create(:label)
snippet = create(:project_snippet) snippet = create(:project_snippet)
commit_status = create(:commit_status)
release = create(:release) release = create(:release)
project = create(:project, project = create(:project,
...@@ -111,7 +115,8 @@ describe Gitlab::ImportExport::ProjectTreeSaver, services: true do ...@@ -111,7 +115,8 @@ describe Gitlab::ImportExport::ProjectTreeSaver, services: true do
releases: [release] releases: [release]
) )
create(:ci_commit, project: project, sha: merge_request.last_commit.id, ref: merge_request.source_branch, statuses: [commit_status]) ci_commit = create(:ci_commit, project: project, sha: merge_request.last_commit.id, ref: merge_request.source_branch)
create(:ci_build, commit: ci_commit)
create(:milestone, project: project) create(:milestone, project: project)
create(:note, noteable: issue) create(:note, noteable: issue)
create(:note, noteable: merge_request) create(:note, noteable: merge_request)
......
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