Commit efa1eed7 authored by charlie ablett's avatar charlie ablett

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

Fix duplicate filename displayed in design todos

Closes #217162

See merge request gitlab-org/gitlab!32274
parents eb5d3076 74d81d16
...@@ -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`),
"\"#{todo.target.title}\"" # so to avoid displaying duplicate filenames in the To Do list for designs,
else # we return an empty string here.
"" return "" if todo.target.blank? || todo.for_design?
end
"\"#{todo.target.title}\""
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