Commit 8ddcb333 authored by Dmytro Zaporozhets (DZ)'s avatar Dmytro Zaporozhets (DZ)

Merge branch 'add-review-request-to-to-do-list-filter' into 'master'

Add Review Requested to Todo list filter

See merge request gitlab-org/gitlab!42344
parents ed1c5289 bb3521f0
...@@ -16,6 +16,7 @@ module TodosHelper ...@@ -16,6 +16,7 @@ module TodosHelper
def todo_action_name(todo) def todo_action_name(todo)
case todo.action case todo.action
when Todo::ASSIGNED then todo.self_added? ? 'assigned' : 'assigned you' when Todo::ASSIGNED then todo.self_added? ? 'assigned' : 'assigned you'
when Todo::REVIEW_REQUESTED then 'requested a review of'
when Todo::MENTIONED then "mentioned #{todo_action_subject(todo)} on" when Todo::MENTIONED then "mentioned #{todo_action_subject(todo)} on"
when Todo::BUILD_FAILED then 'The build failed for' when Todo::BUILD_FAILED then 'The build failed for'
when Todo::MARKED then 'added a todo for' when Todo::MARKED then 'added a todo for'
...@@ -26,6 +27,13 @@ module TodosHelper ...@@ -26,6 +27,13 @@ module TodosHelper
end end
end end
def todo_self_addressing(todo)
case todo.action
when Todo::ASSIGNED then 'to yourself'
when Todo::REVIEW_REQUESTED then 'from yourself'
end
end
def todo_target_link(todo) def todo_target_link(todo)
text = raw(todo_target_type_name(todo) + ' ') + text = raw(todo_target_type_name(todo) + ' ') +
if todo.for_commit? if todo.for_commit?
...@@ -141,6 +149,7 @@ module TodosHelper ...@@ -141,6 +149,7 @@ module TodosHelper
[ [
{ id: '', text: 'Any Action' }, { id: '', text: 'Any Action' },
{ id: Todo::ASSIGNED, text: 'Assigned' }, { id: Todo::ASSIGNED, text: 'Assigned' },
{ id: Todo::REVIEW_REQUESTED, text: 'Review requested' },
{ id: Todo::MENTIONED, text: 'Mentioned' }, { id: Todo::MENTIONED, text: 'Mentioned' },
{ id: Todo::MARKED, text: 'Added' }, { id: Todo::MARKED, text: 'Added' },
{ id: Todo::BUILD_FAILED, text: 'Pipelines' }, { id: Todo::BUILD_FAILED, text: 'Pipelines' },
......
...@@ -227,7 +227,7 @@ class Todo < ApplicationRecord ...@@ -227,7 +227,7 @@ class Todo < ApplicationRecord
end end
def self_assigned? def self_assigned?
assigned? && self_added? self_added? && (assigned? || review_requested?)
end end
private private
......
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
- if todo.self_assigned? - if todo.self_assigned?
%span.title-item.action-name %span.title-item.action-name
to yourself = todo_self_addressing(todo)
%span.title-item %span.title-item
&middot; &middot;
......
...@@ -12,6 +12,10 @@ FactoryBot.define do ...@@ -12,6 +12,10 @@ FactoryBot.define do
action { Todo::ASSIGNED } action { Todo::ASSIGNED }
end end
trait :review_requested do
action { Todo::REVIEW_REQUESTED }
end
trait :mentioned do trait :mentioned do
action { Todo::MENTIONED } action { Todo::MENTIONED }
end end
......
...@@ -130,6 +130,7 @@ RSpec.describe 'Dashboard > User filters todos', :js do ...@@ -130,6 +130,7 @@ RSpec.describe 'Dashboard > User filters todos', :js do
before do before do
create(:todo, :build_failed, user: user_1, author: user_2, project: project_1) create(:todo, :build_failed, user: user_1, author: user_2, project: project_1)
create(:todo, :marked, user: user_1, author: user_2, project: project_1, target: issue1) create(:todo, :marked, user: user_1, author: user_2, project: project_1, target: issue1)
create(:todo, :review_requested, user: user_1, author: user_2, project: project_1, target: issue1)
end end
it 'filters by Assigned' do it 'filters by Assigned' do
...@@ -138,6 +139,12 @@ RSpec.describe 'Dashboard > User filters todos', :js do ...@@ -138,6 +139,12 @@ RSpec.describe 'Dashboard > User filters todos', :js do
expect_to_see_action(:assigned) expect_to_see_action(:assigned)
end end
it 'filters by Review Requested' do
filter_action('Review requested')
expect_to_see_action(:review_requested)
end
it 'filters by Mentioned' do it 'filters by Mentioned' do
filter_action('Mentioned') filter_action('Mentioned')
...@@ -168,6 +175,7 @@ RSpec.describe 'Dashboard > User filters todos', :js do ...@@ -168,6 +175,7 @@ RSpec.describe 'Dashboard > User filters todos', :js do
def expect_to_see_action(action_name) def expect_to_see_action(action_name)
action_names = { action_names = {
assigned: ' assigned you ', assigned: ' assigned you ',
review_requested: ' requested a review of ',
mentioned: ' mentioned ', mentioned: ' mentioned ',
marked: ' added a todo for ', marked: ' added a todo for ',
build_failed: ' build failed for ' build_failed: ' build failed for '
......
...@@ -197,6 +197,21 @@ RSpec.describe 'Dashboard Todos' do ...@@ -197,6 +197,21 @@ RSpec.describe 'Dashboard Todos' do
end end
end end
end end
context 'review request todo' do
let(:merge_request) { create(:merge_request, title: "Fixes issue") }
before do
create(:todo, :review_requested, user: user, project: project, target: merge_request, author: user)
visit dashboard_todos_path
end
it 'shows you set yourself as an reviewer message' do
page.within('.js-todos-all') do
expect(page).to have_content("You requested a review of merge request #{merge_request.to_reference} \"Fixes issue\" at #{project.namespace.owner_name} / #{project.name} from yourself")
end
end
end
end end
context 'User has done todos', :js do context 'User has done todos', :js do
......
...@@ -200,28 +200,44 @@ RSpec.describe Todo do ...@@ -200,28 +200,44 @@ RSpec.describe Todo do
describe '#self_assigned?' do describe '#self_assigned?' do
let(:user_1) { build(:user) } let(:user_1) { build(:user) }
context 'when self_added' do
before do before do
subject.user = user_1 subject.user = user_1
subject.author = user_1 subject.author = user_1
end
it 'returns true for ASSIGNED' do
subject.action = Todo::ASSIGNED subject.action = Todo::ASSIGNED
expect(subject).to be_self_assigned
end end
it 'is true when todo is ASSIGNED and self_added' do it 'returns true for REVIEW_REQUESTED' do
subject.action = Todo::REVIEW_REQUESTED
expect(subject).to be_self_assigned expect(subject).to be_self_assigned
end end
it 'is false when the todo is not ASSIGNED' do it 'returns false for other action' do
subject.action = Todo::MENTIONED subject.action = Todo::MENTIONED
expect(subject).not_to be_self_assigned expect(subject).not_to be_self_assigned
end end
end
it 'is false when todo is not self_added' do context 'when todo is not self_added' do
before do
subject.user = user_1
subject.author = build(:user) subject.author = build(:user)
end
it 'returns false' do
subject.action = Todo::ASSIGNED
expect(subject).not_to be_self_assigned expect(subject).not_to be_self_assigned
end end
end end
end
describe '.for_action' do describe '.for_action' do
it 'returns the todos for a given action' do it 'returns the todos for a given action' do
......
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