Commit 0f2dff62 authored by charlieablett's avatar charlieablett

Exclude fields from note import

parent 30940ccd
...@@ -141,6 +141,9 @@ excluded_attributes: ...@@ -141,6 +141,9 @@ excluded_attributes:
- :external_diff_size - :external_diff_size
issues: issues:
- :milestone_id - :milestone_id
notes:
- :note_html
- :cached_markdown_version
merge_requests: merge_requests:
- :milestone_id - :milestone_id
- :ref_fetched - :ref_fetched
......
...@@ -158,6 +158,8 @@ ...@@ -158,6 +158,8 @@
{ {
"id": 351, "id": 351,
"note": "Quo reprehenderit aliquam qui dicta impedit cupiditate eligendi.", "note": "Quo reprehenderit aliquam qui dicta impedit cupiditate eligendi.",
"note_html": "<p>dodgy html</p>",
"cached_markdown_version": 434343,
"noteable_type": "Issue", "noteable_type": "Issue",
"author_id": 26, "author_id": 26,
"created_at": "2016-06-14T15:02:47.770Z", "created_at": "2016-06-14T15:02:47.770Z",
...@@ -182,6 +184,8 @@ ...@@ -182,6 +184,8 @@
"note": "Est reprehenderit quas aut aspernatur autem recusandae voluptatem.", "note": "Est reprehenderit quas aut aspernatur autem recusandae voluptatem.",
"noteable_type": "Issue", "noteable_type": "Issue",
"author_id": 25, "author_id": 25,
"note_html": "<p>dodgy html</p>",
"cached_markdown_version": 121212,
"created_at": "2016-06-14T15:02:47.795Z", "created_at": "2016-06-14T15:02:47.795Z",
"updated_at": "2016-06-14T15:02:47.795Z", "updated_at": "2016-06-14T15:02:47.795Z",
"project_id": 5, "project_id": 5,
......
...@@ -7,8 +7,8 @@ describe Gitlab::ImportExport::ProjectTreeRestorer do ...@@ -7,8 +7,8 @@ describe Gitlab::ImportExport::ProjectTreeRestorer do
# Using an admin for import, so we can check assignment of existing members # Using an admin for import, so we can check assignment of existing members
@user = create(:admin) @user = create(:admin)
@existing_members = [ @existing_members = [
create(:user, username: 'bernard_willms'), create(:user, username: 'bernard_willms'),
create(:user, username: 'saul_will') create(:user, username: 'saul_will')
] ]
RSpec::Mocks.with_temporary_scope do RSpec::Mocks.with_temporary_scope do
...@@ -21,6 +21,8 @@ describe Gitlab::ImportExport::ProjectTreeRestorer do ...@@ -21,6 +21,8 @@ describe Gitlab::ImportExport::ProjectTreeRestorer do
expect_any_instance_of(Gitlab::Git::Repository).to receive(:create_branch).with('feature', 'DCBA') 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(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) project_tree_restorer = described_class.new(user: @user, shared: @shared, project: @project)
...@@ -58,6 +60,24 @@ describe Gitlab::ImportExport::ProjectTreeRestorer do ...@@ -58,6 +60,24 @@ describe Gitlab::ImportExport::ProjectTreeRestorer do
expect(Milestone.find_by_description('test milestone').issues.count).to eq(2) expect(Milestone.find_by_description('test milestone').issues.count).to eq(2)
end 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 it 'creates a valid pipeline note' do
expect(Ci::Pipeline.find_by_sha('sha-notes').notes).not_to be_empty expect(Ci::Pipeline.find_by_sha('sha-notes').notes).not_to be_empty
end 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