diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-06-18 11:18:50 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-06-18 11:18:50 +0000 |
commit | 8c7f4e9d5f36cff46365a7f8c4b9c21578c1e781 (patch) | |
tree | a77e7fe7a93de11213032ed4ab1f33a3db51b738 /spec/helpers/todos_helper_spec.rb | |
parent | 00b35af3db1abfe813a778f643dad221aad51fca (diff) | |
download | gitlab-ce-8c7f4e9d5f36cff46365a7f8c4b9c21578c1e781.tar.gz |
Add latest changes from gitlab-org/gitlab@13-1-stable-ee
Diffstat (limited to 'spec/helpers/todos_helper_spec.rb')
-rw-r--r-- | spec/helpers/todos_helper_spec.rb | 63 |
1 files changed, 62 insertions, 1 deletions
diff --git a/spec/helpers/todos_helper_spec.rb b/spec/helpers/todos_helper_spec.rb index b09e1e2b83b..0811c2af891 100644 --- a/spec/helpers/todos_helper_spec.rb +++ b/spec/helpers/todos_helper_spec.rb @@ -5,7 +5,7 @@ require 'spec_helper' describe TodosHelper do let_it_be(:user) { 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(:note) do create(:note, @@ -20,6 +20,10 @@ describe TodosHelper do author: author, note: note) end + let_it_be(:alert_todo) do + alert = create(:alert_management_alert, iid: 1001) + create(:todo, target: alert) + end describe '#todos_count_format' do it 'shows fuzzy count for 100 or more items' do @@ -68,6 +72,41 @@ describe TodosHelper do 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 + build_stubbed(: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 context 'when given a design' do let(:todo) { design_todo } @@ -80,6 +119,18 @@ describe TodosHelper do expect(path).to eq("#{issue_path}/designs/#{design.filename}##{dom_id(design_todo.note)}") end end + + context 'when given an alert' do + let(:todo) { alert_todo } + + it 'responds with an appropriate path' do + path = helper.todo_target_path(todo) + + expect(path).to eq( + "/#{todo.project.full_path}/-/alert_management/#{todo.target.iid}/details" + ) + end + end end describe '#todo_target_type_name' do @@ -92,6 +143,16 @@ describe TodosHelper do expect(name).to eq('design') end end + + context 'when given an alert todo' do + let(:todo) { alert_todo } + + it 'responds with an appropriate target type name' do + name = helper.todo_target_type_name(todo) + + expect(name).to eq('alert') + end + end end describe '#todo_types_options' do |