Commit 0085b76f authored by Stan Hu's avatar Stan Hu

Give some context on threaded discussions

parent 710d8210
...@@ -293,9 +293,17 @@ module Gitlab ...@@ -293,9 +293,17 @@ module Gitlab
end end
def pull_request_comment_attributes(comment) def pull_request_comment_attributes(comment)
note =
# Provide some context for replying
if comment.parent_comment
"> #{comment.parent_comment.note.truncate(80)}\n\n#{comment.note}"
else
comment.note
end
{ {
project: project, project: project,
note: comment.note, note: note,
author_id: gitlab_user_id(comment.author_email), author_id: gitlab_user_id(comment.author_email),
created_at: comment.created_at, created_at: comment.created_at,
updated_at: comment.updated_at updated_at: comment.updated_at
......
...@@ -75,7 +75,9 @@ describe Gitlab::BitbucketServerImport::Importer do ...@@ -75,7 +75,9 @@ describe Gitlab::BitbucketServerImport::Importer do
author_email: 'unknown@gmail.com', author_email: 'unknown@gmail.com',
comments: [], comments: [],
created_at: now, created_at: now,
updated_at: now) updated_at: now,
parent_comment: nil)
@pr_comment = instance_double( @pr_comment = instance_double(
BitbucketServer::Representation::Activity, BitbucketServer::Representation::Activity,
comment?: true, comment?: true,
...@@ -115,8 +117,7 @@ describe Gitlab::BitbucketServerImport::Importer do ...@@ -115,8 +117,7 @@ describe Gitlab::BitbucketServerImport::Importer do
author_email: 'someuser@gitlab.com', author_email: 'someuser@gitlab.com',
note: 'I agree', note: 'I agree',
created_at: now, created_at: now,
updated_at: now updated_at: now)
)
# https://gitlab.com/gitlab-org/gitlab-test/compare/c1acaa58bbcbc3eafe538cb8274ba387047b69f8...5937ac0a7beb003549fc5fd26fc247ad # https://gitlab.com/gitlab-org/gitlab-test/compare/c1acaa58bbcbc3eafe538cb8274ba387047b69f8...5937ac0a7beb003549fc5fd26fc247ad
inline_note = instance_double( inline_note = instance_double(
...@@ -131,7 +132,10 @@ describe Gitlab::BitbucketServerImport::Importer do ...@@ -131,7 +132,10 @@ describe Gitlab::BitbucketServerImport::Importer do
author_email: 'unknown@gmail.com', author_email: 'unknown@gmail.com',
comments: [reply], comments: [reply],
created_at: now, created_at: now,
updated_at: now) updated_at: now,
parent_comment: nil)
allow(reply).to receive(:parent_comment).and_return(inline_note)
inline_comment = instance_double( inline_comment = instance_double(
BitbucketServer::Representation::Activity, BitbucketServer::Representation::Activity,
...@@ -161,7 +165,8 @@ describe Gitlab::BitbucketServerImport::Importer do ...@@ -161,7 +165,8 @@ describe Gitlab::BitbucketServerImport::Importer do
expect(start_note.position.new_line).to eq(inline_note.new_pos) expect(start_note.position.new_line).to eq(inline_note.new_pos)
reply_note = notes.last reply_note = notes.last
expect(reply_note.note).to eq(reply.note) # Make sure reply context is included
expect(reply_note.note).to eq("> #{inline_note.note}\n\n#{reply.note}")
expect(reply_note.author).to eq(project.owner) expect(reply_note.author).to eq(project.owner)
expect(reply_note.created_at).to eq(reply.created_at) expect(reply_note.created_at).to eq(reply.created_at)
expect(reply_note.updated_at).to eq(reply.created_at) expect(reply_note.updated_at).to eq(reply.created_at)
...@@ -186,7 +191,8 @@ describe Gitlab::BitbucketServerImport::Importer do ...@@ -186,7 +191,8 @@ describe Gitlab::BitbucketServerImport::Importer do
author_email: project.owner.email, author_email: project.owner.email,
comments: [], comments: [],
created_at: now, created_at: now,
updated_at: now) updated_at: now,
parent_comment: nil)
inline_comment = instance_double( inline_comment = instance_double(
BitbucketServer::Representation::Activity, BitbucketServer::Representation::Activity,
......
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