summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcharlieablett <cablett@gitlab.com>2019-04-23 20:57:24 +1200
committercharlieablett <cablett@gitlab.com>2019-04-23 20:57:24 +1200
commit0f2dff6264256531d314a8ac7f701f13bcfc7020 (patch)
tree7bd8aaba80d541c3780e3546698f523d801c2147
parent30940ccd242dcd05d7205f75af2c16e8dc4ae769 (diff)
downloadgitlab-ce-0f2dff6264256531d314a8ac7f701f13bcfc7020.tar.gz
Exclude fields from note import
-rw-r--r--lib/gitlab/import_export/import_export.yml3
-rw-r--r--spec/lib/gitlab/import_export/project.json4
-rw-r--r--spec/lib/gitlab/import_export/project_tree_restorer_spec.rb24
3 files changed, 29 insertions, 2 deletions
diff --git a/lib/gitlab/import_export/import_export.yml b/lib/gitlab/import_export/import_export.yml
index ce268793128..ab0c9a32d42 100644
--- a/lib/gitlab/import_export/import_export.yml
+++ b/lib/gitlab/import_export/import_export.yml
@@ -141,6 +141,9 @@ excluded_attributes:
- :external_diff_size
issues:
- :milestone_id
+ notes:
+ - :note_html
+ - :cached_markdown_version
merge_requests:
- :milestone_id
- :ref_fetched
diff --git a/spec/lib/gitlab/import_export/project.json b/spec/lib/gitlab/import_export/project.json
index 4a7accc4c52..24d376999fc 100644
--- a/spec/lib/gitlab/import_export/project.json
+++ b/spec/lib/gitlab/import_export/project.json
@@ -158,6 +158,8 @@
{
"id": 351,
"note": "Quo reprehenderit aliquam qui dicta impedit cupiditate eligendi.",
+ "note_html": "<p>dodgy html</p>",
+ "cached_markdown_version": 434343,
"noteable_type": "Issue",
"author_id": 26,
"created_at": "2016-06-14T15:02:47.770Z",
@@ -182,6 +184,8 @@
"note": "Est reprehenderit quas aut aspernatur autem recusandae voluptatem.",
"noteable_type": "Issue",
"author_id": 25,
+ "note_html": "<p>dodgy html</p>",
+ "cached_markdown_version": 121212,
"created_at": "2016-06-14T15:02:47.795Z",
"updated_at": "2016-06-14T15:02:47.795Z",
"project_id": 5,
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 6084dc96410..952844c5d6f 100644
--- a/spec/lib/gitlab/import_export/project_tree_restorer_spec.rb
+++ b/spec/lib/gitlab/import_export/project_tree_restorer_spec.rb
@@ -7,8 +7,8 @@ describe Gitlab::ImportExport::ProjectTreeRestorer do
# Using an admin for import, so we can check assignment of existing members
@user = create(:admin)
@existing_members = [
- create(:user, username: 'bernard_willms'),
- create(:user, username: 'saul_will')
+ create(:user, username: 'bernard_willms'),
+ create(:user, username: 'saul_will')
]
RSpec::Mocks.with_temporary_scope do
@@ -21,6 +21,8 @@ describe Gitlab::ImportExport::ProjectTreeRestorer do
expect_any_instance_of(Gitlab::Git::Repository).to receive(:create_branch).with('feature', 'DCBA')
allow_any_instance_of(Gitlab::Git::Repository).to receive(:create_branch)
+ allow_any_instance_of(Project).to receive(:latest_cached_markdown_version).and_return(434343)
+ allow_any_instance_of(Note).to receive(:latest_cached_markdown_version).and_return(434343)
project_tree_restorer = described_class.new(user: @user, shared: @shared, project: @project)
@@ -58,6 +60,24 @@ describe Gitlab::ImportExport::ProjectTreeRestorer do
expect(Milestone.find_by_description('test milestone').issues.count).to eq(2)
end
+ context 'when importing a project with cached_markdown_version and note_html' do
+ let!(:issue) { Issue.find_by(description: 'Aliquam enim illo et possimus.') }
+ let(:note1) { issue.notes.select {|n| n.note.match(/Quo reprehenderit aliquam qui dicta impedit cupiditate eligendi/)}.first }
+ let(:note2) { issue.notes.select {|n| n.note.match(/Est reprehenderit quas aut aspernatur autem recusandae voluptatem/)}.first }
+
+ it 'does not import the note_html' do
+ expect(note1.note_html).to match(/Et hic est id similique et non nesciunt voluptate/)
+ end
+
+ it 'does not set the old cached_markdown_version' do
+ expect(note2.cached_markdown_version).not_to eq(121212)
+ end
+
+ it 'does not import the note_html' do
+ expect(note2.note_html).to match(/Est reprehenderit quas aut aspernatur autem recusandae voluptatem/)
+ end
+ end
+
it 'creates a valid pipeline note' do
expect(Ci::Pipeline.find_by_sha('sha-notes').notes).not_to be_empty
end