Skip to content
代码片段 群组 项目
未验证 提交 219e3525 编辑于 作者: Dylan Griffith's avatar Dylan Griffith 提交者: GitLab
浏览文件

Merge branch '470888-cablett-elastic-work-item-serialisation-bug' into 'master'

Fix elastic work item serialisation specs

See merge request https://gitlab.com/gitlab-org/gitlab/-/merge_requests/158408



Merged-by: default avatarDylan Griffith <dyl.griffith@gmail.com>
Approved-by: default avatarDylan Griffith <dyl.griffith@gmail.com>
Co-authored-by: default avatarcharlieablett <cablett@gitlab.com>
No related branches found
No related tags found
无相关合并请求
...@@ -16,89 +16,98 @@ ...@@ -16,89 +16,98 @@
let(:result) { subject.as_indexed_json.with_indifferent_access } let(:result) { subject.as_indexed_json.with_indifferent_access }
it 'serializes the project_namespace work_item as a hash' do context 'when add_root_namespace_id_to_work_item migration is not complete' do
result = described_class.new(project_work_item.id, before do
project_work_item.es_parent).as_indexed_json.with_indifferent_access allow(::Elastic::DataMigrationService).to receive(:migration_has_finished?)
expect(result).to match( .with(:add_root_namespace_id_to_work_item)
project_id: project_work_item.reload.project_id, .and_return(false)
id: project_work_item.id, end
iid: project_work_item.iid,
created_at: project_work_item.created_at,
updated_at: project_work_item.updated_at,
title: project_work_item.title,
description: project_work_item.description,
state: project_work_item.state,
upvotes: project_work_item.upvotes_count,
hidden: project_work_item.hidden?,
work_item_type_id: project_work_item.work_item_type_id,
confidential: project_work_item.confidential,
author_id: project_work_item.author_id,
label_ids: [label.id.to_s],
assignee_id: project_work_item.issue_assignee_user_ids,
due_date: project_work_item.due_date,
traversal_ids: project_work_item.namespace.elastic_namespace_ancestry,
hashed_root_namespace_id: project_work_item.namespace.hashed_root_namespace_id,
namespace_visibility_level: project_work_item.namespace.visibility_level,
schema_version: described_class::SCHEMA_VERSION,
archived: project.archived?,
project_visibility_level: project.visibility_level,
work_item_access_level: project.issues_access_level,
type: 'work_item'
)
end
it 'serializes the user_namespace work_item as a hash' do it 'serializes the project_namespace work_item as a hash' do
result = described_class.new(user_work_item.id, user_work_item.es_parent).as_indexed_json.with_indifferent_access result = described_class.new(project_work_item.id,
expect(result).to match( project_work_item.es_parent).as_indexed_json.with_indifferent_access
project_id: user_work_item.reload.project_id, expect(result).to match(
id: user_work_item.id, project_id: project_work_item.reload.project_id,
iid: user_work_item.iid, id: project_work_item.id,
created_at: user_work_item.created_at, iid: project_work_item.iid,
updated_at: user_work_item.updated_at, created_at: project_work_item.created_at,
title: user_work_item.title, updated_at: project_work_item.updated_at,
description: user_work_item.description, title: project_work_item.title,
state: user_work_item.state, description: project_work_item.description,
upvotes: user_work_item.upvotes_count, state: project_work_item.state,
hidden: user_work_item.hidden?, upvotes: project_work_item.upvotes_count,
work_item_type_id: user_work_item.work_item_type_id, hidden: project_work_item.hidden?,
confidential: user_work_item.confidential, work_item_type_id: project_work_item.work_item_type_id,
author_id: user_work_item.author_id, confidential: project_work_item.confidential,
label_ids: [label.id.to_s], author_id: project_work_item.author_id,
assignee_id: user_work_item.issue_assignee_user_ids, label_ids: [label.id.to_s],
due_date: user_work_item.due_date, assignee_id: project_work_item.issue_assignee_user_ids,
traversal_ids: "#{user_work_item.namespace.id}-", due_date: project_work_item.due_date,
hashed_root_namespace_id: user_work_item.namespace.hashed_root_namespace_id, traversal_ids: project_work_item.namespace.elastic_namespace_ancestry,
namespace_visibility_level: user_work_item.namespace.visibility_level, hashed_root_namespace_id: project_work_item.namespace.hashed_root_namespace_id,
schema_version: described_class::SCHEMA_VERSION, namespace_visibility_level: project_work_item.namespace.visibility_level,
type: 'work_item' schema_version: described_class::SCHEMA_VERSION,
) archived: project.archived?,
end project_visibility_level: project.visibility_level,
work_item_access_level: project.issues_access_level,
type: 'work_item'
)
end
it 'serializes the user_namespace work_item as a hash' do
result = described_class.new(user_work_item.id, user_work_item.es_parent)
.as_indexed_json.with_indifferent_access
expect(result).to match(
project_id: user_work_item.reload.project_id,
id: user_work_item.id,
iid: user_work_item.iid,
created_at: user_work_item.created_at,
updated_at: user_work_item.updated_at,
title: user_work_item.title,
description: user_work_item.description,
state: user_work_item.state,
upvotes: user_work_item.upvotes_count,
hidden: user_work_item.hidden?,
work_item_type_id: user_work_item.work_item_type_id,
confidential: user_work_item.confidential,
author_id: user_work_item.author_id,
label_ids: [label.id.to_s],
assignee_id: user_work_item.issue_assignee_user_ids,
due_date: user_work_item.due_date,
traversal_ids: "#{user_work_item.namespace.id}-",
hashed_root_namespace_id: user_work_item.namespace.hashed_root_namespace_id,
namespace_visibility_level: user_work_item.namespace.visibility_level,
schema_version: described_class::SCHEMA_VERSION,
type: 'work_item'
)
end
it 'serializes the object as a hash' do it 'serializes the object as a hash' do
expect(result).to match( expect(result).to match(
project_id: work_item.reload.project_id, project_id: work_item.reload.project_id,
id: work_item.id, id: work_item.id,
iid: work_item.iid, iid: work_item.iid,
namespace_id: group.id, namespace_id: group.id,
created_at: work_item.created_at, created_at: work_item.created_at,
updated_at: work_item.updated_at, updated_at: work_item.updated_at,
title: work_item.title, title: work_item.title,
description: work_item.description, description: work_item.description,
state: work_item.state, state: work_item.state,
upvotes: work_item.upvotes_count, upvotes: work_item.upvotes_count,
hidden: work_item.hidden?, hidden: work_item.hidden?,
work_item_type_id: work_item.work_item_type_id, work_item_type_id: work_item.work_item_type_id,
confidential: work_item.confidential, confidential: work_item.confidential,
author_id: work_item.author_id, author_id: work_item.author_id,
label_ids: [label.id.to_s], label_ids: [label.id.to_s],
assignee_id: work_item.issue_assignee_user_ids, assignee_id: work_item.issue_assignee_user_ids,
due_date: work_item.due_date, due_date: work_item.due_date,
traversal_ids: "#{parent_group.id}-#{group.id}-", traversal_ids: "#{parent_group.id}-#{group.id}-",
hashed_root_namespace_id: ::Search.hash_namespace_id(parent_group.id), hashed_root_namespace_id: ::Search.hash_namespace_id(parent_group.id),
namespace_visibility_level: group.visibility_level, namespace_visibility_level: group.visibility_level,
schema_version: described_class::SCHEMA_VERSION, schema_version: described_class::SCHEMA_VERSION,
type: 'work_item' type: 'work_item'
) )
end
end end
context 'when add_root_namespace_id_to_work_item migration is complete' do context 'when add_root_namespace_id_to_work_item migration is complete' do
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册