Commit 0d9347f9 authored by Arun Kumar Mohan's avatar Arun Kumar Mohan

Fix filename duplication in design notes in activity feeds

parent 6cfe09c4
...@@ -3,6 +3,13 @@ ...@@ -3,6 +3,13 @@
module NotesHelper module NotesHelper
MAX_PRERENDERED_NOTES = 10 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) def note_target_fields(note)
if note.noteable if note.noteable
hidden_field_tag(:target_type, note.noteable.class.name.underscore) + hidden_field_tag(:target_type, note.noteable.class.name.underscore) +
......
...@@ -7,8 +7,10 @@ ...@@ -7,8 +7,10 @@
%span.event-type.d-inline-block.append-right-4{ class: event.action_name } %span.event-type.d-inline-block.append-right-4{ class: event.action_name }
= event.action_name = event.action_name
= event_note_title_html(event) = event_note_title_html(event)
%span.event-target-title.append-right-4{ dir: "auto" } - title = note_target_title(event.target)
= """.html_safe + event.target.title + "&quot".html_safe - if title.present?
%span.event-target-title.append-right-4{ dir: "auto" }
= """.html_safe + title + "&quot".html_safe
= render "events/event_scope", event: event = 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 ...@@ -24,6 +24,36 @@ describe NotesHelper do
project.add_guest(guest) project.add_guest(guest)
end 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 describe "#notes_max_access_for_users" do
it 'returns access levels' do it 'returns access levels' do
expect(helper.note_max_access_for_user(owner_note)).to eq(Gitlab::Access::OWNER) 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