From 0f2dff6264256531d314a8ac7f701f13bcfc7020 Mon Sep 17 00:00:00 2001 From: charlieablett Date: Tue, 23 Apr 2019 20:57:24 +1200 Subject: Exclude fields from note import --- lib/gitlab/import_export/import_export.yml | 3 +++ spec/lib/gitlab/import_export/project.json | 4 ++++ .../import_export/project_tree_restorer_spec.rb | 24 ++++++++++++++++++++-- 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": "

dodgy html

", + "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": "

dodgy html

", + "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 -- cgit v1.2.1