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
This commit is contained in:
Bob Van Landuyt 2018-04-05 12:13:10 +02:00
parent e3acc982a8
commit 902cec12b5
7 changed files with 4 additions and 20 deletions

View file

@ -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

View file

@ -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:

View file

@ -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

View file

@ -2,7 +2,6 @@
"description": "Nisi et repellendus ut enim quo accusamus vel magnam.",
"visibility_level": 10,
"archived": false,
"description_html": "<p dir=\"auto\">Nisi et repellendus ut enim quo accusamus vel magnam.</p>",
"labels": [
{
"id": 2,

View file

@ -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 = "<p dir=\"auto\">Nisi et repellendus ut enim quo accusamus vel magnam.</p>"
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

View file

@ -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)

View file

@ -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