From 902cec12b5b531434ccf7ecf6df22ddb4249c253 Mon Sep 17 00:00:00 2001 From: Bob Van Landuyt Date: Thu, 5 Apr 2018 12:13:10 +0200 Subject: [PATCH] Don't export `Project#description_html` Since we can regenerate `description_html` from the `description`, we should not export it. This avoids some complexity when overriding the description during an import/export where we would need to invalidate this cached field. Now we refresh the markdown cache after the import --- app/models/project.rb | 1 + lib/gitlab/import_export/import_export.yml | 3 +-- lib/gitlab/import_export/project_tree_restorer.rb | 8 +------- spec/lib/gitlab/import_export/project.json | 1 - .../gitlab/import_export/project_tree_restorer_spec.rb | 5 ----- spec/lib/gitlab/import_export/project_tree_saver_spec.rb | 5 ----- spec/models/project_spec.rb | 1 + 7 files changed, 4 insertions(+), 20 deletions(-) diff --git a/app/models/project.rb b/app/models/project.rb index 71d2f30698e..1d583831156 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -1478,6 +1478,7 @@ class Project < ActiveRecord::Base remove_import_jid update_project_counter_caches after_create_default_branch + refresh_markdown_cache! end def update_project_counter_caches diff --git a/lib/gitlab/import_export/import_export.yml b/lib/gitlab/import_export/import_export.yml index 4bdd01f5e94..6a0a1b65fe9 100644 --- a/lib/gitlab/import_export/import_export.yml +++ b/lib/gitlab/import_export/import_export.yml @@ -105,6 +105,7 @@ excluded_attributes: - :last_repository_updated_at - :last_repository_check_at - :storage_version + - :description_html snippets: - :expired_at merge_request_diff: @@ -144,8 +145,6 @@ methods: - :diff_head_sha - :source_branch_sha - :target_branch_sha - project: - - :description_html events: - :action push_event_payload: diff --git a/lib/gitlab/import_export/project_tree_restorer.rb b/lib/gitlab/import_export/project_tree_restorer.rb index fb37e728485..2c315207298 100644 --- a/lib/gitlab/import_export/project_tree_restorer.rb +++ b/lib/gitlab/import_export/project_tree_restorer.rb @@ -83,13 +83,7 @@ module Gitlab end def restore_project - params = project_params.symbolize_keys - - if params[:description].present? - params[:description_html] = nil - end - - @project.update_columns(params) + @project.update_columns(project_params) @project end diff --git a/spec/lib/gitlab/import_export/project.json b/spec/lib/gitlab/import_export/project.json index 382a562224a..8c1bf6f7be8 100644 --- a/spec/lib/gitlab/import_export/project.json +++ b/spec/lib/gitlab/import_export/project.json @@ -2,7 +2,6 @@ "description": "Nisi et repellendus ut enim quo accusamus vel magnam.", "visibility_level": 10, "archived": false, - "description_html": "

Nisi et repellendus ut enim quo accusamus vel magnam.

", "labels": [ { "id": 2, 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 55373dcb2c8..13a8c9adcee 100644 --- a/spec/lib/gitlab/import_export/project_tree_restorer_spec.rb +++ b/spec/lib/gitlab/import_export/project_tree_restorer_spec.rb @@ -46,11 +46,6 @@ describe Gitlab::ImportExport::ProjectTreeRestorer do expect(Project.find_by_path('project').description).to eq('Nisi et repellendus ut enim quo accusamus vel magnam.') end - it 'has the project html description' do - expected_description_html = "

Nisi et repellendus ut enim quo accusamus vel magnam.

" - expect(Project.find_by_path('project').description_html).to eq(expected_description_html) - end - it 'has the same label associated to two issues' do expect(ProjectLabel.find_by_title('test2').issues.count).to eq(2) 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 0d20a551e2a..2b8a11ce8f9 100644 --- a/spec/lib/gitlab/import_export/project_tree_saver_spec.rb +++ b/spec/lib/gitlab/import_export/project_tree_saver_spec.rb @@ -245,10 +245,6 @@ describe Gitlab::ImportExport::ProjectTreeSaver do end context 'project attributes' do - it 'contains the html description' do - expect(saved_project_json).to include("description_html" => 'description') - end - it 'does not contain the runners token' do expect(saved_project_json).not_to include("runners_token" => 'token') end @@ -274,7 +270,6 @@ describe Gitlab::ImportExport::ProjectTreeSaver do releases: [release], group: group ) - project.update_column(:description_html, 'description') project_label = create(:label, project: project) group_label = create(:group_label, group: group) create(:label_link, label: project_label, target: issue) diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb index 0e560be9eaa..af5b1654b65 100644 --- a/spec/models/project_spec.rb +++ b/spec/models/project_spec.rb @@ -3227,6 +3227,7 @@ describe Project do expect(project).to receive(:update_project_counter_caches) expect(project).to receive(:remove_import_jid) expect(project).to receive(:after_create_default_branch) + expect(project).to receive(:refresh_markdown_cache!) project.after_import end