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:
Diffstat (limited to 'spec/helpers/todos_helper_spec.rb')
-rw-r--r--spec/helpers/todos_helper_spec.rb118
1 files changed, 90 insertions, 28 deletions
diff --git a/spec/helpers/todos_helper_spec.rb b/spec/helpers/todos_helper_spec.rb
index 7c91dd0570f..ca334a04fe9 100644
--- a/spec/helpers/todos_helper_spec.rb
+++ b/spec/helpers/todos_helper_spec.rb
@@ -14,6 +14,8 @@ RSpec.describe TodosHelper do
note: 'I am note, hear me roar')
end
+ let_it_be(:group) { create(:group, :public, name: 'Group 1') }
+
let_it_be(:design_todo) do
create(:todo, :mentioned,
user: user,
@@ -37,6 +39,10 @@ RSpec.describe TodosHelper do
create(:todo, target: issue)
end
+ let_it_be(:group_todo) do
+ create(:todo, target: group)
+ 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+'
@@ -50,16 +56,14 @@ RSpec.describe TodosHelper do
end
end
- describe '#todo_target_link' do
+ describe '#todo_target_name' 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>"
+ it 'references the filename of the design' do
+ name = helper.todo_target_name(todo)
- expect(link).to eq(expected)
+ expect(name).to eq(design.to_reference.to_s)
end
end
end
@@ -94,7 +98,7 @@ RSpec.describe TodosHelper do
it 'returns the title' do
title = helper.todo_target_title(todo)
- expect(title).to eq("\"Issue 1\"")
+ expect(title).to eq("Issue 1")
end
end
end
@@ -155,33 +159,51 @@ RSpec.describe TodosHelper do
expect(path).to eq("/#{issue.project.full_path}/-/issues/#{issue.iid}##{dom_id(note)}")
end
end
+
+ context 'when a user requests access to group' do
+ let_it_be(:group_access_request_todo) do
+ create(:todo,
+ target_id: group.id,
+ target_type: group.class.polymorphic_name,
+ group: group,
+ action: Todo::MEMBER_ACCESS_REQUESTED)
+ end
+
+ it 'responds with access requests tab' do
+ path = helper.todo_target_path(group_access_request_todo)
+
+ access_request_path = Gitlab::Routing.url_helpers.group_group_members_url(group, tab: 'access_requests')
+
+ expect(path).to eq(access_request_path)
+ end
+ end
end
- describe '#todo_target_type_name' do
- subject { helper.todo_target_type_name(todo) }
+ describe '#todo_target_aria_label' do
+ subject { helper.todo_target_aria_label(todo) }
context 'when given a design todo' do
let(:todo) { design_todo }
- it { is_expected.to eq('design') }
+ it { is_expected.to eq("Design ##{todo.target.iid}[#{todo.target.title}]") }
end
context 'when given an alert todo' do
let(:todo) { alert_todo }
- it { is_expected.to eq('alert') }
+ it { is_expected.to eq("Alert ^alert##{todo.target.iid}") }
end
context 'when given a task todo' do
let(:todo) { task_todo }
- it { is_expected.to eq('task') }
+ it { is_expected.to eq("Task ##{todo.target.iid}") }
end
context 'when given an issue todo' do
let(:todo) { issue_todo }
- it { is_expected.to eq('issue') }
+ it { is_expected.to eq("Issue ##{todo.target.iid}") }
end
context 'when given a merge request todo' do
@@ -190,7 +212,7 @@ RSpec.describe TodosHelper do
create(:todo, target: merge_request)
end
- it { is_expected.to eq('merge request') }
+ it { is_expected.to eq("Merge Request !#{todo.target.iid}") }
end
end
@@ -229,7 +251,7 @@ RSpec.describe TodosHelper do
todo.target.update!(state: 'closed')
end
- it_behaves_like 'a rendered state pill', css: '.gl-bg-red-500', state: 'closed'
+ it_behaves_like 'a rendered state pill', css: '.badge-danger', state: 'closed'
end
context 'merged MR' do
@@ -237,7 +259,7 @@ RSpec.describe TodosHelper do
todo.target.update!(state: 'merged')
end
- it_behaves_like 'a rendered state pill', css: '.gl-bg-blue-500', state: 'merged'
+ it_behaves_like 'a rendered state pill', css: '.badge-info', state: 'merged'
end
end
@@ -251,7 +273,7 @@ RSpec.describe TodosHelper do
todo.target.update!(state: 'closed')
end
- it_behaves_like 'a rendered state pill', css: '.gl-bg-blue-500', state: 'closed'
+ it_behaves_like 'a rendered state pill', css: '.badge-info', state: 'closed'
end
end
@@ -265,7 +287,7 @@ RSpec.describe TodosHelper do
todo.target.resolve!
end
- it_behaves_like 'a rendered state pill', css: '.gl-bg-blue-500', state: 'resolved'
+ it_behaves_like 'a rendered state pill', css: '.badge-info', state: 'resolved'
end
end
end
@@ -329,17 +351,17 @@ RSpec.describe TodosHelper do
where(:action, :self_added?, :expected_action_name) do
Todo::ASSIGNED | false | s_('Todos|assigned you')
Todo::ASSIGNED | true | s_('Todos|assigned')
- Todo::REVIEW_REQUESTED | true | s_('Todos|requested a review of')
- Todo::MENTIONED | true | format(s_("Todos|mentioned %{who} on"), who: s_('Todos|yourself'))
- Todo::MENTIONED | false | format(s_("Todos|mentioned %{who} on"), who: _('you'))
- Todo::DIRECTLY_ADDRESSED | true | format(s_("Todos|mentioned %{who} on"), who: s_('Todos|yourself'))
- Todo::DIRECTLY_ADDRESSED | false | format(s_("Todos|mentioned %{who} on"), who: _('you'))
- Todo::BUILD_FAILED | true | s_('Todos|The pipeline failed in')
- Todo::MARKED | true | s_('Todos|added a todo for')
- Todo::APPROVAL_REQUIRED | true | format(s_("Todos|set %{who} as an approver for"), who: s_('Todos|yourself'))
- Todo::APPROVAL_REQUIRED | false | format(s_("Todos|set %{who} as an approver for"), who: _('you'))
+ Todo::REVIEW_REQUESTED | true | s_('Todos|requested a review')
+ Todo::MENTIONED | true | format(s_("Todos|mentioned %{who}"), who: s_('Todos|yourself'))
+ Todo::MENTIONED | false | format(s_("Todos|mentioned %{who}"), who: _('you'))
+ Todo::DIRECTLY_ADDRESSED | true | format(s_("Todos|mentioned %{who}"), who: s_('Todos|yourself'))
+ Todo::DIRECTLY_ADDRESSED | false | format(s_("Todos|mentioned %{who}"), who: _('you'))
+ Todo::BUILD_FAILED | true | s_('Todos|The pipeline failed')
+ Todo::MARKED | true | s_('Todos|added a to-do item')
+ Todo::APPROVAL_REQUIRED | true | format(s_("Todos|set %{who} as an approver"), who: s_('Todos|yourself'))
+ Todo::APPROVAL_REQUIRED | false | format(s_("Todos|set %{who} as an approver"), who: _('you'))
Todo::UNMERGEABLE | true | s_('Todos|Could not merge')
- Todo::MERGE_TRAIN_REMOVED | true | s_("Todos|Removed from Merge Train:")
+ Todo::MERGE_TRAIN_REMOVED | true | s_("Todos|Removed from Merge Train")
end
with_them do
@@ -350,5 +372,45 @@ RSpec.describe TodosHelper do
it { expect(helper.todo_action_name(alert_todo)).to eq(expected_action_name) }
end
+
+ context 'member access requested' do
+ context 'when source is group' do
+ it 'returns group access message' do
+ group_todo.action = Todo::MEMBER_ACCESS_REQUESTED
+
+ expect(helper.todo_action_name(group_todo)).to eq(
+ format(s_("Todos|has requested access to group %{which}"), which: _(group.name))
+ )
+ end
+ end
+ end
+ end
+
+ describe '#todo_due_date' do
+ subject(:result) { helper.todo_due_date(todo) }
+
+ context 'due date is today' do
+ let_it_be(:issue_with_today_due_date) do
+ create(:issue, title: 'Issue 1', project: project, due_date: Date.current)
+ end
+
+ let(:todo) do
+ create(:todo, project: issue_with_today_due_date.project, target: issue_with_today_due_date, note: note)
+ end
+
+ it { expect(result).to match('Due today') }
+ end
+
+ context 'due date is not today' do
+ let_it_be(:issue_with_tomorrow_due_date) do
+ create(:issue, title: 'Issue 1', project: project, due_date: Date.tomorrow)
+ end
+
+ let(:todo) do
+ create(:todo, project: issue_with_tomorrow_due_date.project, target: issue_with_tomorrow_due_date, note: note)
+ end
+
+ it { expect(result).to match("Due #{l(Date.tomorrow, format: Date::DATE_FORMATS[:medium])}") }
+ end
end
end