Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-05-20 17:34:42 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-05-20 17:34:42 +0300
commit9f46488805e86b1bc341ea1620b866016c2ce5ed (patch)
treef9748c7e287041e37d6da49e0a29c9511dc34768 /spec/helpers/todos_helper_spec.rb
parentdfc92d081ea0332d69c8aca2f0e745cb48ae5e6d (diff)
Add latest changes from gitlab-org/gitlab@13-0-stable-ee
Diffstat (limited to 'spec/helpers/todos_helper_spec.rb')
-rw-r--r--spec/helpers/todos_helper_spec.rb71
1 files changed, 69 insertions, 2 deletions
diff --git a/spec/helpers/todos_helper_spec.rb b/spec/helpers/todos_helper_spec.rb
index 7c73b990338..b09e1e2b83b 100644
--- a/spec/helpers/todos_helper_spec.rb
+++ b/spec/helpers/todos_helper_spec.rb
@@ -1,8 +1,26 @@
# frozen_string_literal: true
-require "spec_helper"
+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(:design) { create(:design, issue: issue) }
+ let_it_be(:note) do
+ create(:note,
+ project: issue.project,
+ note: 'I am note, hear me roar')
+ end
+ let_it_be(:design_todo) do
+ create(:todo, :mentioned,
+ user: user,
+ project: issue.project,
+ target: design,
+ author: author,
+ note: note)
+ end
+
describe '#todos_count_format' do
it 'shows fuzzy count for 100 or more items' do
expect(helper.todos_count_format(100)).to eq '99+'
@@ -32,7 +50,56 @@ describe TodosHelper do
{ 'id' => projects.first.id, 'text' => projects.first.full_name }
]
- expect(JSON.parse(helper.todo_projects_options)).to match_array(expected_results)
+ expect(Gitlab::Json.parse(helper.todo_projects_options)).to match_array(expected_results)
+ end
+ end
+
+ describe '#todo_target_link' do
+ context 'when given a design' do
+ let(:todo) { design_todo }
+
+ it 'produces a good link' do
+ path = helper.todo_target_path(todo)
+ link = helper.todo_target_link(todo)
+ expected = "<a href=\"#{path}\">design #{design.to_reference}</a>"
+
+ expect(link).to eq(expected)
+ end
+ end
+ end
+
+ describe '#todo_target_path' do
+ context 'when given a design' do
+ let(:todo) { design_todo }
+
+ it 'responds with an appropriate path' do
+ path = helper.todo_target_path(todo)
+ issue_path = Gitlab::Routing.url_helpers
+ .project_issue_path(issue.project, issue)
+
+ expect(path).to eq("#{issue_path}/designs/#{design.filename}##{dom_id(design_todo.note)}")
+ end
+ end
+ end
+
+ describe '#todo_target_type_name' do
+ context 'when given a design todo' do
+ let(:todo) { design_todo }
+
+ it 'responds with an appropriate target type name' do
+ name = helper.todo_target_type_name(todo)
+
+ expect(name).to eq('design')
+ end
+ end
+ end
+
+ describe '#todo_types_options' do
+ it 'includes a match for a design todo' do
+ options = helper.todo_types_options
+ design_option = options.find { |o| o[:id] == design_todo.target_type }
+
+ expect(design_option).to include(text: 'Design')
end
end
end