Commit b6a2ffad authored by Heinrich Lee Yu's avatar Heinrich Lee Yu

Generates discussion_id when importing from GitHub

The GitHub importer skips callbacks so the discussion_id isn't
generated. This is fine because we also generate it at runtime when the
note is rendered.

But it is still better to generate it and persist it so that a note does
not have a different discussion id every time it is rendered.

The discussion_id is also going to be used for paginating discussions.
parent e3461eac
......@@ -29,6 +29,7 @@ module Gitlab
project_id: project.id,
author_id: author_id,
note: note_body,
discussion_id: note.discussion_id,
system: false,
created_at: note.created_at,
updated_at: note.updated_at
......
......@@ -63,6 +63,14 @@ module Gitlab
@attributes = attributes
end
def discussion_id
Discussion.discussion_id(
Struct
.new(:noteable_id, :noteable_type)
.new(noteable_id, noteable_type)
)
end
alias_method :issuable_type, :noteable_type
def github_identifiers
......
......@@ -52,6 +52,7 @@ RSpec.describe Gitlab::GithubImport::Importer::NoteImporter do
project_id: project.id,
author_id: user.id,
note: 'This is my note',
discussion_id: match(/\A[0-9a-f]{40}\z/),
system: false,
created_at: created_at,
updated_at: updated_at
......@@ -82,6 +83,7 @@ RSpec.describe Gitlab::GithubImport::Importer::NoteImporter do
project_id: project.id,
author_id: project.creator_id,
note: "*Created by: alice*\n\nThis is my note",
discussion_id: match(/\A[0-9a-f]{40}\z/),
system: false,
created_at: created_at,
updated_at: updated_at
......
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