Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
3d52e139
G
gitlab-foss
项目概览
李少辉-开发者
/
gitlab-foss
通知
15
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
gitlab-foss
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
3d52e139
编写于
2月 20, 2016
作者:
D
Douglas Barbosa Alexandre
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Rename Tasks to Todos
上级
408e010d
变更
43
隐藏空白更改
内联
并排
Showing
43 changed file
with
604 addition
and
269 deletion
+604
-269
CHANGELOG
CHANGELOG
+2
-2
app/assets/stylesheets/pages/todos.scss
app/assets/stylesheets/pages/todos.scss
+13
-13
app/controllers/dashboard/tasks_controller.rb
app/controllers/dashboard/tasks_controller.rb
+0
-21
app/controllers/dashboard/todos_controller.rb
app/controllers/dashboard/todos_controller.rb
+23
-0
app/controllers/projects/merge_requests_controller.rb
app/controllers/projects/merge_requests_controller.rb
+1
-1
app/finders/todos_finder.rb
app/finders/todos_finder.rb
+5
-5
app/helpers/todos_helper.rb
app/helpers/todos_helper.rb
+59
-0
app/models/note.rb
app/models/note.rb
+1
-1
app/models/todo.rb
app/models/todo.rb
+2
-2
app/models/user.rb
app/models/user.rb
+1
-1
app/services/base_service.rb
app/services/base_service.rb
+2
-2
app/services/issues/close_service.rb
app/services/issues/close_service.rb
+2
-2
app/services/issues/create_service.rb
app/services/issues/create_service.rb
+1
-1
app/services/issues/update_service.rb
app/services/issues/update_service.rb
+3
-3
app/services/merge_requests/close_service.rb
app/services/merge_requests/close_service.rb
+1
-1
app/services/merge_requests/create_service.rb
app/services/merge_requests/create_service.rb
+1
-1
app/services/merge_requests/update_service.rb
app/services/merge_requests/update_service.rb
+3
-3
app/services/notes/create_service.rb
app/services/notes/create_service.rb
+1
-1
app/services/notes/update_service.rb
app/services/notes/update_service.rb
+1
-1
app/services/todo_service.rb
app/services/todo_service.rb
+43
-43
app/views/dashboard/tasks/_task.html.haml
app/views/dashboard/tasks/_task.html.haml
+0
-21
app/views/dashboard/todos/_todo.html.haml
app/views/dashboard/todos/_todo.html.haml
+21
-0
app/views/dashboard/todos/index.html.haml
app/views/dashboard/todos/index.html.haml
+14
-14
app/views/layouts/header/_default.html.haml
app/views/layouts/header/_default.html.haml
+3
-3
app/views/layouts/nav/_dashboard.html.haml
app/views/layouts/nav/_dashboard.html.haml
+4
-4
config/routes.rb
config/routes.rb
+1
-1
db/migrate/20160220123949_rename_tasks_to_todos.rb
db/migrate/20160220123949_rename_tasks_to_todos.rb
+5
-0
db/schema.rb
db/schema.rb
+8
-8
features/dashboard/todos.feature
features/dashboard/todos.feature
+11
-11
features/steps/dashboard/todos.rb
features/steps/dashboard/todos.rb
+32
-32
features/steps/shared/paths.rb
features/steps/shared/paths.rb
+2
-2
spec/factories/todos.rb
spec/factories/todos.rb
+5
-5
spec/models/note_spec.rb
spec/models/note_spec.rb
+1
-1
spec/models/todo_spec.rb.rb
spec/models/todo_spec.rb.rb
+4
-4
spec/models/user_spec.rb
spec/models/user_spec.rb
+1
-1
spec/services/issues/close_service_spec.rb
spec/services/issues/close_service_spec.rb
+4
-4
spec/services/issues/create_service_spec.rb
spec/services/issues/create_service_spec.rb
+5
-4
spec/services/issues/update_service_spec.rb
spec/services/issues/update_service_spec.rb
+17
-16
spec/services/merge_requests/close_service_spec.rb
spec/services/merge_requests/close_service_spec.rb
+3
-3
spec/services/merge_requests/create_service_spec.rb
spec/services/merge_requests/create_service_spec.rb
+9
-7
spec/services/merge_requests/update_service_spec.rb
spec/services/merge_requests/update_service_spec.rb
+19
-18
spec/services/notes/update_service_spec.rb
spec/services/notes/update_service_spec.rb
+6
-6
spec/services/todo_service_spec.rb
spec/services/todo_service_spec.rb
+264
-0
未找到文件。
CHANGELOG
浏览文件 @
3d52e139
...
...
@@ -65,7 +65,7 @@ v 8.5.0 (unreleased)
- Fix broken link to project in build notification emails
- Ability to see and sort on vote count from Issues and MR lists
- Fix builds scheduler when first build in stage was allowed to fail
- User project limit is reached notice is hidden if the projects limit is zero
- User project limit is reached notice is hidden if the projects limit is zero
- Add API support for managing runners and project's runners
- Allow SAML users to login with no previous account without having to allow
all Omniauth providers to do so.
...
...
@@ -75,7 +75,7 @@ v 8.5.0 (unreleased)
- Emoji comment on diffs are not award emoji
- Add label description (Nuttanart Pornprasitsakul)
- Show label row when filtering issues or merge requests by label (Nuttanart Pornprasitsakul)
- Add T
ask Queue
- Add T
odos
v 8.4.4
- Update omniauth-saml gem to 1.4.2
...
...
app/assets/stylesheets/pages/t
ask
s.scss
→
app/assets/stylesheets/pages/t
odo
s.scss
浏览文件 @
3d52e139
/**
* Dashboard
tasks queue
* Dashboard
Todos
*
*/
.navbar-nav
{
li
{
.badge.t
ask
s-pending-count
{
.badge.t
odo
s-pending-count
{
background-color
:
#7f8fa4
;
margin-top
:
-5px
;
}
}
}
.t
ask
s
{
.t
odo
s
{
.panel
{
border-top
:
none
;
margin-bottom
:
0
;
}
}
.t
ask
-item
{
.t
odo
-item
{
font-size
:
$gl-font-size
;
padding
:
$gl-padding-top
0
$gl-padding-top
(
$gl-avatar-size
+
$gl-padding-top
);
border-bottom
:
1px
solid
$table-border-color
;
color
:
#7f8fa4
;
&
.t
ask
-inline
{
&
.t
odo
-inline
{
.avatar
{
position
:
relative
;
top
:
-2px
;
}
.t
ask
-title
{
.t
odo
-title
{
line-height
:
40px
;
}
}
...
...
@@ -44,7 +44,7 @@
margin-left
:
-
(
$gl-avatar-size
+
$gl-padding-top
);
}
.t
ask
-title
{
.t
odo
-title
{
@include
str-truncated
(
calc
(
100%
-
174px
));
font-weight
:
600
;
...
...
@@ -53,10 +53,10 @@
}
}
.t
ask
-body
{
.t
odo
-body
{
margin-right
:
174px
;
.t
ask
-note
{
.t
odo
-note
{
word-wrap
:
break-word
;
.md
{
...
...
@@ -89,7 +89,7 @@
}
}
.t
ask
-note-icon
{
.t
odo
-note-icon
{
color
:
#777
;
float
:
left
;
font-size
:
$gl-font-size
;
...
...
@@ -102,10 +102,10 @@
}
@media
(
max-width
:
$screen-xs-max
)
{
.t
ask
-item
{
.t
odo
-item
{
padding-left
:
$gl-padding
;
.t
ask
-title
{
.t
odo
-title
{
white-space
:
normal
;
overflow
:
visible
;
max-width
:
100%
;
...
...
@@ -115,7 +115,7 @@
display
:
none
;
}
.t
ask
-body
{
.t
odo
-body
{
margin
:
0
;
border-left
:
2px
solid
#DDD
;
padding-left
:
10px
;
...
...
app/controllers/dashboard/tasks_controller.rb
已删除
100644 → 0
浏览文件 @
408e010d
class
Dashboard::TasksController
<
Dashboard
::
ApplicationController
def
index
@tasks
=
TasksFinder
.
new
(
current_user
,
params
).
execute
@tasks
=
@tasks
.
page
(
params
[
:page
]).
per
(
PER_PAGE
)
end
def
destroy
task
.
done!
respond_to
do
|
format
|
format
.
html
{
redirect_to
dashboard_tasks_path
,
notice:
'Task was successfully marked as done.'
}
format
.
js
{
render
nothing:
true
}
end
end
private
def
task
@task
||=
current_user
.
tasks
.
find
(
params
[
:id
])
end
end
app/controllers/dashboard/todos_controller.rb
0 → 100644
浏览文件 @
3d52e139
class
Dashboard::TodosController
<
Dashboard
::
ApplicationController
def
index
@todos
=
TodosFinder
.
new
(
current_user
,
params
).
execute
@todos
=
@todos
.
page
(
params
[
:page
]).
per
(
PER_PAGE
)
end
def
destroy
todo
.
done!
respond_to
do
|
format
|
format
.
html
{
redirect_to
dashboard_todos_path
,
notice:
'Todo was successfully marked as done.'
}
format
.
js
{
render
nothing:
true
}
end
end
private
def
todo
@todo
||=
current_user
.
todos
.
find
(
params
[
:id
])
end
end
app/controllers/projects/merge_requests_controller.rb
浏览文件 @
3d52e139
...
...
@@ -181,7 +181,7 @@ class Projects::MergeRequestsController < Projects::ApplicationController
return
end
T
ask
Service
.
new
.
merge_merge_request
(
merge_request
,
current_user
)
T
odo
Service
.
new
.
merge_merge_request
(
merge_request
,
current_user
)
@merge_request
.
update
(
merge_error:
nil
)
...
...
app/finders/t
ask
s_finder.rb
→
app/finders/t
odo
s_finder.rb
浏览文件 @
3d52e139
# T
ask
sFinder
# T
odo
sFinder
#
# Used to filter T
ask
s by set of params
# Used to filter T
odo
s by set of params
#
# Arguments:
# current_user - which user use
...
...
@@ -12,7 +12,7 @@
# type: 'Issue' or 'MergeRequest'
#
class
T
ask
sFinder
class
T
odo
sFinder
NONE
=
'0'
attr_accessor
:current_user
,
:params
...
...
@@ -23,7 +23,7 @@ class TasksFinder
end
def
execute
items
=
current_user
.
t
ask
s
items
=
current_user
.
t
odo
s
items
=
by_action_id
(
items
)
items
=
by_author
(
items
)
items
=
by_project
(
items
)
...
...
@@ -36,7 +36,7 @@ class TasksFinder
private
def
action_id?
action_id
.
present?
&&
[
T
ask
::
ASSIGNED
,
Task
::
MENTIONED
].
include?
(
action_id
.
to_i
)
action_id
.
present?
&&
[
T
odo
::
ASSIGNED
,
Todo
::
MENTIONED
].
include?
(
action_id
.
to_i
)
end
def
action_id
...
...
app/helpers/t
ask
s_helper.rb
→
app/helpers/t
odo
s_helper.rb
浏览文件 @
3d52e139
module
TasksHelper
def
link_to_author
(
task
)
author
=
task
.
author
if
author
link_to
author
.
name
,
user_path
(
author
.
username
)
else
task
.
author_name
end
end
def
tasks_pending_count
current_user
.
tasks
.
pending
.
count
module
TodosHelper
def
todos_pending_count
current_user
.
todos
.
pending
.
count
end
def
t
ask
s_done_count
current_user
.
t
ask
s
.
done
.
count
def
t
odo
s_done_count
current_user
.
t
odo
s
.
done
.
count
end
def
t
ask_action_name
(
task
)
target
=
t
ask
.
target_type
.
titleize
.
downcase
def
t
odo_action_name
(
todo
)
target
=
t
odo
.
target_type
.
titleize
.
downcase
[
t
ask
.
action_name
,
target
].
join
(
" "
)
[
t
odo
.
action_name
,
target
].
join
(
" "
)
end
def
t
ask_target_link_html
(
task
)
link_to
"#
#{
t
ask
.
target_iid
}
"
,
task_target_path
(
task
)
def
t
odo_target_link_html
(
todo
)
link_to
"#
#{
t
odo
.
target_iid
}
"
,
todo_target_path
(
todo
)
end
def
t
ask_target_path
(
task
)
anchor
=
dom_id
(
t
ask
.
note
)
if
task
.
note
.
present?
def
t
odo_target_path
(
todo
)
anchor
=
dom_id
(
t
odo
.
note
)
if
todo
.
note
.
present?
polymorphic_path
([
t
ask
.
project
.
namespace
.
becomes
(
Namespace
),
t
ask
.
project
,
task
.
target
],
anchor:
anchor
)
polymorphic_path
([
t
odo
.
project
.
namespace
.
becomes
(
Namespace
),
t
odo
.
project
,
todo
.
target
],
anchor:
anchor
)
end
def
t
ask
_actions_options
def
t
odo
_actions_options
actions
=
[
OpenStruct
.
new
(
id:
''
,
title:
'Any Action'
),
OpenStruct
.
new
(
id:
T
ask
::
ASSIGNED
,
title:
'Assigned'
),
OpenStruct
.
new
(
id:
T
ask
::
MENTIONED
,
title:
'Mentioned'
)
OpenStruct
.
new
(
id:
T
odo
::
ASSIGNED
,
title:
'Assigned'
),
OpenStruct
.
new
(
id:
T
odo
::
MENTIONED
,
title:
'Mentioned'
)
]
options_from_collection_for_select
(
actions
,
'id'
,
'title'
,
params
[
:action_id
])
end
def
t
ask
_projects_options
def
t
odo
_projects_options
projects
=
current_user
.
authorized_projects
.
sorted_by_activity
.
non_archived
projects
=
projects
.
includes
(
:namespace
)
...
...
@@ -57,7 +47,7 @@ module TasksHelper
options_from_collection_for_select
(
projects
,
'id'
,
'title'
,
params
[
:project_id
])
end
def
t
ask
_types_options
def
t
odo
_types_options
types
=
[
OpenStruct
.
new
(
title:
'Any Type'
,
name:
''
),
OpenStruct
.
new
(
title:
'Issue'
,
name:
'Issue'
),
...
...
app/models/note.rb
浏览文件 @
3d52e139
...
...
@@ -37,7 +37,7 @@ class Note < ActiveRecord::Base
belongs_to
:author
,
class_name:
"User"
belongs_to
:updated_by
,
class_name:
"User"
has_many
:t
ask
s
,
dependent: :destroy
has_many
:t
odo
s
,
dependent: :destroy
delegate
:name
,
to: :project
,
prefix:
true
delegate
:name
,
:email
,
to: :author
,
prefix:
true
...
...
app/models/t
ask
.rb
→
app/models/t
odo
.rb
浏览文件 @
3d52e139
# == Schema Information
#
# Table name: t
ask
s
# Table name: t
odo
s
#
# id :integer not null, primary key
# user_id :integer not null
...
...
@@ -15,7 +15,7 @@
# updated_at :datetime
#
class
T
ask
<
ActiveRecord
::
Base
class
T
odo
<
ActiveRecord
::
Base
ASSIGNED
=
1
MENTIONED
=
2
...
...
app/models/user.rb
浏览文件 @
3d52e139
...
...
@@ -140,7 +140,7 @@ class User < ActiveRecord::Base
has_one
:abuse_report
,
dependent: :destroy
has_many
:spam_logs
,
dependent: :destroy
has_many
:builds
,
dependent: :nullify
,
class_name:
'Ci::Build'
has_many
:t
ask
s
,
dependent: :destroy
has_many
:t
odo
s
,
dependent: :destroy
#
# Validations
...
...
app/services/base_service.rb
浏览文件 @
3d52e139
...
...
@@ -23,8 +23,8 @@ class BaseService
EventCreateService
.
new
end
def
t
ask
_service
T
ask
Service
.
new
def
t
odo
_service
T
odo
Service
.
new
end
def
log_info
(
message
)
...
...
app/services/issues/close_service.rb
浏览文件 @
3d52e139
...
...
@@ -3,7 +3,7 @@ module Issues
def
execute
(
issue
,
commit
=
nil
)
if
project
.
jira_tracker?
&&
project
.
jira_service
.
active
project
.
jira_service
.
execute
(
commit
,
issue
)
t
ask
_service
.
close_issue
(
issue
,
current_user
)
t
odo
_service
.
close_issue
(
issue
,
current_user
)
return
issue
end
...
...
@@ -11,7 +11,7 @@ module Issues
event_service
.
close_issue
(
issue
,
current_user
)
create_note
(
issue
,
commit
)
notification_service
.
close_issue
(
issue
,
current_user
)
t
ask
_service
.
close_issue
(
issue
,
current_user
)
t
odo
_service
.
close_issue
(
issue
,
current_user
)
execute_hooks
(
issue
,
'close'
)
end
...
...
app/services/issues/create_service.rb
浏览文件 @
3d52e139
...
...
@@ -9,7 +9,7 @@ module Issues
if
issue
.
save
issue
.
update_attributes
(
label_ids:
label_params
)
notification_service
.
new_issue
(
issue
,
current_user
)
t
ask
_service
.
new_issue
(
issue
,
current_user
)
t
odo
_service
.
new_issue
(
issue
,
current_user
)
event_service
.
open_issue
(
issue
,
current_user
)
issue
.
create_cross_references!
(
current_user
)
execute_hooks
(
issue
,
'open'
)
...
...
app/services/issues/update_service.rb
浏览文件 @
3d52e139
...
...
@@ -6,12 +6,12 @@ module Issues
def
handle_changes
(
issue
,
options
=
{})
if
has_changes?
(
issue
,
options
)
t
ask_service
.
mark_pending_task
s_as_done
(
issue
,
current_user
)
t
odo_service
.
mark_pending_todo
s_as_done
(
issue
,
current_user
)
end
if
issue
.
previous_changes
.
include?
(
'title'
)
||
issue
.
previous_changes
.
include?
(
'description'
)
t
ask
_service
.
update_issue
(
issue
,
current_user
)
t
odo
_service
.
update_issue
(
issue
,
current_user
)
end
if
issue
.
previous_changes
.
include?
(
'milestone_id'
)
...
...
@@ -21,7 +21,7 @@ module Issues
if
issue
.
previous_changes
.
include?
(
'assignee_id'
)
create_assignee_note
(
issue
)
notification_service
.
reassigned_issue
(
issue
,
current_user
)
t
ask
_service
.
reassigned_issue
(
issue
,
current_user
)
t
odo
_service
.
reassigned_issue
(
issue
,
current_user
)
end
end
...
...
app/services/merge_requests/close_service.rb
浏览文件 @
3d52e139
...
...
@@ -9,7 +9,7 @@ module MergeRequests
event_service
.
close_mr
(
merge_request
,
current_user
)
create_note
(
merge_request
)
notification_service
.
close_mr
(
merge_request
,
current_user
)
t
ask
_service
.
close_merge_request
(
merge_request
,
current_user
)
t
odo
_service
.
close_merge_request
(
merge_request
,
current_user
)
execute_hooks
(
merge_request
,
'close'
)
end
...
...
app/services/merge_requests/create_service.rb
浏览文件 @
3d52e139
...
...
@@ -18,7 +18,7 @@ module MergeRequests
merge_request
.
update_attributes
(
label_ids:
label_params
)
event_service
.
open_mr
(
merge_request
,
current_user
)
notification_service
.
new_merge_request
(
merge_request
,
current_user
)
t
ask
_service
.
new_merge_request
(
merge_request
,
current_user
)
t
odo
_service
.
new_merge_request
(
merge_request
,
current_user
)
merge_request
.
create_cross_references!
(
current_user
)
execute_hooks
(
merge_request
)
end
...
...
app/services/merge_requests/update_service.rb
浏览文件 @
3d52e139
...
...
@@ -16,12 +16,12 @@ module MergeRequests
def
handle_changes
(
merge_request
,
options
=
{})
if
has_changes?
(
merge_request
,
options
)
t
ask_service
.
mark_pending_task
s_as_done
(
merge_request
,
current_user
)
t
odo_service
.
mark_pending_todo
s_as_done
(
merge_request
,
current_user
)
end
if
merge_request
.
previous_changes
.
include?
(
'title'
)
||
merge_request
.
previous_changes
.
include?
(
'description'
)
t
ask
_service
.
update_merge_request
(
merge_request
,
current_user
)
t
odo
_service
.
update_merge_request
(
merge_request
,
current_user
)
end
if
merge_request
.
previous_changes
.
include?
(
'target_branch'
)
...
...
@@ -37,7 +37,7 @@ module MergeRequests
if
merge_request
.
previous_changes
.
include?
(
'assignee_id'
)
create_assignee_note
(
merge_request
)
notification_service
.
reassigned_merge_request
(
merge_request
,
current_user
)
t
ask
_service
.
reassigned_merge_request
(
merge_request
,
current_user
)
t
odo
_service
.
reassigned_merge_request
(
merge_request
,
current_user
)
end
if
merge_request
.
previous_changes
.
include?
(
'target_branch'
)
||
...
...
app/services/notes/create_service.rb
浏览文件 @
3d52e139
...
...
@@ -8,7 +8,7 @@ module Notes
if
note
.
save
# Finish the harder work in the background
NewNoteWorker
.
perform_in
(
2
.
seconds
,
note
.
id
,
params
)
T
ask
Service
.
new
.
new_note
(
note
,
current_user
)
T
odo
Service
.
new
.
new_note
(
note
,
current_user
)
end
note
...
...
app/services/notes/update_service.rb
浏览文件 @
3d52e139
...
...
@@ -8,7 +8,7 @@ module Notes
note
.
reset_events_cache
if
note
.
previous_changes
.
include?
(
'note'
)
T
ask
Service
.
new
.
update_note
(
note
,
current_user
)
T
odo
Service
.
new
.
update_note
(
note
,
current_user
)
end
note
...
...
app/services/t
ask
_service.rb
→
app/services/t
odo
_service.rb
浏览文件 @
3d52e139
# T
ask
Service class
# T
odo
Service class
#
# Used for creating t
asks on task queue after certain user action
# Used for creating t
odos after certain user actions
#
# Ex.
# T
ask
Service.new.new_issue(issue, current_user)
# T
odo
Service.new.new_issue(issue, current_user)
#
class
T
ask
Service
class
T
odo
Service
# When create an issue we should:
#
# * create a t
ask
for assignee if issue is assigned
# * create a t
ask
for each mentioned user on issue
# * create a t
odo
for assignee if issue is assigned
# * create a t
odo
for each mentioned user on issue
#
def
new_issue
(
issue
,
current_user
)
new_issuable
(
issue
,
current_user
)
...
...
@@ -17,32 +17,32 @@ class TaskService
# When update an issue we should:
#
# * mark all pending t
ask
s related to the issue for the current user as done
# * mark all pending t
odo
s related to the issue for the current user as done
#
def
update_issue
(
issue
,
current_user
)
create_mention_t
ask
s
(
issue
.
project
,
issue
,
current_user
)
create_mention_t
odo
s
(
issue
.
project
,
issue
,
current_user
)
end
# When close an issue we should:
#
# * mark all pending t
ask
s related to the target for the current user as done
# * mark all pending t
odo
s related to the target for the current user as done
#
def
close_issue
(
issue
,
current_user
)
mark_pending_t
ask
s_as_done
(
issue
,
current_user
)
mark_pending_t
odo
s_as_done
(
issue
,
current_user
)
end
# When we reassign an issue we should:
#
# * create a pending t
ask
for new assignee if issue is assigned
# * create a pending t
odo
for new assignee if issue is assigned
#
def
reassigned_issue
(
issue
,
current_user
)
create_assignment_t
ask
(
issue
,
current_user
)
create_assignment_t
odo
(
issue
,
current_user
)
end
# When create a merge request we should:
#
# * creates a pending t
ask
for assignee if merge request is assigned
# * create a t
ask
for each mentioned user on merge request
# * creates a pending t
odo
for assignee if merge request is assigned
# * create a t
odo
for each mentioned user on merge request
#
def
new_merge_request
(
merge_request
,
current_user
)
new_issuable
(
merge_request
,
current_user
)
...
...
@@ -50,40 +50,40 @@ class TaskService
# When update a merge request we should:
#
# * create a t
ask
for each mentioned user on merge request
# * create a t
odo
for each mentioned user on merge request
#
def
update_merge_request
(
merge_request
,
current_user
)
create_mention_t
ask
s
(
merge_request
.
project
,
merge_request
,
current_user
)
create_mention_t
odo
s
(
merge_request
.
project
,
merge_request
,
current_user
)
end
# When close a merge request we should:
#
# * mark all pending t
ask
s related to the target for the current user as done
# * mark all pending t
odo
s related to the target for the current user as done
#
def
close_merge_request
(
merge_request
,
current_user
)
mark_pending_t
ask
s_as_done
(
merge_request
,
current_user
)
mark_pending_t
odo
s_as_done
(
merge_request
,
current_user
)
end
# When we reassign a merge request we should:
#
# * creates a pending t
ask
for new assignee if merge request is assigned
# * creates a pending t
odo
for new assignee if merge request is assigned
#
def
reassigned_merge_request
(
merge_request
,
current_user
)
create_assignment_t
ask
(
merge_request
,
current_user
)
create_assignment_t
odo
(
merge_request
,
current_user
)
end
# When merge a merge request we should:
#
# * mark all pending t
ask
s related to the target for the current user as done
# * mark all pending t
odo
s related to the target for the current user as done
#
def
merge_merge_request
(
merge_request
,
current_user
)
mark_pending_t
ask
s_as_done
(
merge_request
,
current_user
)
mark_pending_t
odo
s_as_done
(
merge_request
,
current_user
)
end
# When create a note we should:
#
# * mark all pending t
ask
s related to the noteable for the note author as done
# * create a t
ask
for each mentioned user on note
# * mark all pending t
odo
s related to the noteable for the note author as done
# * create a t
odo
for each mentioned user on note
#
def
new_note
(
note
,
current_user
)
handle_note
(
note
,
current_user
)
...
...
@@ -91,28 +91,28 @@ class TaskService
# When update a note we should:
#
# * mark all pending t
ask
s related to the noteable for the current user as done
# * create a t
ask
for each new user mentioned on note
# * mark all pending t
odo
s related to the noteable for the current user as done
# * create a t
odo
for each new user mentioned on note
#
def
update_note
(
note
,
current_user
)
handle_note
(
note
,
current_user
)
end
# When marking pending t
ask
s as done we should:
# When marking pending t
odo
s as done we should:
#
# * mark all pending t
ask
s related to the target for the current user as done
# * mark all pending t
odo
s related to the target for the current user as done
#
def
mark_pending_t
ask
s_as_done
(
target
,
user
)
pending_t
ask
s
(
user
,
target
.
project
,
target
).
update_all
(
state: :done
)
def
mark_pending_t
odo
s_as_done
(
target
,
user
)
pending_t
odo
s
(
user
,
target
.
project
,
target
).
update_all
(
state: :done
)
end
private
def
create_t
ask
s
(
project
,
target
,
author
,
users
,
action
,
note
=
nil
)
def
create_t
odo
s
(
project
,
target
,
author
,
users
,
action
,
note
=
nil
)
Array
(
users
).
each
do
|
user
|
next
if
pending_t
ask
s
(
user
,
project
,
target
).
exists?
next
if
pending_t
odo
s
(
user
,
project
,
target
).
exists?
T
ask
.
create
(
T
odo
.
create
(
project:
project
,
user_id:
user
.
id
,
author_id:
author
.
id
,
...
...
@@ -125,8 +125,8 @@ class TaskService
end
def
new_issuable
(
issuable
,
author
)
create_assignment_t
ask
(
issuable
,
author
)
create_mention_t
ask
s
(
issuable
.
project
,
issuable
,
author
)
create_assignment_t
odo
(
issuable
,
author
)
create_mention_t
odo
s
(
issuable
.
project
,
issuable
,
author
)
end
def
handle_note
(
note
,
author
)
...
...
@@ -136,19 +136,19 @@ class TaskService
project
=
note
.
project
target
=
note
.
noteable
mark_pending_t
ask
s_as_done
(
target
,
author
)
create_mention_t
ask
s
(
project
,
target
,
author
,
note
)
mark_pending_t
odo
s_as_done
(
target
,
author
)
create_mention_t
odo
s
(
project
,
target
,
author
,
note
)
end
def
create_assignment_t
ask
(
issuable
,
author
)
def
create_assignment_t
odo
(
issuable
,
author
)
if
issuable
.
assignee
&&
issuable
.
assignee
!=
author
create_t
asks
(
issuable
.
project
,
issuable
,
author
,
issuable
.
assignee
,
Task
::
ASSIGNED
)
create_t
odos
(
issuable
.
project
,
issuable
,
author
,
issuable
.
assignee
,
Todo
::
ASSIGNED
)
end
end
def
create_mention_t
ask
s
(
project
,
issuable
,
author
,
note
=
nil
)
def
create_mention_t
odo
s
(
project
,
issuable
,
author
,
note
=
nil
)
mentioned_users
=
filter_mentioned_users
(
project
,
note
||
issuable
,
author
)
create_t
asks
(
project
,
issuable
,
author
,
mentioned_users
,
Task
::
MENTIONED
,
note
)
create_t
odos
(
project
,
issuable
,
author
,
mentioned_users
,
Todo
::
MENTIONED
,
note
)
end
def
filter_mentioned_users
(
project
,
target
,
author
)
...
...
@@ -160,8 +160,8 @@ class TaskService
mentioned_users
.
uniq
end
def
pending_t
ask
s
(
user
,
project
,
target
)
user
.
t
ask
s
.
pending
.
where
(
def
pending_t
odo
s
(
user
,
project
,
target
)
user
.
t
odo
s
.
pending
.
where
(
project_id:
project
.
id
,
target_id:
target
.
id
,
target_type:
target
.
class
.
name
...
...
app/views/dashboard/tasks/_task.html.haml
已删除
100644 → 0
浏览文件 @
408e010d
%li
{
class:
"task task-#{task.done? ? 'done' : 'pending'}"
,
id:
dom_id
(
task
)
}
.task-item
{
class:
'task-block'
}
=
image_tag
avatar_icon
(
task
.
author_email
,
40
),
class:
'avatar s40'
,
alt
:''
.task-title
%span
.author_name
=
link_to_author
task
%span
.task_label
=
task_action_name
(
task
)
=
task_target_link_html
(
task
)
·
#{
time_ago_with_tooltip
(
task
.
created_at
)
}
-
if
task
.
pending?
.task-actions.pull-right
=
link_to
'Done'
,
[
:dashboard
,
task
],
method: :delete
,
class:
'btn'
.task-body
.task-note
.md
=
event_note
(
task
.
body
,
project:
task
.
project
)
app/views/dashboard/todos/_todo.html.haml
0 → 100644
浏览文件 @
3d52e139
%li
{
class:
"todo todo-#{todo.done? ? 'done' : 'pending'}"
,
id:
dom_id
(
todo
)
}
.todo-item
{
class:
'todo-block'
}
=
image_tag
avatar_icon
(
todo
.
author_email
,
40
),
class:
'avatar s40'
,
alt
:''
.todo-title
%span
.author_name
=
link_to_author
todo
%span
.todo_label
=
todo_action_name
(
todo
)
=
todo_target_link_html
(
todo
)
·
#{
time_ago_with_tooltip
(
todo
.
created_at
)
}
-
if
todo
.
pending?
.todo-actions.pull-right
=
link_to
'Done'
,
[
:dashboard
,
todo
],
method: :delete
,
class:
'btn'
.todo-body
.todo-note
.md
=
event_note
(
todo
.
body
,
project:
todo
.
project
)
app/views/dashboard/t
ask
s/index.html.haml
→
app/views/dashboard/t
odo
s/index.html.haml
浏览文件 @
3d52e139
-
page_title
"T
ask
s"
-
header_title
"T
asks"
,
dashboard_task
s_path
-
page_title
"T
odo
s"
-
header_title
"T
odos"
,
dashboard_todo
s_path
.top-area
%ul
.nav-links
%li
{
class:
(
'active'
if
params
[
:state
].
blank?
||
params
[
:state
]
==
'pending'
)}
=
link_to
page_filter_path
(
state:
'pending'
)
do
%span
T
ask
s
T
odo
s
%span
{
class:
'badge'
}
=
t
ask
s_pending_count
=
t
odo
s_pending_count
%li
{
class:
(
'active'
if
params
[
:state
]
==
'done'
)}
=
link_to
page_filter_path
(
state:
'done'
)
do
%span
Done
%span
{
class:
'badge'
}
=
t
ask
s_done_count
=
t
odo
s_done_count
.t
ask
s-filters
.t
odo
s-filters
.gray-content-block.second-block
=
form_tag
page_filter_path
(
without:
[
:assignee_id
,
:milestone_title
,
:label_name
,
:scope
,
:sort
]),
method: :get
,
class:
'filter-form'
do
.filter-item.inline
=
select_tag
(
'project_id'
,
t
ask
_projects_options
,
=
select_tag
(
'project_id'
,
t
odo
_projects_options
,
class:
'select2 trigger-submit'
,
include_blank:
true
,
data:
{
placeholder:
'Project'
})
.filter-item.inline
=
users_select_tag
(
:author_id
,
selected:
params
[
:author_id
],
placeholder:
'Author'
,
class:
'trigger-submit'
,
any_user:
"Any Author"
,
first_user:
true
,
current_user:
true
)
.filter-item.inline
=
select_tag
(
'type'
,
t
ask
_types_options
,
=
select_tag
(
'type'
,
t
odo
_types_options
,
class:
'select2 trigger-submit'
,
include_blank:
true
,
data:
{
placeholder:
'Type'
})
.filter-item.inline.actions-filter
=
select_tag
(
'action_id'
,
t
ask
_actions_options
,
=
select_tag
(
'action_id'
,
t
odo
_actions_options
,
class:
'select2 trigger-submit'
,
include_blank:
true
,
data:
{
placeholder:
'Action'
})
.prepend-top-default
-
if
@t
ask
s
.
any?
-
@t
ask
s
.
group_by
(
&
:project
).
each
do
|
group
|
-
if
@t
odo
s
.
any?
-
@t
odo
s
.
group_by
(
&
:project
).
each
do
|
group
|
.panel.panel-default.panel-small
-
project
=
group
[
0
]
.panel-heading
=
link_to
project
.
name_with_namespace
,
namespace_project_path
(
project
.
namespace
,
project
)
%ul
.well-list.t
ask
s-list
%ul
.well-list.t
odo
s-list
=
render
group
[
1
]
=
paginate
@t
ask
s
,
theme:
"gitlab"
=
paginate
@t
odo
s
,
theme:
"gitlab"
-
else
.nothing-here-block
No t
ask
s to show
.nothing-here-block
No t
odo
s to show
:javascript
new
UsersSelect
();
...
...
app/views/layouts/header/_default.html.haml
浏览文件 @
3d52e139
...
...
@@ -22,9 +22,9 @@
=
link_to
admin_root_path
,
title:
'Admin Area'
,
data:
{
toggle:
'tooltip'
,
placement:
'bottom'
,
container:
'body'
}
do
=
icon
(
'wrench fw'
)
%li
=
link_to
dashboard_t
asks_path
,
title:
'Task
s'
,
data:
{
toggle:
'tooltip'
,
placement:
'bottom'
,
container:
'body'
}
do
%span
.badge.t
ask
s-pending-count
=
t
ask
s_pending_count
=
link_to
dashboard_t
odos_path
,
title:
'Todo
s'
,
data:
{
toggle:
'tooltip'
,
placement:
'bottom'
,
container:
'body'
}
do
%span
.badge.t
odo
s-pending-count
=
t
odo
s_pending_count
-
if
current_user
.
can_create_project?
%li
=
link_to
new_project_path
,
title:
'New project'
,
data:
{
toggle:
'tooltip'
,
placement:
'bottom'
,
container:
'body'
}
do
...
...
app/views/layouts/nav/_dashboard.html.haml
浏览文件 @
3d52e139
...
...
@@ -4,12 +4,12 @@
=
icon
(
'home fw'
)
%span
Projects
=
nav_link
(
controller: :t
ask
s
)
do
=
link_to
dashboard_t
asks_path
,
title:
'Task
s'
do
=
nav_link
(
controller: :t
odo
s
)
do
=
link_to
dashboard_t
odos_path
,
title:
'Todo
s'
do
=
icon
(
'bell fw'
)
%span
T
ask
s
%span
.count
=
number_with_delimiter
(
t
ask
s_pending_count
)
T
odo
s
%span
.count
=
number_with_delimiter
(
t
odo
s_pending_count
)
=
nav_link
(
path:
'dashboard#activity'
)
do
=
link_to
activity_dashboard_path
,
class:
'shortcuts-activity'
,
title:
'Activity'
do
=
icon
(
'dashboard fw'
)
...
...
config/routes.rb
浏览文件 @
3d52e139
...
...
@@ -333,7 +333,7 @@ Rails.application.routes.draw do
resources
:groups
,
only:
[
:index
]
resources
:snippets
,
only:
[
:index
]
resources
:t
ask
s
,
only:
[
:index
,
:destroy
]
resources
:t
odo
s
,
only:
[
:index
,
:destroy
]
resources
:projects
,
only:
[
:index
]
do
collection
do
...
...
db/migrate/20160220123949_rename_tasks_to_todos.rb
0 → 100644
浏览文件 @
3d52e139
class
RenameTasksToTodos
<
ActiveRecord
::
Migration
def
change
rename_table
:tasks
,
:todos
end
end
db/schema.rb
浏览文件 @
3d52e139
...
...
@@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord
::
Schema
.
define
(
version:
201602
17174422
)
do
ActiveRecord
::
Schema
.
define
(
version:
201602
20123949
)
do
# These are extensions that must be enabled in order to support this database
enable_extension
"plpgsql"
...
...
@@ -824,7 +824,7 @@ ActiveRecord::Schema.define(version: 20160217174422) do
add_index
"tags"
,
[
"name"
],
name:
"index_tags_on_name"
,
unique:
true
,
using: :btree
create_table
"t
ask
s"
,
force: :cascade
do
|
t
|
create_table
"t
odo
s"
,
force: :cascade
do
|
t
|
t
.
integer
"user_id"
,
null:
false
t
.
integer
"project_id"
,
null:
false
t
.
integer
"target_id"
,
null:
false
...
...
@@ -837,12 +837,12 @@ ActiveRecord::Schema.define(version: 20160217174422) do
t
.
integer
"note_id"
end
add_index
"t
asks"
,
[
"author_id"
],
name:
"index_task
s_on_author_id"
,
using: :btree
add_index
"t
asks"
,
[
"note_id"
],
name:
"index_task
s_on_note_id"
,
using: :btree
add_index
"t
asks"
,
[
"project_id"
],
name:
"index_task
s_on_project_id"
,
using: :btree
add_index
"t
asks"
,
[
"state"
],
name:
"index_task
s_on_state"
,
using: :btree
add_index
"t
asks"
,
[
"target_type"
,
"target_id"
],
name:
"index_task
s_on_target_type_and_target_id"
,
using: :btree
add_index
"t
asks"
,
[
"user_id"
],
name:
"index_task
s_on_user_id"
,
using: :btree
add_index
"t
odos"
,
[
"author_id"
],
name:
"index_todo
s_on_author_id"
,
using: :btree
add_index
"t
odos"
,
[
"note_id"
],
name:
"index_todo
s_on_note_id"
,
using: :btree
add_index
"t
odos"
,
[
"project_id"
],
name:
"index_todo
s_on_project_id"
,
using: :btree
add_index
"t
odos"
,
[
"state"
],
name:
"index_todo
s_on_state"
,
using: :btree
add_index
"t
odos"
,
[
"target_type"
,
"target_id"
],
name:
"index_todo
s_on_target_type_and_target_id"
,
using: :btree
add_index
"t
odos"
,
[
"user_id"
],
name:
"index_todo
s_on_user_id"
,
using: :btree
create_table
"users"
,
force: :cascade
do
|
t
|
t
.
string
"email"
,
default:
""
,
null:
false
...
...
features/dashboard/t
ask
s.feature
→
features/dashboard/t
odo
s.feature
浏览文件 @
3d52e139
@dashboard
Feature
:
Dashboard T
ask
s
Feature
:
Dashboard T
odo
s
Background
:
Given
I sign in as a user
And
I own project
"Shop"
...
...
@@ -7,32 +7,32 @@ Feature: Dashboard Tasks
And
"Mary Jane"
is a developer of project
"Shop"
And
"Mary Jane"
owns private project
"Enterprise"
And
I am a developer of project
"Enterprise"
And
I have
pending task
s
And
I visit dashboard t
ask queue
page
And
I have
todo
s
And
I visit dashboard t
odos
page
@javascript
Scenario
:
I
mark
pending task
s as done
Then
I should see
pending task
s assigned to me
And
I mark the
pending task
as done
Scenario
:
I
mark
todo
s as done
Then
I should see
todo
s assigned to me
And
I mark the
todo
as done
And
I click on the
"Done"
tab
Then
I should see all t
ask
s marked as done
Then
I should see all t
odo
s marked as done
@javascript
Scenario
:
I
filter by project
Given
I filter by
"Enterprise"
Then
I should not see t
ask
s
Then
I should not see t
odo
s
@javascript
Scenario
:
I
filter by author
Given
I filter by
"John Doe"
Then
I should not see t
ask
s related to
"Mary Jane"
in the list
Then
I should not see t
odo
s related to
"Mary Jane"
in the list
@javascript
Scenario
:
I
filter by type
Given
I filter by
"Issue"
Then
I should not see t
ask
s related to
"Merge Requests"
in the list
Then
I should not see t
odo
s related to
"Merge Requests"
in the list
@javascript
Scenario
:
I
filter by action
Given
I filter by
"Mentioned"
Then
I should not see t
ask
s related to
"Assignments"
in the list
Then
I should not see t
odo
s related to
"Assignments"
in the list
features/steps/dashboard/t
ask
s.rb
→
features/steps/dashboard/t
odo
s.rb
浏览文件 @
3d52e139
class
Spinach::Features::DashboardT
ask
s
<
Spinach
::
FeatureSteps
class
Spinach::Features::DashboardT
odo
s
<
Spinach
::
FeatureSteps
include
SharedAuthentication
include
SharedPaths
include
SharedProject
...
...
@@ -17,43 +17,43 @@ class Spinach::Features::DashboardTasks < Spinach::FeatureSteps
project
.
team
<<
[
john_doe
,
:developer
]
end
step
'I have
pending task
s'
do
create
(
:t
ask
,
user:
current_user
,
project:
project
,
author:
mary_jane
,
target:
issue
,
action:
Task
::
MENTIONED
)
create
(
:t
ask
,
user:
current_user
,
project:
project
,
author:
john_doe
,
target:
issue
,
action:
Task
::
ASSIGNED
)
step
'I have
todo
s'
do
create
(
:t
odo
,
user:
current_user
,
project:
project
,
author:
mary_jane
,
target:
issue
,
action:
Todo
::
MENTIONED
)
create
(
:t
odo
,
user:
current_user
,
project:
project
,
author:
john_doe
,
target:
issue
,
action:
Todo
::
ASSIGNED
)
note
=
create
(
:note
,
author:
john_doe
,
noteable:
issue
,
note:
"
#{
current_user
.
to_reference
}
Wdyt?"
)
create
(
:t
ask
,
user:
current_user
,
project:
project
,
author:
john_doe
,
target:
issue
,
action:
Task
::
MENTIONED
,
note:
note
)
create
(
:t
ask
,
user:
current_user
,
project:
project
,
author:
john_doe
,
target:
merge_request
,
action:
Task
::
ASSIGNED
)
create
(
:t
odo
,
user:
current_user
,
project:
project
,
author:
john_doe
,
target:
issue
,
action:
Todo
::
MENTIONED
,
note:
note
)
create
(
:t
odo
,
user:
current_user
,
project:
project
,
author:
john_doe
,
target:
merge_request
,
action:
Todo
::
ASSIGNED
)
end
step
'I should see
pending task
s assigned to me'
do
expect
(
page
).
to
have_content
'T
ask
s 4'
step
'I should see
todo
s assigned to me'
do
expect
(
page
).
to
have_content
'T
odo
s 4'
expect
(
page
).
to
have_content
'Done 0'
expect
(
page
).
to
have_link
project
.
name_with_namespace
should_see_t
ask
(
1
,
"John Doe assigned merge request #
#{
merge_request
.
iid
}
"
,
merge_request
.
title
)
should_see_t
ask
(
2
,
"John Doe mentioned you on issue #
#{
issue
.
iid
}
"
,
"
#{
current_user
.
to_reference
}
Wdyt?"
)
should_see_t
ask
(
3
,
"John Doe assigned issue #
#{
issue
.
iid
}
"
,
issue
.
title
)
should_see_t
ask
(
4
,
"Mary Jane mentioned you on issue #
#{
issue
.
iid
}
"
,
issue
.
title
)
should_see_t
odo
(
1
,
"John Doe assigned merge request #
#{
merge_request
.
iid
}
"
,
merge_request
.
title
)
should_see_t
odo
(
2
,
"John Doe mentioned you on issue #
#{
issue
.
iid
}
"
,
"
#{
current_user
.
to_reference
}
Wdyt?"
)
should_see_t
odo
(
3
,
"John Doe assigned issue #
#{
issue
.
iid
}
"
,
issue
.
title
)
should_see_t
odo
(
4
,
"Mary Jane mentioned you on issue #
#{
issue
.
iid
}
"
,
issue
.
title
)
end
step
'I mark the
pending task
as done'
do
page
.
within
(
'.t
ask
:nth-child(1)'
)
do
step
'I mark the
todo
as done'
do
page
.
within
(
'.t
odo
:nth-child(1)'
)
do
click_link
'Done'
end
expect
(
page
).
to
have_content
'T
ask
was successfully marked as done.'
expect
(
page
).
to
have_content
'T
ask
s 3'
expect
(
page
).
to
have_content
'T
odo
was successfully marked as done.'
expect
(
page
).
to
have_content
'T
odo
s 3'
expect
(
page
).
to
have_content
'Done 1'
should_not_see_t
ask
"John Doe assigned merge request #
#{
merge_request
.
iid
}
"
should_not_see_t
odo
"John Doe assigned merge request #
#{
merge_request
.
iid
}
"
end
step
'I click on the "Done" tab'
do
click_link
'Done 1'
end
step
'I should see all t
ask
s marked as done'
do
step
'I should see all t
odo
s marked as done'
do
expect
(
page
).
to
have_link
project
.
name_with_namespace
should_see_t
ask
(
1
,
"John Doe assigned merge request #
#{
merge_request
.
iid
}
"
,
merge_request
.
title
,
false
)
should_see_t
odo
(
1
,
"John Doe assigned merge request #
#{
merge_request
.
iid
}
"
,
merge_request
.
title
,
false
)
end
step
'I filter by "Enterprise"'
do
...
...
@@ -69,28 +69,28 @@ class Spinach::Features::DashboardTasks < Spinach::FeatureSteps
end
step
'I filter by "Mentioned"'
do
select2
(
"
#{
T
ask
::
MENTIONED
}
"
,
from:
'#action_id'
)
select2
(
"
#{
T
odo
::
MENTIONED
}
"
,
from:
'#action_id'
)
end
step
'I should not see t
ask
s'
do
expect
(
page
).
to
have_content
'No t
ask
s to show'
step
'I should not see t
odo
s'
do
expect
(
page
).
to
have_content
'No t
odo
s to show'
end
step
'I should not see t
ask
s related to "Mary Jane" in the list'
do
should_not_see_t
ask
"Mary Jane mentioned you on issue #
#{
issue
.
iid
}
"
step
'I should not see t
odo
s related to "Mary Jane" in the list'
do
should_not_see_t
odo
"Mary Jane mentioned you on issue #
#{
issue
.
iid
}
"
end
step
'I should not see t
ask
s related to "Merge Requests" in the list'
do
should_not_see_t
ask
"John Doe assigned merge request #
#{
merge_request
.
iid
}
"
step
'I should not see t
odo
s related to "Merge Requests" in the list'
do
should_not_see_t
odo
"John Doe assigned merge request #
#{
merge_request
.
iid
}
"
end
step
'I should not see t
ask
s related to "Assignments" in the list'
do
should_not_see_t
ask
"John Doe assigned merge request #
#{
merge_request
.
iid
}
"
should_not_see_t
ask
"John Doe assigned issue #
#{
issue
.
iid
}
"
step
'I should not see t
odo
s related to "Assignments" in the list'
do
should_not_see_t
odo
"John Doe assigned merge request #
#{
merge_request
.
iid
}
"
should_not_see_t
odo
"John Doe assigned issue #
#{
issue
.
iid
}
"
end
def
should_see_t
ask
(
position
,
title
,
body
,
pending
=
true
)
page
.
within
(
".t
ask
:nth-child(
#{
position
}
)"
)
do
def
should_see_t
odo
(
position
,
title
,
body
,
pending
=
true
)
page
.
within
(
".t
odo
:nth-child(
#{
position
}
)"
)
do
expect
(
page
).
to
have_content
title
expect
(
page
).
to
have_content
body
...
...
@@ -102,7 +102,7 @@ class Spinach::Features::DashboardTasks < Spinach::FeatureSteps
end
end
def
should_not_see_t
ask
(
title
)
def
should_not_see_t
odo
(
title
)
expect
(
page
).
not_to
have_content
title
end
...
...
features/steps/shared/paths.rb
浏览文件 @
3d52e139
...
...
@@ -103,8 +103,8 @@ module SharedPaths
visit
dashboard_groups_path
end
step
'I visit dashboard t
ask queue
page'
do
visit
dashboard_t
ask
s_path
step
'I visit dashboard t
odos
page'
do
visit
dashboard_t
odo
s_path
end
step
'I should be redirected to the dashboard groups page'
do
...
...
spec/factories/t
ask
s.rb
→
spec/factories/t
odo
s.rb
浏览文件 @
3d52e139
# == Schema Information
#
# Table name: t
ask
s
# Table name: t
odo
s
#
# id :integer not null, primary key
# user_id :integer not null
...
...
@@ -16,19 +16,19 @@
#
FactoryGirl
.
define
do
factory
:t
ask
do
factory
:t
odo
do
project
author
user
target
factory: :issue
action
{
T
ask
::
ASSIGNED
}
action
{
T
odo
::
ASSIGNED
}
trait
:assigned
do
action
{
T
ask
::
ASSIGNED
}
action
{
T
odo
::
ASSIGNED
}
end
trait
:mentioned
do
action
{
T
ask
::
MENTIONED
}
action
{
T
odo
::
MENTIONED
}
end
end
end
spec/models/note_spec.rb
浏览文件 @
3d52e139
...
...
@@ -27,7 +27,7 @@ describe Note, models: true do
it
{
is_expected
.
to
belong_to
(
:noteable
)
}
it
{
is_expected
.
to
belong_to
(
:author
).
class_name
(
'User'
)
}
it
{
is_expected
.
to
have_many
(
:t
ask
s
).
dependent
(
:destroy
)
}
it
{
is_expected
.
to
have_many
(
:t
odo
s
).
dependent
(
:destroy
)
}
end
describe
'validation'
do
...
...
spec/models/t
ask_spec
.rb
→
spec/models/t
odo_spec.rb
.rb
浏览文件 @
3d52e139
# == Schema Information
#
# Table name: t
ask
s
# Table name: t
odo
s
#
# id :integer not null, primary key
# user_id :integer not null
...
...
@@ -17,7 +17,7 @@
require
'spec_helper'
describe
T
ask
,
models:
true
do
describe
T
odo
,
models:
true
do
describe
'relationships'
do
it
{
is_expected
.
to
belong_to
(
:author
).
class_name
(
"User"
)
}
it
{
is_expected
.
to
belong_to
(
:note
)
}
...
...
@@ -39,13 +39,13 @@ describe Task, models: true do
describe
'#action_name'
do
it
'returns proper message when action is an assigment'
do
subject
.
action
=
T
ask
::
ASSIGNED
subject
.
action
=
T
odo
::
ASSIGNED
expect
(
subject
.
action_name
).
to
eq
'assigned'
end
it
'returns proper message when action is a mention'
do
subject
.
action
=
T
ask
::
MENTIONED
subject
.
action
=
T
odo
::
MENTIONED
expect
(
subject
.
action_name
).
to
eq
'mentioned you on'
end
...
...
spec/models/user_spec.rb
浏览文件 @
3d52e139
...
...
@@ -92,7 +92,7 @@ describe User, models: true do
it
{
is_expected
.
to
have_many
(
:identities
).
dependent
(
:destroy
)
}
it
{
is_expected
.
to
have_one
(
:abuse_report
)
}
it
{
is_expected
.
to
have_many
(
:spam_logs
).
dependent
(
:destroy
)
}
it
{
is_expected
.
to
have_many
(
:t
ask
s
).
dependent
(
:destroy
)
}
it
{
is_expected
.
to
have_many
(
:t
odo
s
).
dependent
(
:destroy
)
}
end
describe
'validations'
do
...
...
spec/services/issues/close_service_spec.rb
浏览文件 @
3d52e139
...
...
@@ -5,7 +5,7 @@ describe Issues::CloseService, services: true do
let
(
:user2
)
{
create
(
:user
)
}
let
(
:issue
)
{
create
(
:issue
,
assignee:
user2
)
}
let
(
:project
)
{
issue
.
project
}
let!
(
:
pending_task
)
{
create
(
:task
,
:assigned
,
user:
user
,
project:
project
,
target:
issue
,
author:
user2
)
}
let!
(
:
todo
)
{
create
(
:todo
,
:assigned
,
user:
user
,
project:
project
,
target:
issue
,
author:
user2
)
}
before
do
project
.
team
<<
[
user
,
:master
]
...
...
@@ -34,8 +34,8 @@ describe Issues::CloseService, services: true do
expect
(
note
.
note
).
to
include
"Status changed to closed"
end
it
'marks
pending task
s as done'
do
expect
(
pending_task
.
reload
).
to
be_done
it
'marks
todo
s as done'
do
expect
(
todo
.
reload
).
to
be_done
end
end
...
...
@@ -47,7 +47,7 @@ describe Issues::CloseService, services: true do
it
{
expect
(
@issue
).
to
be_valid
}
it
{
expect
(
@issue
).
to
be_opened
}
it
{
expect
(
pending_task
.
reload
).
to
be_pending
}
it
{
expect
(
todo
.
reload
).
to
be_pending
}
end
end
end
spec/services/issues/create_service_spec.rb
浏览文件 @
3d52e139
...
...
@@ -24,17 +24,18 @@ describe Issues::CreateService, services: true do
it
{
expect
(
@issue
.
title
).
to
eq
(
'Awesome issue'
)
}
it
{
expect
(
@issue
.
assignee
).
to
eq
assignee
}
it
'creates a pending t
ask
for new assignee'
do
it
'creates a pending t
odo
for new assignee'
do
attributes
=
{
project:
project
,
author:
user
,
user:
assignee
,
target:
@issue
,
action:
Task
::
ASSIGNED
,
target_id:
@issue
.
id
,
target_type:
@issue
.
class
.
name
,
action:
Todo
::
ASSIGNED
,
state: :pending
}
expect
(
T
ask
.
where
(
attributes
).
count
).
to
eq
1
expect
(
T
odo
.
where
(
attributes
).
count
).
to
eq
1
end
end
end
...
...
spec/services/issues/update_service_spec.rb
浏览文件 @
3d52e139
...
...
@@ -80,16 +80,16 @@ describe Issues::UpdateService, services: true do
end
end
context
't
ask queue
'
do
let!
(
:
pending_task
)
{
create
(
:task
,
:assigned
,
user:
user
,
project:
project
,
target:
issue
,
author:
user2
)
}
context
't
odos
'
do
let!
(
:
todo
)
{
create
(
:todo
,
:assigned
,
user:
user
,
project:
project
,
target:
issue
,
author:
user2
)
}
context
'when the title change'
do
before
do
update_issue
({
title:
'New title'
})
end
it
'marks pending t
ask
s as done'
do
expect
(
pending_task
.
reload
.
done?
).
to
eq
true
it
'marks pending t
odo
s as done'
do
expect
(
todo
.
reload
.
done?
).
to
eq
true
end
end
...
...
@@ -98,8 +98,8 @@ describe Issues::UpdateService, services: true do
update_issue
({
description:
'Also please fix'
})
end
it
'marks
pending task
s as done'
do
expect
(
pending_task
.
reload
.
done?
).
to
eq
true
it
'marks
todo
s as done'
do
expect
(
todo
.
reload
.
done?
).
to
eq
true
end
end
...
...
@@ -108,21 +108,22 @@ describe Issues::UpdateService, services: true do
update_issue
({
assignee:
user2
})
end
it
'marks previous assignee
pending task
s as done'
do
expect
(
pending_task
.
reload
.
done?
).
to
eq
true
it
'marks previous assignee
todo
s as done'
do
expect
(
todo
.
reload
.
done?
).
to
eq
true
end
it
'creates a
pending task
for new assignee'
do
it
'creates a
todo
for new assignee'
do
attributes
=
{
project:
project
,
author:
user
,
user:
user2
,
target:
issue
,
action:
Task
::
ASSIGNED
,
target_id:
issue
.
id
,
target_type:
issue
.
class
.
name
,
action:
Todo
::
ASSIGNED
,
state: :pending
}
expect
(
T
ask
.
where
(
attributes
).
count
).
to
eq
1
expect
(
T
odo
.
where
(
attributes
).
count
).
to
eq
1
end
end
...
...
@@ -131,8 +132,8 @@ describe Issues::UpdateService, services: true do
update_issue
({
milestone:
create
(
:milestone
)
})
end
it
'marks
pending task
s as done'
do
expect
(
pending_task
.
reload
.
done?
).
to
eq
true
it
'marks
todo
s as done'
do
expect
(
todo
.
reload
.
done?
).
to
eq
true
end
end
...
...
@@ -141,8 +142,8 @@ describe Issues::UpdateService, services: true do
update_issue
({
label_ids:
[
label
.
id
]
})
end
it
'marks
pending task
s as done'
do
expect
(
pending_task
.
reload
.
done?
).
to
eq
true
it
'marks
todo
s as done'
do
expect
(
todo
.
reload
.
done?
).
to
eq
true
end
end
end
...
...
spec/services/merge_requests/close_service_spec.rb
浏览文件 @
3d52e139
...
...
@@ -5,7 +5,7 @@ describe MergeRequests::CloseService, services: true do
let
(
:user2
)
{
create
(
:user
)
}
let
(
:merge_request
)
{
create
(
:merge_request
,
assignee:
user2
)
}
let
(
:project
)
{
merge_request
.
project
}
let!
(
:
pending_task
)
{
create
(
:task
,
:assigned
,
user:
user
,
project:
project
,
target:
merge_request
,
author:
user2
)
}
let!
(
:
todo
)
{
create
(
:todo
,
:assigned
,
user:
user
,
project:
project
,
target:
merge_request
,
author:
user2
)
}
before
do
project
.
team
<<
[
user
,
:master
]
...
...
@@ -43,8 +43,8 @@ describe MergeRequests::CloseService, services: true do
expect
(
note
.
note
).
to
include
'Status changed to closed'
end
it
'marks
pending task
s as done'
do
expect
(
pending_task
.
reload
).
to
be_done
it
'marks
todo
s as done'
do
expect
(
todo
.
reload
).
to
be_done
end
end
end
...
...
spec/services/merge_requests/create_service_spec.rb
浏览文件 @
3d52e139
...
...
@@ -34,13 +34,14 @@ describe MergeRequests::CreateService, services: true do
expect
(
service
).
to
have_received
(
:execute_hooks
).
with
(
@merge_request
)
end
it
'does not creates
a pending task
'
do
it
'does not creates
todos
'
do
attributes
=
{
project:
project
,
target:
@merge_request
target_id:
@merge_request
.
id
,
target_type:
@merge_request
.
class
.
name
}
expect
(
T
ask
.
where
(
attributes
).
count
).
to
be_zero
expect
(
T
odo
.
where
(
attributes
).
count
).
to
be_zero
end
context
'when merge request is assigned to someone'
do
...
...
@@ -56,17 +57,18 @@ describe MergeRequests::CreateService, services: true do
it
{
expect
(
@merge_request
.
assignee
).
to
eq
assignee
}
it
'creates a
pending task
for new assignee'
do
it
'creates a
todo
for new assignee'
do
attributes
=
{
project:
project
,
author:
user
,
user:
assignee
,
target:
@merge_request
,
action:
Task
::
ASSIGNED
,
target_id:
@merge_request
.
id
,
target_type:
@merge_request
.
class
.
name
,
action:
Todo
::
ASSIGNED
,
state: :pending
}
expect
(
T
ask
.
where
(
attributes
).
count
).
to
eq
1
expect
(
T
odo
.
where
(
attributes
).
count
).
to
eq
1
end
end
end
...
...
spec/services/merge_requests/update_service_spec.rb
浏览文件 @
3d52e139
...
...
@@ -98,16 +98,16 @@ describe MergeRequests::UpdateService, services: true do
end
end
context
't
ask queue
'
do
let!
(
:pending_t
ask
)
{
create
(
:task
,
:assigned
,
user:
user
,
project:
project
,
target:
merge_request
,
author:
user2
)
}
context
't
odos
'
do
let!
(
:pending_t
odo
)
{
create
(
:todo
,
:assigned
,
user:
user
,
project:
project
,
target:
merge_request
,
author:
user2
)
}
context
'when the title change'
do
before
do
update_merge_request
({
title:
'New title'
})
end
it
'marks pending t
ask
s as done'
do
expect
(
pending_t
ask
.
reload
).
to
be_done
it
'marks pending t
odo
s as done'
do
expect
(
pending_t
odo
.
reload
).
to
be_done
end
end
...
...
@@ -116,8 +116,8 @@ describe MergeRequests::UpdateService, services: true do
update_merge_request
({
description:
'Also please fix'
})
end
it
'marks pending t
ask
s as done'
do
expect
(
pending_t
ask
.
reload
).
to
be_done
it
'marks pending t
odo
s as done'
do
expect
(
pending_t
odo
.
reload
).
to
be_done
end
end
...
...
@@ -126,21 +126,22 @@ describe MergeRequests::UpdateService, services: true do
update_merge_request
({
assignee:
user2
})
end
it
'marks previous assignee pending t
ask
s as done'
do
expect
(
pending_t
ask
.
reload
).
to
be_done
it
'marks previous assignee pending t
odo
s as done'
do
expect
(
pending_t
odo
.
reload
).
to
be_done
end
it
'creates a pending t
ask
for new assignee'
do
it
'creates a pending t
odo
for new assignee'
do
attributes
=
{
project:
project
,
author:
user
,
user:
user2
,
target:
merge_request
,
action:
Task
::
ASSIGNED
,
target_id:
merge_request
.
id
,
target_type:
merge_request
.
class
.
name
,
action:
Todo
::
ASSIGNED
,
state: :pending
}
expect
(
T
ask
.
where
(
attributes
).
count
).
to
eq
1
expect
(
T
odo
.
where
(
attributes
).
count
).
to
eq
1
end
end
...
...
@@ -149,8 +150,8 @@ describe MergeRequests::UpdateService, services: true do
update_merge_request
({
milestone:
create
(
:milestone
)
})
end
it
'marks pending t
ask
s as done'
do
expect
(
pending_t
ask
.
reload
).
to
be_done
it
'marks pending t
odo
s as done'
do
expect
(
pending_t
odo
.
reload
).
to
be_done
end
end
...
...
@@ -159,8 +160,8 @@ describe MergeRequests::UpdateService, services: true do
update_merge_request
({
label_ids:
[
label
.
id
]
})
end
it
'marks pending t
ask
s as done'
do
expect
(
pending_t
ask
.
reload
).
to
be_done
it
'marks pending t
odo
s as done'
do
expect
(
pending_t
odo
.
reload
).
to
be_done
end
end
...
...
@@ -169,8 +170,8 @@ describe MergeRequests::UpdateService, services: true do
update_merge_request
({
target_branch:
'target'
})
end
it
'marks pending t
ask
s as done'
do
expect
(
pending_t
ask
.
reload
).
to
be_done
it
'marks pending t
odo
s as done'
do
expect
(
pending_t
odo
.
reload
).
to
be_done
end
end
end
...
...
spec/services/notes/update_service_spec.rb
浏览文件 @
3d52e139
...
...
@@ -18,16 +18,16 @@ describe Notes::UpdateService, services: true do
@note
.
reload
end
context
't
ask queue
'
do
let!
(
:
pending_task
)
{
create
(
:task
,
:assigned
,
user:
user
,
project:
project
,
target:
issue
,
author:
user2
)
}
context
't
odos
'
do
let!
(
:
todo
)
{
create
(
:todo
,
:assigned
,
user:
user
,
project:
project
,
target:
issue
,
author:
user2
)
}
context
'when the note change'
do
before
do
update_note
({
note:
'New note'
})
end
it
'marks
pending task
s as done'
do
expect
(
pending_task
.
reload
).
to
be_done
it
'marks
todo
s as done'
do
expect
(
todo
.
reload
).
to
be_done
end
end
...
...
@@ -36,8 +36,8 @@ describe Notes::UpdateService, services: true do
update_note
({
note:
'Old note'
})
end
it
'keep
pending task
s'
do
expect
(
pending_task
.
reload
).
to
be_pending
it
'keep
todo
s'
do
expect
(
todo
.
reload
).
to
be_pending
end
end
end
...
...
spec/services/t
ask
_service_spec.rb
→
spec/services/t
odo
_service_spec.rb
浏览文件 @
3d52e139
require
'spec_helper'
describe
T
ask
Service
,
services:
true
do
describe
T
odo
Service
,
services:
true
do
let
(
:author
)
{
create
(
:user
)
}
let
(
:john_doe
)
{
create
(
:user
,
username:
'john_doe'
)
}
let
(
:michael
)
{
create
(
:user
,
username:
'michael'
)
}
...
...
@@ -20,130 +20,130 @@ describe TaskService, services: true do
let
(
:unassigned_issue
)
{
create
(
:issue
,
project:
project
,
assignee:
nil
)
}
describe
'#new_issue'
do
it
'creates a t
ask
if assigned'
do
it
'creates a t
odo
if assigned'
do
service
.
new_issue
(
issue
,
author
)
should_create_t
ask
(
user:
john_doe
,
target:
issue
,
action:
Task
::
ASSIGNED
)
should_create_t
odo
(
user:
john_doe
,
target:
issue
,
action:
Todo
::
ASSIGNED
)
end
it
'does not create a t
ask
if unassigned'
do
should_not_create_any_t
ask
{
service
.
new_issue
(
unassigned_issue
,
author
)
}
it
'does not create a t
odo
if unassigned'
do
should_not_create_any_t
odo
{
service
.
new_issue
(
unassigned_issue
,
author
)
}
end
it
'does not create a t
ask
if assignee is the current user'
do
should_not_create_any_t
ask
{
service
.
new_issue
(
unassigned_issue
,
john_doe
)
}
it
'does not create a t
odo
if assignee is the current user'
do
should_not_create_any_t
odo
{
service
.
new_issue
(
unassigned_issue
,
john_doe
)
}
end
it
'creates a t
ask
for each valid mentioned user'
do
it
'creates a t
odo
for each valid mentioned user'
do
service
.
new_issue
(
issue
,
author
)
should_create_t
ask
(
user:
michael
,
target:
issue
,
action:
Task
::
MENTIONED
)
should_not_create_t
ask
(
user:
author
,
target:
issue
,
action:
Task
::
MENTIONED
)
should_not_create_t
ask
(
user:
john_doe
,
target:
issue
,
action:
Task
::
MENTIONED
)
should_not_create_t
ask
(
user:
stranger
,
target:
issue
,
action:
Task
::
MENTIONED
)
should_create_t
odo
(
user:
michael
,
target:
issue
,
action:
Todo
::
MENTIONED
)
should_not_create_t
odo
(
user:
author
,
target:
issue
,
action:
Todo
::
MENTIONED
)
should_not_create_t
odo
(
user:
john_doe
,
target:
issue
,
action:
Todo
::
MENTIONED
)
should_not_create_t
odo
(
user:
stranger
,
target:
issue
,
action:
Todo
::
MENTIONED
)
end
end
describe
'#update_issue'
do
it
'creates a t
ask
for each valid mentioned user'
do
it
'creates a t
odo
for each valid mentioned user'
do
service
.
update_issue
(
issue
,
author
)
should_create_t
ask
(
user:
michael
,
target:
issue
,
action:
Task
::
MENTIONED
)
should_create_t
ask
(
user:
john_doe
,
target:
issue
,
action:
Task
::
MENTIONED
)
should_not_create_t
ask
(
user:
author
,
target:
issue
,
action:
Task
::
MENTIONED
)
should_not_create_t
ask
(
user:
stranger
,
target:
issue
,
action:
Task
::
MENTIONED
)
should_create_t
odo
(
user:
michael
,
target:
issue
,
action:
Todo
::
MENTIONED
)
should_create_t
odo
(
user:
john_doe
,
target:
issue
,
action:
Todo
::
MENTIONED
)
should_not_create_t
odo
(
user:
author
,
target:
issue
,
action:
Todo
::
MENTIONED
)
should_not_create_t
odo
(
user:
stranger
,
target:
issue
,
action:
Todo
::
MENTIONED
)
end
it
'does not create a t
ask
if user was already mentioned'
do
create
(
:t
ask
,
:mentioned
,
user:
michael
,
project:
project
,
target:
issue
,
author:
author
)
it
'does not create a t
odo
if user was already mentioned'
do
create
(
:t
odo
,
:mentioned
,
user:
michael
,
project:
project
,
target:
issue
,
author:
author
)
expect
{
service
.
update_issue
(
issue
,
author
)
}.
not_to
change
(
michael
.
t
ask
s
,
:count
)
expect
{
service
.
update_issue
(
issue
,
author
)
}.
not_to
change
(
michael
.
t
odo
s
,
:count
)
end
end
describe
'#close_issue'
do
it
'marks related pending t
ask
s to the target for the user as done'
do
first_t
ask
=
create
(
:task
,
:assigned
,
user:
john_doe
,
project:
project
,
target:
issue
,
author:
author
)
second_t
ask
=
create
(
:task
,
:assigned
,
user:
john_doe
,
project:
project
,
target:
issue
,
author:
author
)
it
'marks related pending t
odo
s to the target for the user as done'
do
first_t
odo
=
create
(
:todo
,
:assigned
,
user:
john_doe
,
project:
project
,
target:
issue
,
author:
author
)
second_t
odo
=
create
(
:todo
,
:assigned
,
user:
john_doe
,
project:
project
,
target:
issue
,
author:
author
)
service
.
close_issue
(
issue
,
john_doe
)
expect
(
first_t
ask
.
reload
).
to
be_done
expect
(
second_t
ask
.
reload
).
to
be_done
expect
(
first_t
odo
.
reload
).
to
be_done
expect
(
second_t
odo
.
reload
).
to
be_done
end
end
describe
'#reassigned_issue'
do
it
'creates a pending t
ask
for new assignee'
do
it
'creates a pending t
odo
for new assignee'
do
unassigned_issue
.
update_attribute
(
:assignee
,
john_doe
)
service
.
reassigned_issue
(
unassigned_issue
,
author
)
should_create_t
ask
(
user:
john_doe
,
target:
unassigned_issue
,
action:
Task
::
ASSIGNED
)
should_create_t
odo
(
user:
john_doe
,
target:
unassigned_issue
,
action:
Todo
::
ASSIGNED
)
end
it
'does not create a t
ask
if unassigned'
do
it
'does not create a t
odo
if unassigned'
do
issue
.
update_attribute
(
:assignee
,
nil
)
should_not_create_any_t
ask
{
service
.
reassigned_issue
(
issue
,
author
)
}
should_not_create_any_t
odo
{
service
.
reassigned_issue
(
issue
,
author
)
}
end
it
'does not create a t
ask
if new assignee is the current user'
do
it
'does not create a t
odo
if new assignee is the current user'
do
unassigned_issue
.
update_attribute
(
:assignee
,
john_doe
)
should_not_create_any_t
ask
{
service
.
reassigned_issue
(
unassigned_issue
,
john_doe
)
}
should_not_create_any_t
odo
{
service
.
reassigned_issue
(
unassigned_issue
,
john_doe
)
}
end
end
describe
'#mark_pending_t
ask
s_as_done'
do
it
'marks related pending t
ask
s to the target for the user as done'
do
first_t
ask
=
create
(
:task
,
:assigned
,
user:
john_doe
,
project:
project
,
target:
issue
,
author:
author
)
second_t
ask
=
create
(
:task
,
:assigned
,
user:
john_doe
,
project:
project
,
target:
issue
,
author:
author
)
describe
'#mark_pending_t
odo
s_as_done'
do
it
'marks related pending t
odo
s to the target for the user as done'
do
first_t
odo
=
create
(
:todo
,
:assigned
,
user:
john_doe
,
project:
project
,
target:
issue
,
author:
author
)
second_t
odo
=
create
(
:todo
,
:assigned
,
user:
john_doe
,
project:
project
,
target:
issue
,
author:
author
)
service
.
mark_pending_t
ask
s_as_done
(
issue
,
john_doe
)
service
.
mark_pending_t
odo
s_as_done
(
issue
,
john_doe
)
expect
(
first_t
ask
.
reload
).
to
be_done
expect
(
second_t
ask
.
reload
).
to
be_done
expect
(
first_t
odo
.
reload
).
to
be_done
expect
(
second_t
odo
.
reload
).
to
be_done
end
end
describe
'#new_note'
do
let!
(
:first_t
ask
)
{
create
(
:task
,
:assigned
,
user:
john_doe
,
project:
project
,
target:
issue
,
author:
author
)
}
let!
(
:second_t
ask
)
{
create
(
:task
,
:assigned
,
user:
john_doe
,
project:
project
,
target:
issue
,
author:
author
)
}
let!
(
:first_t
odo
)
{
create
(
:todo
,
:assigned
,
user:
john_doe
,
project:
project
,
target:
issue
,
author:
author
)
}
let!
(
:second_t
odo
)
{
create
(
:todo
,
:assigned
,
user:
john_doe
,
project:
project
,
target:
issue
,
author:
author
)
}
let
(
:note
)
{
create
(
:note
,
project:
project
,
noteable:
issue
,
author:
john_doe
,
note:
mentions
)
}
let
(
:award_note
)
{
create
(
:note
,
:award
,
project:
project
,
noteable:
issue
,
author:
john_doe
,
note:
'thumbsup'
)
}
let
(
:system_note
)
{
create
(
:system_note
,
project:
project
,
noteable:
issue
)
}
it
'mark related pending t
ask
s to the noteable for the note author as done'
do
first_t
ask
=
create
(
:task
,
:assigned
,
user:
john_doe
,
project:
project
,
target:
issue
,
author:
author
)
second_t
ask
=
create
(
:task
,
:assigned
,
user:
john_doe
,
project:
project
,
target:
issue
,
author:
author
)
it
'mark related pending t
odo
s to the noteable for the note author as done'
do
first_t
odo
=
create
(
:todo
,
:assigned
,
user:
john_doe
,
project:
project
,
target:
issue
,
author:
author
)
second_t
odo
=
create
(
:todo
,
:assigned
,
user:
john_doe
,
project:
project
,
target:
issue
,
author:
author
)
service
.
new_note
(
note
,
john_doe
)
expect
(
first_t
ask
.
reload
).
to
be_done
expect
(
second_t
ask
.
reload
).
to
be_done
expect
(
first_t
odo
.
reload
).
to
be_done
expect
(
second_t
odo
.
reload
).
to
be_done
end
it
'mark related pending t
ask
s to the noteable for the award note author as done'
do
it
'mark related pending t
odo
s to the noteable for the award note author as done'
do
service
.
new_note
(
award_note
,
john_doe
)
expect
(
first_t
ask
.
reload
).
to
be_done
expect
(
second_t
ask
.
reload
).
to
be_done
expect
(
first_t
odo
.
reload
).
to
be_done
expect
(
second_t
odo
.
reload
).
to
be_done
end
it
'does not mark related pending t
ask
s it is a system note'
do
it
'does not mark related pending t
odo
s it is a system note'
do
service
.
new_note
(
system_note
,
john_doe
)
expect
(
first_t
ask
.
reload
).
to
be_pending
expect
(
second_t
ask
.
reload
).
to
be_pending
expect
(
first_t
odo
.
reload
).
to
be_pending
expect
(
second_t
odo
.
reload
).
to
be_pending
end
it
'creates a t
ask
for each valid mentioned user'
do
it
'creates a t
odo
for each valid mentioned user'
do
service
.
new_note
(
note
,
john_doe
)
should_create_t
ask
(
user:
michael
,
target:
issue
,
author:
john_doe
,
action:
Task
::
MENTIONED
,
note:
note
)
should_create_t
ask
(
user:
author
,
target:
issue
,
author:
john_doe
,
action:
Task
::
MENTIONED
,
note:
note
)
should_not_create_t
ask
(
user:
john_doe
,
target:
issue
,
author:
john_doe
,
action:
Task
::
MENTIONED
,
note:
note
)
should_not_create_t
ask
(
user:
stranger
,
target:
issue
,
author:
john_doe
,
action:
Task
::
MENTIONED
,
note:
note
)
should_create_t
odo
(
user:
michael
,
target:
issue
,
author:
john_doe
,
action:
Todo
::
MENTIONED
,
note:
note
)
should_create_t
odo
(
user:
author
,
target:
issue
,
author:
john_doe
,
action:
Todo
::
MENTIONED
,
note:
note
)
should_not_create_t
odo
(
user:
john_doe
,
target:
issue
,
author:
john_doe
,
action:
Todo
::
MENTIONED
,
note:
note
)
should_not_create_t
odo
(
user:
stranger
,
target:
issue
,
author:
john_doe
,
action:
Todo
::
MENTIONED
,
note:
note
)
end
end
end
...
...
@@ -153,112 +153,112 @@ describe TaskService, services: true do
let
(
:mr_unassigned
)
{
create
(
:merge_request
,
source_project:
project
,
author:
author
,
assignee:
nil
)
}
describe
'#new_merge_request'
do
it
'creates a pending t
ask
if assigned'
do
it
'creates a pending t
odo
if assigned'
do
service
.
new_merge_request
(
mr_assigned
,
author
)
should_create_t
ask
(
user:
john_doe
,
target:
mr_assigned
,
action:
Task
::
ASSIGNED
)
should_create_t
odo
(
user:
john_doe
,
target:
mr_assigned
,
action:
Todo
::
ASSIGNED
)
end
it
'does not create a t
ask
if unassigned'
do
should_not_create_any_t
ask
{
service
.
new_merge_request
(
mr_unassigned
,
author
)
}
it
'does not create a t
odo
if unassigned'
do
should_not_create_any_t
odo
{
service
.
new_merge_request
(
mr_unassigned
,
author
)
}
end
it
'does not create a t
ask
if assignee is the current user'
do
should_not_create_any_t
ask
{
service
.
new_merge_request
(
mr_unassigned
,
john_doe
)
}
it
'does not create a t
odo
if assignee is the current user'
do
should_not_create_any_t
odo
{
service
.
new_merge_request
(
mr_unassigned
,
john_doe
)
}
end
it
'creates a t
ask
for each valid mentioned user'
do
it
'creates a t
odo
for each valid mentioned user'
do
service
.
new_merge_request
(
mr_assigned
,
author
)
should_create_t
ask
(
user:
michael
,
target:
mr_assigned
,
action:
Task
::
MENTIONED
)
should_not_create_t
ask
(
user:
author
,
target:
mr_assigned
,
action:
Task
::
MENTIONED
)
should_not_create_t
ask
(
user:
john_doe
,
target:
mr_assigned
,
action:
Task
::
MENTIONED
)
should_not_create_t
ask
(
user:
stranger
,
target:
mr_assigned
,
action:
Task
::
MENTIONED
)
should_create_t
odo
(
user:
michael
,
target:
mr_assigned
,
action:
Todo
::
MENTIONED
)
should_not_create_t
odo
(
user:
author
,
target:
mr_assigned
,
action:
Todo
::
MENTIONED
)
should_not_create_t
odo
(
user:
john_doe
,
target:
mr_assigned
,
action:
Todo
::
MENTIONED
)
should_not_create_t
odo
(
user:
stranger
,
target:
mr_assigned
,
action:
Todo
::
MENTIONED
)
end
end
describe
'#update_merge_request'
do
it
'creates a t
ask
for each valid mentioned user'
do
it
'creates a t
odo
for each valid mentioned user'
do
service
.
update_merge_request
(
mr_assigned
,
author
)
should_create_t
ask
(
user:
michael
,
target:
mr_assigned
,
action:
Task
::
MENTIONED
)
should_create_t
ask
(
user:
john_doe
,
target:
mr_assigned
,
action:
Task
::
MENTIONED
)
should_not_create_t
ask
(
user:
author
,
target:
mr_assigned
,
action:
Task
::
MENTIONED
)
should_not_create_t
ask
(
user:
stranger
,
target:
mr_assigned
,
action:
Task
::
MENTIONED
)
should_create_t
odo
(
user:
michael
,
target:
mr_assigned
,
action:
Todo
::
MENTIONED
)
should_create_t
odo
(
user:
john_doe
,
target:
mr_assigned
,
action:
Todo
::
MENTIONED
)
should_not_create_t
odo
(
user:
author
,
target:
mr_assigned
,
action:
Todo
::
MENTIONED
)
should_not_create_t
odo
(
user:
stranger
,
target:
mr_assigned
,
action:
Todo
::
MENTIONED
)
end
it
'does not create a t
ask
if user was already mentioned'
do
create
(
:t
ask
,
:mentioned
,
user:
michael
,
project:
project
,
target:
mr_assigned
,
author:
author
)
it
'does not create a t
odo
if user was already mentioned'
do
create
(
:t
odo
,
:mentioned
,
user:
michael
,
project:
project
,
target:
mr_assigned
,
author:
author
)
expect
{
service
.
update_merge_request
(
mr_assigned
,
author
)
}.
not_to
change
(
michael
.
t
ask
s
,
:count
)
expect
{
service
.
update_merge_request
(
mr_assigned
,
author
)
}.
not_to
change
(
michael
.
t
odo
s
,
:count
)
end
end
describe
'#close_merge_request'
do
it
'marks related pending t
ask
s to the target for the user as done'
do
first_t
ask
=
create
(
:task
,
:assigned
,
user:
john_doe
,
project:
project
,
target:
mr_assigned
,
author:
author
)
second_t
ask
=
create
(
:task
,
:assigned
,
user:
john_doe
,
project:
project
,
target:
mr_assigned
,
author:
author
)
it
'marks related pending t
odo
s to the target for the user as done'
do
first_t
odo
=
create
(
:todo
,
:assigned
,
user:
john_doe
,
project:
project
,
target:
mr_assigned
,
author:
author
)
second_t
odo
=
create
(
:todo
,
:assigned
,
user:
john_doe
,
project:
project
,
target:
mr_assigned
,
author:
author
)
service
.
close_merge_request
(
mr_assigned
,
john_doe
)
expect
(
first_t
ask
.
reload
).
to
be_done
expect
(
second_t
ask
.
reload
).
to
be_done
expect
(
first_t
odo
.
reload
).
to
be_done
expect
(
second_t
odo
.
reload
).
to
be_done
end
end
describe
'#reassigned_merge_request'
do
it
'creates a pending t
ask
for new assignee'
do
it
'creates a pending t
odo
for new assignee'
do
mr_unassigned
.
update_attribute
(
:assignee
,
john_doe
)
service
.
reassigned_merge_request
(
mr_unassigned
,
author
)
should_create_t
ask
(
user:
john_doe
,
target:
mr_unassigned
,
action:
Task
::
ASSIGNED
)
should_create_t
odo
(
user:
john_doe
,
target:
mr_unassigned
,
action:
Todo
::
ASSIGNED
)
end
it
'does not create a t
ask
if unassigned'
do
it
'does not create a t
odo
if unassigned'
do
mr_assigned
.
update_attribute
(
:assignee
,
nil
)
should_not_create_any_t
ask
{
service
.
reassigned_merge_request
(
mr_assigned
,
author
)
}
should_not_create_any_t
odo
{
service
.
reassigned_merge_request
(
mr_assigned
,
author
)
}
end
it
'does not create a t
ask
if new assignee is the current user'
do
it
'does not create a t
odo
if new assignee is the current user'
do
mr_assigned
.
update_attribute
(
:assignee
,
john_doe
)
should_not_create_any_t
ask
{
service
.
reassigned_merge_request
(
mr_assigned
,
john_doe
)
}
should_not_create_any_t
odo
{
service
.
reassigned_merge_request
(
mr_assigned
,
john_doe
)
}
end
end
describe
'#merge_merge_request'
do
it
'marks related pending t
ask
s to the target for the user as done'
do
first_t
ask
=
create
(
:task
,
:assigned
,
user:
john_doe
,
project:
project
,
target:
mr_assigned
,
author:
author
)
second_t
ask
=
create
(
:task
,
:assigned
,
user:
john_doe
,
project:
project
,
target:
mr_assigned
,
author:
author
)
it
'marks related pending t
odo
s to the target for the user as done'
do
first_t
odo
=
create
(
:todo
,
:assigned
,
user:
john_doe
,
project:
project
,
target:
mr_assigned
,
author:
author
)
second_t
odo
=
create
(
:todo
,
:assigned
,
user:
john_doe
,
project:
project
,
target:
mr_assigned
,
author:
author
)
service
.
merge_merge_request
(
mr_assigned
,
john_doe
)
expect
(
first_t
ask
.
reload
).
to
be_done
expect
(
second_t
ask
.
reload
).
to
be_done
expect
(
first_t
odo
.
reload
).
to
be_done
expect
(
second_t
odo
.
reload
).
to
be_done
end
end
end
def
should_create_t
ask
(
attributes
=
{})
def
should_create_t
odo
(
attributes
=
{})
attributes
.
reverse_merge!
(
project:
project
,
author:
author
,
state: :pending
)
expect
(
T
ask
.
where
(
attributes
).
count
).
to
eq
1
expect
(
T
odo
.
where
(
attributes
).
count
).
to
eq
1
end
def
should_not_create_t
ask
(
attributes
=
{})
def
should_not_create_t
odo
(
attributes
=
{})
attributes
.
reverse_merge!
(
project:
project
,
author:
author
,
state: :pending
)
expect
(
T
ask
.
where
(
attributes
).
count
).
to
eq
0
expect
(
T
odo
.
where
(
attributes
).
count
).
to
eq
0
end
def
should_not_create_any_t
ask
expect
{
yield
}.
not_to
change
(
T
ask
,
:count
)
def
should_not_create_any_t
odo
expect
{
yield
}.
not_to
change
(
T
odo
,
:count
)
end
end
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录