summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Colyer <jcolyer@Jasons-MacBook-Pro.local>2019-08-02 14:35:10 -0500
committerJason Colyer <jcolyer@Jasons-MacBook-Pro.local>2019-08-02 14:35:10 -0500
commit87235d009c8d5f40ec0f29575c7af6e91cb0a926 (patch)
tree82cf812f00ac0c8f82416e13f8d86d2e6cfcd5dd
parente14265d50d80e96db694f66d6ea3a12b1fdcf943 (diff)
downloadgitlab-ce-87235d009c8d5f40ec0f29575c7af6e91cb0a926.tar.gz
Make issue boards importable
- Added Importable to models/list.rb - Did unless: :importable? on board validation - Created changelog - Modified haml to show issue boards are importable - Added needed spec tests - Modified project.json to include board information - Added relevant models to all_models - Added relevant models to import_export - Added relevant models to safe_model_attributes
-rw-r--r--app/models/list.rb3
-rw-r--r--app/views/projects/_export.html.haml1
-rw-r--r--changelogs/unreleased/make-issue-boards-importable.yml5
-rw-r--r--lib/gitlab/import_export/import_export.yml9
-rw-r--r--spec/lib/gitlab/import_export/all_models.yml14
-rw-r--r--spec/lib/gitlab/import_export/project.json60
-rw-r--r--spec/lib/gitlab/import_export/project_tree_restorer_spec.rb10
-rw-r--r--spec/lib/gitlab/import_export/project_tree_saver_spec.rb7
-rw-r--r--spec/lib/gitlab/import_export/safe_model_attributes.yml19
9 files changed, 126 insertions, 2 deletions
diff --git a/app/models/list.rb b/app/models/list.rb
index d28a9bda82d..ccadd39bda2 100644
--- a/app/models/list.rb
+++ b/app/models/list.rb
@@ -3,10 +3,11 @@
class List < ApplicationRecord
belongs_to :board
belongs_to :label
+ include Importable
enum list_type: { backlog: 0, label: 1, closed: 2, assignee: 3, milestone: 4 }
- validates :board, :list_type, presence: true
+ validates :board, :list_type, presence: true, unless: :importing?
validates :label, :position, presence: true, if: :label?
validates :label_id, uniqueness: { scope: :board_id }, if: :label?
validates :position, numericality: { only_integer: true, greater_than_or_equal_to: 0 }, if: :movable?
diff --git a/app/views/projects/_export.html.haml b/app/views/projects/_export.html.haml
index 1056977886a..d14c5c27b65 100644
--- a/app/views/projects/_export.html.haml
+++ b/app/views/projects/_export.html.haml
@@ -15,6 +15,7 @@
%li= _('Project configuration, including services')
%li= _('Issues with comments, merge requests with diffs and comments, labels, milestones, snippets, and other project entities')
%li= _('LFS objects')
+ %li=_('Issue Boards')
%p= _('The following items will NOT be exported:')
%ul
%li= _('Job traces and artifacts')
diff --git a/changelogs/unreleased/make-issue-boards-importable.yml b/changelogs/unreleased/make-issue-boards-importable.yml
new file mode 100644
index 00000000000..fd270a236dc
--- /dev/null
+++ b/changelogs/unreleased/make-issue-boards-importable.yml
@@ -0,0 +1,5 @@
+---
+title: Make issue boards importable
+merge_request: 31434
+author: Jason Colyer
+type: changed
diff --git a/lib/gitlab/import_export/import_export.yml b/lib/gitlab/import_export/import_export.yml
index 01437c67fa9..29da46fb18d 100644
--- a/lib/gitlab/import_export/import_export.yml
+++ b/lib/gitlab/import_export/import_export.yml
@@ -80,6 +80,13 @@ project_tree:
- :ci_cd_settings
- :error_tracking_setting
- :metrics_setting
+ - boards:
+ - lists:
+ - label:
+ - :priorities
+ - milestone:
+ - events:
+ - :push_event_payload
# Only include the following attributes for the models specified.
included_attributes:
@@ -216,6 +223,8 @@ methods:
- :action
project_badges:
- :type
+ lists:
+ - :list_type
# EE specific relationships and settings to include. All of this will be merged
# into the previous structures if EE is used.
diff --git a/spec/lib/gitlab/import_export/all_models.yml b/spec/lib/gitlab/import_export/all_models.yml
index 929b6222900..ada8c649ff6 100644
--- a/spec/lib/gitlab/import_export/all_models.yml
+++ b/spec/lib/gitlab/import_export/all_models.yml
@@ -469,3 +469,17 @@ incident_management_setting:
merge_trains:
- project
- merge_request
+boards:
+- group
+- lists
+- destroyable_lists
+- milestone
+- board_labels
+- board_assignee
+- assignee
+- labels
+lists:
+- user
+- milestone
+- board
+- label
diff --git a/spec/lib/gitlab/import_export/project.json b/spec/lib/gitlab/import_export/project.json
index 9e54ca28e58..6d70b147666 100644
--- a/spec/lib/gitlab/import_export/project.json
+++ b/spec/lib/gitlab/import_export/project.json
@@ -7147,5 +7147,65 @@
"link_url": "http://www.example.com",
"image_url": "http://www.example.com"
}
+ ],
+ "boards": [
+ {
+ "id": 29,
+ "project_id": 49,
+ "created_at": "2019-06-06T14:01:06.204Z",
+ "updated_at": "2019-06-06T14:22:37.045Z",
+ "name": "TestBoardABC",
+ "milestone_id": null,
+ "group_id": null,
+ "weight": null,
+ "lists": [
+ {
+ "id": 59,
+ "board_id": 29,
+ "label_id": null,
+ "list_type": "backlog",
+ "position": null,
+ "created_at": "2019-06-06T14:01:06.214Z",
+ "updated_at": "2019-06-06T14:01:06.214Z",
+ "user_id": null,
+ "milestone_id": null
+ },
+ {
+ "id": 61,
+ "board_id": 29,
+ "label_id": 20,
+ "list_type": "label",
+ "position": 0,
+ "created_at": "2019-06-06T14:01:43.197Z",
+ "updated_at": "2019-06-06T14:01:43.197Z",
+ "user_id": null,
+ "milestone_id": null,
+ "label": {
+ "id": 20,
+ "title": "testlabel",
+ "color": "#0033CC",
+ "project_id": 49,
+ "created_at": "2019-06-06T14:01:19.698Z",
+ "updated_at": "2019-06-06T14:01:19.698Z",
+ "template": false,
+ "description": null,
+ "group_id": null,
+ "type": "ProjectLabel",
+ "priorities": []
+ }
+ },
+ {
+ "id": 60,
+ "board_id": 29,
+ "label_id": null,
+ "list_type": "closed",
+ "position": null,
+ "created_at": "2019-06-06T14:01:06.221Z",
+ "updated_at": "2019-06-06T14:01:06.221Z",
+ "user_id": null,
+ "milestone_id": null
+ }
+ ]
+ }
]
}
diff --git a/spec/lib/gitlab/import_export/project_tree_restorer_spec.rb b/spec/lib/gitlab/import_export/project_tree_restorer_spec.rb
index b9f6595762b..baec24590b4 100644
--- a/spec/lib/gitlab/import_export/project_tree_restorer_spec.rb
+++ b/spec/lib/gitlab/import_export/project_tree_restorer_spec.rb
@@ -160,13 +160,21 @@ describe Gitlab::ImportExport::ProjectTreeRestorer do
end
it 'has project labels' do
- expect(ProjectLabel.count).to eq(2)
+ expect(ProjectLabel.count).to eq(3)
end
it 'has no group labels' do
expect(GroupLabel.count).to eq(0)
end
+ it 'has issue boards' do
+ expect(Project.find_by_path('project').boards.count).to eq(1)
+ end
+
+ it 'has lists associated with the issue board' do
+ expect(Project.find_by_path('project').boards.find_by_name('TestBoardABC').lists.count).to eq(3)
+ end
+
it 'has a project feature' do
expect(@project.project_feature).not_to be_nil
end
diff --git a/spec/lib/gitlab/import_export/project_tree_saver_spec.rb b/spec/lib/gitlab/import_export/project_tree_saver_spec.rb
index 1ff2eb9210f..fefbed93316 100644
--- a/spec/lib/gitlab/import_export/project_tree_saver_spec.rb
+++ b/spec/lib/gitlab/import_export/project_tree_saver_spec.rb
@@ -272,6 +272,10 @@ describe Gitlab::ImportExport::ProjectTreeSaver do
expect(saved_project_json).not_to include("runners_token" => 'token')
end
end
+
+ it 'has a board and a list' do
+ expect(saved_project_json['boards'].first['lists']).not_to be_empty
+ end
end
end
@@ -327,6 +331,9 @@ describe Gitlab::ImportExport::ProjectTreeSaver do
create(:project_badge, project: project)
create(:project_badge, project: project)
+ board = create(:board, project: project, name: 'TestBoard')
+ create(:list, board: board, position: 0, label: project_label)
+
project
end
diff --git a/spec/lib/gitlab/import_export/safe_model_attributes.yml b/spec/lib/gitlab/import_export/safe_model_attributes.yml
index 28b187c3676..e1099b681fb 100644
--- a/spec/lib/gitlab/import_export/safe_model_attributes.yml
+++ b/spec/lib/gitlab/import_export/safe_model_attributes.yml
@@ -687,3 +687,22 @@ ProjectMetricsSetting:
- external_dashboard_url
- created_at
- updated_at
+Board:
+- id
+- project_id
+- created_at
+- updated_at
+- group_id
+- milestone_id
+- weight
+- name
+List:
+- id
+- board_id
+- label_id
+- list_type
+- position
+- created_at
+- updated_at
+- milestone_id
+- user_id