Commit bf2341e4 authored by Markus Koller's avatar Markus Koller

Merge branch 'fix/design-notes-filename-duplication' into 'master'

Fix filename duplication in design notes in activity feeds

Closes #218769

See merge request gitlab-org/gitlab!32823
parents aac239a3 0d9347f9
......@@ -3,6 +3,13 @@
module NotesHelper
MAX_PRERENDERED_NOTES = 10
def note_target_title(note)
# The design title is already present in `Event#note_target_reference`.
return if note.nil? || note.for_design?
note.title
end
def note_target_fields(note)
if note.noteable
hidden_field_tag(:target_type, note.noteable.class.name.underscore) +
......
......@@ -7,8 +7,10 @@
%span.event-type.d-inline-block.append-right-4{ class: event.action_name }
= event.action_name
= event_note_title_html(event)
%span.event-target-title.append-right-4{ dir: "auto" }
= """.html_safe + event.target.title + "&quot".html_safe
- title = note_target_title(event.target)
- if title.present?
%span.event-target-title.append-right-4{ dir: "auto" }
= """.html_safe + title + "&quot".html_safe
= render "events/event_scope", event: event
......
---
title: Fix filename duplication in design notes in activity feeds
merge_request: 32823
author: Arun Kumar Mohan
type: fixed
......@@ -24,6 +24,36 @@ describe NotesHelper do
project.add_guest(guest)
end
describe '#note_target_title' do
context 'note does not exist' do
it 'returns nil' do
expect(helper.note_target_title(nil)).to be_blank
end
end
context 'target does not exist' do
it 'returns nil' do
note = Note.new
expect(helper.note_target_title(note)).to be_blank
end
end
context 'when given a design target' do
it 'returns nil' do
note = build_stubbed(:note_on_design)
expect(helper.note_target_title(note)).to be_blank
end
end
context 'when given a non-design target' do
it 'returns the issue title' do
issue = build_stubbed(:issue, title: 'Issue 1')
note = build_stubbed(:note, noteable: issue)
expect(helper.note_target_title(note)).to eq('Issue 1')
end
end
end
describe "#notes_max_access_for_users" do
it 'returns access levels' do
expect(helper.note_max_access_for_user(owner_note)).to eq(Gitlab::Access::OWNER)
......
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