Commit c94c0dc0 authored by James Lopez's avatar James Lopez

Merge branch 'feature/project-export' of gitlab.com:gitlab-org/gitlab-ce into...

Merge branch 'feature/project-export' of gitlab.com:gitlab-org/gitlab-ce into feature/project-import
parents 49539779 3b99e4ae
# Model relationships to be included in the project import/export
:project_tree:
- :issues
- :issues:
- :notes
- :labels
- :milestones
- :snippets
......@@ -10,6 +11,7 @@
- :user
- :merge_requests:
- :merge_request_diff
- :notes
- :commit_statuses:
- :commit
......
......@@ -30,8 +30,6 @@ module Projects
end
def project_json_tree
# TODO confirm children, also add subchildren (i.e comments)
# TODO confirm atts for children
@project.to_json(Projects::ImportExport.project_tree)
end
end
......
......@@ -3,6 +3,8 @@ require 'spec_helper'
describe Projects::ImportExport::ProjectTreeSaver, services: true do
describe :save do
# TODO refactor this into a setup method
let(:user) { create(:user) }
let(:issue) { create(:issue, assignee: user) }
let(:merge_request) { create(:merge_request) }
......@@ -25,6 +27,8 @@ describe Projects::ImportExport::ProjectTreeSaver, services: true do
let(:export_path) { "#{Dir::tmpdir}/project_tree_saver_spec" }
let(:shared) { Projects::ImportExport::Shared.new(relative_path: project.path_with_namespace) }
let(:project_tree_saver) { Projects::ImportExport::ProjectTreeSaver.new(project: project, shared: shared) }
let!(:issue_note) { create(:note, note: ":+1: issue", noteable: issue) }
let!(:merge_request_note) { create(:note, note: ":+1: merge_request", noteable: merge_request) }
before(:each) do
project.team << [user, :master]
......@@ -78,6 +82,10 @@ describe Projects::ImportExport::ProjectTreeSaver, services: true do
expect(saved_project_json['issues']).not_to be_empty
end
it 'has issue comments' do
expect(saved_project_json['issues'].first['notes']).not_to be_empty
end
it 'has commit statuses' do
expect(saved_project_json['commit_statuses']).not_to be_empty
end
......@@ -90,6 +98,10 @@ describe Projects::ImportExport::ProjectTreeSaver, services: true do
expect(saved_project_json['merge_requests'].first['merge_request_diff']).not_to be_empty
end
it 'has merge requests comments' do
expect(saved_project_json['merge_requests'].first['notes']).not_to be_empty
end
it 'has ci commits' do
expect(saved_project_json['commit_statuses'].first['commit']).not_to be_empty
end
......@@ -99,163 +111,4 @@ describe Projects::ImportExport::ProjectTreeSaver, services: true do
def project_json(filename)
JSON.parse(IO.read(filename))
end
# TODO: Remove this. Current JSON pretty printed:
# {
# "id":7,
# "name":"searchable_project",
# "path":"gitlabhq",
# "description":null,
# "issues_enabled":true,
# "wall_enabled":false,
# "merge_requests_enabled":true,
# "wiki_enabled":true,
# "snippets_enabled":true,
# "visibility_level":20,
# "archived":false,
# "issues":[
# {
# "id":1,
# "title":"Voluptas dolores molestias iste excepturi quia atque sint et.",
# "assignee_id":1,
# "author_id":2,
# "project_id":7,
# "created_at":"2016-03-08T09:14:31.726Z",
# "updated_at":"2016-03-08T09:14:36.293Z",
# "position":0,
# "branch_name":null,
# "description":null,
# "milestone_id":null,
# "state":"opened",
# "iid":1,
# "updated_by_id":null
# }
# ],
# "merge_requests":[
# {
# "id":1,
# "target_branch":"feature",
# "source_branch":"master",
# "source_project_id":2,
# "author_id":5,
# "assignee_id":null,
# "title":"Quam velit cupiditate culpa perspiciatis esse maiores quaerat.",
# "created_at":"2016-03-08T09:14:32.597Z",
# "updated_at":"2016-03-08T09:14:32.597Z",
# "milestone_id":null,
# "state":"opened",
# "merge_status":"can_be_merged",
# "target_project_id":7,
# "iid":1,
# "description":null,
# "position":0,
# "locked_at":null,
# "updated_by_id":null,
# "merge_error":null,
# "merge_params":{
#
# },
# "merge_when_build_succeeds":false,
# "merge_user_id":null,
# "merge_commit_sha":null
# }
# ],
# "labels":[
# {
# "id":1,
# "title":"Bug",
# "color":"#990000",
# "project_id":7,
# "created_at":"2016-03-08T09:14:33.774Z",
# "updated_at":"2016-03-08T09:14:36.314Z",
# "template":false,
# "description":null
# }
# ],
# "milestones":[
# {
# "id":1,
# "title":"Milestone v1.2",
# "project_id":7,
# "description":null,
# "due_date":null,
# "created_at":"2016-03-08T09:14:36.526Z",
# "updated_at":"2016-03-08T09:14:36.526Z",
# "state":"active",
# "iid":1
# }
# ],
# "snippets":[
# {
# "id":1,
# "title":"Voluptatem qui officiis modi ut fugit distinctio dolor qui.",
# "content":"Quaerat sunt eligendi voluptatum magnam.",
# "author_id":12,
# "project_id":7,
# "created_at":"2016-03-08T09:14:34.539Z",
# "updated_at":"2016-03-08T09:14:36.332Z",
# "file_name":"rowland.tremblay",
# "expires_at":null,
# "visibility_level":0
# }
# ],
# "releases":[
# {
# "id":1,
# "tag":"v1.1.0",
# "description":"Awesome release",
# "project_id":7,
# "created_at":"2016-03-08T09:14:35.023Z",
# "updated_at":"2016-03-08T09:14:36.351Z"
# }
# ],
# "events":[
# {
# "id":1,
# "target_type":null,
# "target_id":null,
# "title":null,
# "data":null,
# "project_id":7,
# "created_at":"2016-03-08T09:14:36.806Z",
# "updated_at":"2016-03-08T09:14:36.806Z",
# "action":8,
# "author_id":1
# }
# ],
# "commit_statuses":[
# {
# "id":1,
# "project_id":null,
# "status":"success",
# "finished_at":"2016-01-26T07:23:42.000Z",
# "trace":null,
# "created_at":"2016-03-08T09:14:35.633Z",
# "updated_at":"2016-03-08T09:14:36.385Z",
# "started_at":"2016-01-26T07:21:42.000Z",
# "runner_id":null,
# "coverage":null,
# "commit_id":1,
# "commands":null,
# "job_id":null,
# "name":"default",
# "deploy":false,
# "options":null,
# "allow_failure":false,
# "stage":null,
# "trigger_request_id":null,
# "stage_idx":null,
# "tag":null,
# "ref":null,
# "user_id":null,
# "target_url":null,
# "description":"commit status",
# "artifacts_file":null,
# "gl_project_id":7,
# "artifacts_metadata":null,
# "erased_by_id":null,
# "erased_at":null
# }
# ]
# }
end
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