Skip to content
Snippets Groups Projects
Commit 741c4643 authored by David Kim's avatar David Kim :dart:
Browse files

Update review request todo output

parent 6f246ada
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -16,7 +16,7 @@ module TodosHelper
def todo_action_name(todo)
case todo.action
when Todo::ASSIGNED then todo.self_added? ? 'assigned' : 'assigned you'
when Todo::REVIEW_REQUESTED then todo.self_added? ? 'assigned' : 'requested review of'
when Todo::REVIEW_REQUESTED then 'requested a review of'
when Todo::MENTIONED then "mentioned #{todo_action_subject(todo)} on"
when Todo::BUILD_FAILED then 'The build failed for'
when Todo::MARKED then 'added a todo for'
Loading
Loading
@@ -27,6 +27,13 @@ module TodosHelper
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)
text = raw(todo_target_type_name(todo) + ' ') +
if todo.for_commit?
Loading
Loading
Loading
Loading
@@ -227,7 +227,7 @@ class Todo < ApplicationRecord
end
 
def self_assigned?
assigned? && self_added?
self_added? && (assigned? || review_requested?)
end
 
private
Loading
Loading
Loading
Loading
@@ -31,7 +31,7 @@
 
- if todo.self_assigned?
%span.title-item.action-name
to yourself
= todo_self_addressing(todo)
 
%span.title-item
&middot;
Loading
Loading
Loading
Loading
@@ -197,6 +197,21 @@ RSpec.describe 'Dashboard Todos' do
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
 
context 'User has done todos', :js do
Loading
Loading
Loading
Loading
@@ -200,26 +200,42 @@ RSpec.describe Todo do
describe '#self_assigned?' do
let(:user_1) { build(:user) }
 
before do
subject.user = user_1
subject.author = user_1
subject.action = Todo::ASSIGNED
end
context 'when self_added' do
before do
subject.user = user_1
subject.author = user_1
end
 
it 'is true when todo is ASSIGNED and self_added' do
expect(subject).to be_self_assigned
end
it 'returns true for ASSIGNED' do
subject.action = Todo::ASSIGNED
expect(subject).to be_self_assigned
end
 
it 'is false when the todo is not ASSIGNED' do
subject.action = Todo::MENTIONED
it 'returns true for REVIEW_REQUESTED' do
subject.action = Todo::REVIEW_REQUESTED
 
expect(subject).not_to be_self_assigned
expect(subject).to be_self_assigned
end
it 'returns false for other action' do
subject.action = Todo::MENTIONED
expect(subject).not_to be_self_assigned
end
end
 
it 'is false when todo is not self_added' do
subject.author = build(:user)
context 'when todo is not self_added' do
before do
subject.user = user_1
subject.author = build(:user)
end
 
expect(subject).not_to be_self_assigned
it 'returns false' do
subject.action = Todo::ASSIGNED
expect(subject).not_to be_self_assigned
end
end
end
 
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment