提交 973f2dd9 编写于 作者: M Michael Leopard

Reversing pipeline order on import

Updating tree restorer and saver tests
上级 a9cd5d2a
---
title: Reverse Pipeline Order On Import
merge_request: 32388
author:
type: fixed
......@@ -28,6 +28,8 @@ module Gitlab
RelationRenameService.rename(@tree_hash)
correct_pipeline_order
ActiveRecord::Base.uncached do
ActiveRecord::Base.no_touching do
create_relations
......@@ -235,6 +237,15 @@ module Gitlab
def nil_iid_pipeline?(relation_key, relation_item)
relation_key == 'ci_pipelines' && relation_item['iid'].nil?
end
def correct_pipeline_order
if @tree_hash['ci_pipelines'].present?
pipelines = @tree_hash["ci_pipelines"]
if pipelines.first["created_at"] > pipelines.last["created_at"]
@tree_hash["ci_pipelines"].sort_by! { |pipelines| pipelines['created_at'] }
end
end
end
end
end
end
......@@ -62,6 +62,13 @@ describe Gitlab::ImportExport::ProjectTreeRestorer do
expect(Milestone.find_by_description('test milestone').issues.count).to eq(2)
end
it 'has ci pipeline builds in reverse chronological order' do
first_build = @project.ci_pipelines.first
last_build = @project.ci_pipelines.last
expect(first_build["created_at"]).to be < last_build["created_at"]
end
context 'when importing a project with cached_markdown_version and note_html' do
context 'for an Issue' do
it 'does not import note_html' do
......
......@@ -196,10 +196,9 @@ describe Gitlab::ImportExport::ProjectTreeSaver do
it 'has pipeline builds' do
builds_count = saved_project_json
.dig('ci_pipelines', 0, 'stages', 0, 'statuses')
.count { |hash| hash['type'] == 'Ci::Build' }
.dig('ci_pipelines').length
expect(builds_count).to eq(1)
expect(builds_count).to eq(3)
end
it 'has no when YML attributes but only the DB column' do
......@@ -359,18 +358,22 @@ describe Gitlab::ImportExport::ProjectTreeSaver do
milestone = create(:milestone, project: project)
merge_request = create(:merge_request, source_project: project, milestone: milestone)
ci_build = create(:ci_build, project: project, when: nil)
ci_build.pipeline.update(project: project)
create(:commit_status, project: project, pipeline: ci_build.pipeline)
create(:milestone, project: project)
create(:discussion_note, noteable: issue, project: project)
create(:note, noteable: merge_request, project: project)
create(:note, noteable: snippet, project: project)
create(:note_on_commit,
author: user,
project: project,
commit_id: ci_build.pipeline.sha)
pipelines = []
3.times do |i|
pipelines.push(create(:ci_empty_pipeline, project: project, sha: project.commit.sha, ref: 'master'))
ci_build = create(:ci_build, project: project, when: nil, pipeline: pipelines[i])
ci_build.pipeline.update(project: project)
create(:commit_status, project: project, pipeline: ci_build.pipeline)
create(:milestone, project: project)
create(:discussion_note, noteable: issue, project: project)
create(:note, noteable: merge_request, project: project)
create(:note, noteable: snippet, project: project)
create(:note_on_commit,
author: user,
project: project,
commit_id: ci_build.pipeline.sha)
end
create(:resource_label_event, label: project_label, issue: issue)
create(:resource_label_event, label: group_label, merge_request: merge_request)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册