Commit 74d81d16 authored by Arun Kumar Mohan's avatar Arun Kumar Mohan

Fix duplicate filename displayed in design todos

parent ac669daf
...@@ -37,11 +37,12 @@ module TodosHelper ...@@ -37,11 +37,12 @@ module TodosHelper
end end
def todo_target_title(todo) def todo_target_title(todo)
if todo.target # Design To Dos' filenames are displayed in `#todo_target_link` (see `Design#to_reference`),
# so to avoid displaying duplicate filenames in the To Do list for designs,
# we return an empty string here.
return "" if todo.target.blank? || todo.for_design?
"\"#{todo.target.title}\"" "\"#{todo.target.title}\""
else
""
end
end end
def todo_parent_path(todo) def todo_parent_path(todo)
......
---
title: Fix duplicate filename displayed in design todos
merge_request: 32274
author: Arun Kumar Mohan
type: fixed
...@@ -5,7 +5,7 @@ require 'spec_helper' ...@@ -5,7 +5,7 @@ require 'spec_helper'
describe TodosHelper do describe TodosHelper do
let_it_be(:user) { create(:user) } let_it_be(:user) { create(:user) }
let_it_be(:author) { create(:user) } let_it_be(:author) { create(:user) }
let_it_be(:issue) { create(:issue) } let_it_be(:issue) { create(:issue, title: 'Issue 1') }
let_it_be(:design) { create(:design, issue: issue) } let_it_be(:design) { create(:design, issue: issue) }
let_it_be(:note) do let_it_be(:note) do
create(:note, create(:note,
...@@ -68,6 +68,41 @@ describe TodosHelper do ...@@ -68,6 +68,41 @@ describe TodosHelper do
end end
end end
describe '#todo_target_title' do
context 'when the target does not exist' do
let(:todo) { double('Todo', target: nil) }
it 'returns an empty string' do
title = helper.todo_target_title(todo)
expect(title).to eq("")
end
end
context 'when given a design todo' do
let(:todo) { design_todo }
it 'returns an empty string' do
title = helper.todo_target_title(todo)
expect(title).to eq("")
end
end
context 'when given a non-design todo' do
let(:todo) do
create(:todo, :assigned,
user: user,
project: issue.project,
target: issue,
author: author)
end
it 'returns the title' do
title = helper.todo_target_title(todo)
expect(title).to eq("\"Issue 1\"")
end
end
end
describe '#todo_target_path' do describe '#todo_target_path' do
context 'when given a design' do context 'when given a design' do
let(:todo) { design_todo } let(:todo) { design_todo }
......
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