Files
Douwe MaanandRobert Speicher bf0294378e Merge branch 'feature/project-export' into 'master'
Export project functionality

This is a MR for the export functionality of https://gitlab.com/gitlab-org/gitlab-ce/issues/3050, which adds the ability to export single projects.

- [x] members
- DB data
  - [x] issues
  - [x] issue comments
  - [x] merge requests
  - [x] merge request diff
  - [x] merge request comments
  - [x] labels
  - [x] milestones
  - [x] snippets
  - [x] releases
  - [x] events
  - [x] commit statuses
  - [x] CI builds
- File system data
  - [x] Git repository
  - [x] wiki
  - [x] uploads
  - [ ] ~~CI build traces~~
  - [ ] ~~CI build artifacts~~
  - [ ] ~~LFS objects~~
- DB configuration
  - [x] services
  - [x] web hooks
  - [x] protected branches
  - [x] deploy keys
  - [x] CI variables
  - [x] CI triggers

See merge request !3114
2016-06-17 14:18:15 -04:00

88 lines
3.5 KiB
Ruby

require 'spec_helper'
describe Gitlab::ImportExport::Reader, lib: true do
let(:shared) { Gitlab::ImportExport::Shared.new(relative_path:'') }
let(:test_config) { 'spec/support/import_export/import_export.yml' }
let(:project_tree_hash) do
{
only: [:name, :path],
include: [:issues, :labels,
{ merge_requests: {
only: [:id],
except: [:iid],
include: [:merge_request_diff, :merge_request_test]
} },
{ commit_statuses: { include: :commit } }]
}
end
before do
allow_any_instance_of(Gitlab::ImportExport).to receive(:config_file).and_return(test_config)
end
it 'generates hash from project tree config' do
expect(described_class.new(shared: shared).project_tree).to match(project_tree_hash)
end
context 'individual scenarios' do
it 'generates the correct hash for a single project relation' do
setup_yaml(project_tree: [:issues])
expect(described_class.new(shared: shared).project_tree).to match(include: [:issues])
end
it 'generates the correct hash for a multiple project relation' do
setup_yaml(project_tree: [:issues, :snippets])
expect(described_class.new(shared: shared).project_tree).to match(include: [:issues, :snippets])
end
it 'generates the correct hash for a single sub-relation' do
setup_yaml(project_tree: [issues: [:notes]])
expect(described_class.new(shared: shared).project_tree).to match(include: [{ issues: { include: :notes } }])
end
it 'generates the correct hash for a multiple sub-relation' do
setup_yaml(project_tree: [merge_requests: [:notes, :merge_request_diff]])
expect(described_class.new(shared: shared).project_tree).to match(include: [{ merge_requests: { include: [:notes, :merge_request_diff] } }])
end
it 'generates the correct hash for a sub-relation with another sub-relation' do
setup_yaml(project_tree: [merge_requests: [notes: :author]])
expect(described_class.new(shared: shared).project_tree).to match(include: [{ merge_requests: { include: { notes: { include: :author } } } }])
end
it 'generates the correct hash for a relation with included attributes' do
setup_yaml(project_tree: [:issues], included_attributes: { issues: [:name, :description] })
expect(described_class.new(shared: shared).project_tree).to match(include: [{ issues: { only: [:name, :description] } }])
end
it 'generates the correct hash for a relation with excluded attributes' do
setup_yaml(project_tree: [:issues], excluded_attributes: { issues: [:name] })
expect(described_class.new(shared: shared).project_tree).to match(include: [{ issues: { except: [:name] } }])
end
it 'generates the correct hash for a relation with both excluded and included attributes' do
setup_yaml(project_tree: [:issues], excluded_attributes: { issues: [:name] }, included_attributes: { issues: [:description] })
expect(described_class.new(shared: shared).project_tree).to match(include: [{ issues: { except: [:name], only: [:description] } }])
end
it 'generates the correct hash for a relation with custom methods' do
setup_yaml(project_tree: [:issues], methods: { issues: [:name] })
expect(described_class.new(shared: shared).project_tree).to match(include: [{ issues: { methods: [:name] } }])
end
def setup_yaml(hash)
allow(YAML).to receive(:load_file).with(test_config).and_return(hash)
end
end
end