Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
b7dff1b0
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 搜索 >>
提交
b7dff1b0
编写于
11月 03, 2016
作者:
V
Valery Sizov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix: Todos Filter Shows All Users
上级
5ef2bd19
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
74 addition
and
10 deletion
+74
-10
app/assets/javascripts/users_select.js
app/assets/javascripts/users_select.js
+4
-0
app/controllers/autocomplete_controller.rb
app/controllers/autocomplete_controller.rb
+5
-1
app/models/user.rb
app/models/user.rb
+1
-0
app/views/dashboard/todos/index.html.haml
app/views/dashboard/todos/index.html.haml
+1
-1
changelogs/unreleased/22588-todos-filter-shows-all-users.yml
changelogs/unreleased/22588-todos-filter-shows-all-users.yml
+4
-0
spec/features/todos/todos_filtering_spec.rb
spec/features/todos/todos_filtering_spec.rb
+45
-8
spec/models/user_spec.rb
spec/models/user_spec.rb
+14
-0
未找到文件。
app/assets/javascripts/users_select.js
浏览文件 @
b7dff1b0
...
...
@@ -23,6 +23,8 @@
$dropdown
=
$
(
dropdown
);
options
.
projectId
=
$dropdown
.
data
(
'
project-id
'
);
options
.
showCurrentUser
=
$dropdown
.
data
(
'
current-user
'
);
options
.
todoFilter
=
$dropdown
.
data
(
'
todo-filter
'
);
options
.
todoStateFilter
=
$dropdown
.
data
(
'
todo-state-filter
'
);
showNullUser
=
$dropdown
.
data
(
'
null-user
'
);
showMenuAbove
=
$dropdown
.
data
(
'
showMenuAbove
'
);
showAnyUser
=
$dropdown
.
data
(
'
any-user
'
);
...
...
@@ -394,6 +396,8 @@
project_id
:
options
.
projectId
||
null
,
group_id
:
options
.
groupId
||
null
,
skip_ldap
:
options
.
skipLdap
||
null
,
todo_filter
:
options
.
todoFilter
||
null
,
todo_state_filter
:
options
.
todoStateFilter
||
null
,
current_user
:
options
.
showCurrentUser
||
null
,
push_code_to_protected_branches
:
options
.
pushCodeToProtectedBranches
||
null
,
author_id
:
options
.
authorId
||
null
,
...
...
app/controllers/autocomplete_controller.rb
浏览文件 @
b7dff1b0
...
...
@@ -11,9 +11,13 @@ class AutocompleteController < ApplicationController
@users
=
@users
.
reorder
(
:name
)
@users
=
@users
.
page
(
params
[
:page
])
if
params
[
:todo_filter
].
present?
@users
=
@users
.
todo_authors
(
current_user
.
id
,
params
[
:todo_state_filter
])
end
if
params
[
:search
].
blank?
# Include current user if available to filter by "Me"
if
params
[
:current_user
]
&&
current_user
if
params
[
:current_user
]
.
present?
&&
current_user
@users
=
[
*
@users
,
current_user
]
end
...
...
app/models/user.rb
浏览文件 @
b7dff1b0
...
...
@@ -173,6 +173,7 @@ class User < ActiveRecord::Base
scope
:active
,
->
{
with_state
(
:active
)
}
scope
:not_in_project
,
->
(
project
)
{
project
.
users
.
present?
?
where
(
"id not in (:ids)"
,
ids:
project
.
users
.
map
(
&
:id
)
)
:
all
}
scope
:without_projects
,
->
{
where
(
'id NOT IN (SELECT DISTINCT(user_id) FROM members)'
)
}
scope
:todo_authors
,
->
(
user_id
,
state
)
{
where
(
id:
Todo
.
where
(
user_id:
user_id
,
state:
state
).
select
(
:author_id
))
}
def
self
.
with_two_factor
joins
(
"LEFT OUTER JOIN u2f_registrations AS u2f ON u2f.user_id = users.id"
).
...
...
app/views/dashboard/todos/index.html.haml
浏览文件 @
b7dff1b0
...
...
@@ -37,7 +37,7 @@
-
if
params
[
:author_id
].
present?
=
hidden_field_tag
(
:author_id
,
params
[
:author_id
])
=
dropdown_tag
(
user_dropdown_label
(
params
[
:author_id
],
'Author'
),
options:
{
toggle_class:
'js-user-search js-filter-submit js-author-search'
,
title:
'Filter by author'
,
filter:
true
,
filterInput:
'input#author-search'
,
dropdown_class:
'dropdown-menu-user dropdown-menu-selectable dropdown-menu-author js-filter-submit'
,
placeholder:
'Search authors'
,
data:
{
any_user:
'Any Author'
,
first_user:
(
current_user
.
username
if
current_user
),
current_user:
true
,
project_id:
(
@project
.
id
if
@project
),
selected:
params
[
:author_id
],
field_name:
'author_id'
,
default_label:
'Author
'
}
})
placeholder:
'Search authors'
,
data:
{
any_user:
'Any Author'
,
first_user:
(
current_user
.
username
if
current_user
),
project_id:
(
@project
.
id
if
@project
),
selected:
params
[
:author_id
],
field_name:
'author_id'
,
default_label:
'Author'
,
todo_filter:
true
,
todo_state_filter:
params
[
:state
]
||
'pending
'
}
})
.filter-item.inline
-
if
params
[
:type
].
present?
=
hidden_field_tag
(
:type
,
params
[
:type
])
...
...
changelogs/unreleased/22588-todos-filter-shows-all-users.yml
0 → 100644
浏览文件 @
b7dff1b0
---
title
:
'
Fix:
Todos
Filter
Shows
All
Users'
merge_request
:
author
:
spec/features/todos/todos_filtering_spec.rb
浏览文件 @
b7dff1b0
...
...
@@ -36,17 +36,54 @@ describe 'Dashboard > User filters todos', feature: true, js: true do
expect
(
page
).
not_to
have_content
project_2
.
name_with_namespace
end
it
'filters by author'
do
click_button
'Author'
within
'.dropdown-menu-author'
do
fill_in
'Search authors'
,
with:
user_1
.
name
click_link
user_1
.
name
context
"Author filter"
do
it
'filters by author'
do
click_button
'Author'
within
'.dropdown-menu-author'
do
fill_in
'Search authors'
,
with:
user_1
.
name
click_link
user_1
.
name
end
wait_for_ajax
expect
(
find
(
'.todos-list'
)).
to
have_content
user_1
.
name
expect
(
find
(
'.todos-list'
)).
not_to
have_content
user_2
.
name
end
wait_for_ajax
it
"shows only authors of existing todos"
do
click_button
'Author'
within
'.dropdown-menu-author'
do
# It should contain two users + "Any Author"
expect
(
page
).
to
have_selector
(
'.dropdown-menu-user-link'
,
count:
3
)
expect
(
page
).
to
have_content
(
user_1
.
name
)
expect
(
page
).
to
have_content
(
user_2
.
name
)
end
end
expect
(
find
(
'.todos-list'
)).
to
have_content
user_1
.
name
expect
(
find
(
'.todos-list'
)).
not_to
have_content
user_2
.
name
it
"shows only authors of existing done todos"
do
user_3
=
create
:user
user_4
=
create
:user
create
(
:todo
,
user:
user_1
,
author:
user_3
,
project:
project_1
,
target:
issue
,
action:
1
,
state: :done
)
create
(
:todo
,
user:
user_1
,
author:
user_4
,
project:
project_2
,
target:
merge_request
,
action:
2
,
state: :done
)
project_1
.
team
<<
[
user_3
,
:developer
]
project_2
.
team
<<
[
user_4
,
:developer
]
visit
dashboard_todos_path
(
state:
'done'
)
click_button
'Author'
within
'.dropdown-menu-author'
do
# It should contain two users + "Any Author"
expect
(
page
).
to
have_selector
(
'.dropdown-menu-user-link'
,
count:
3
)
expect
(
page
).
to
have_content
(
user_3
.
name
)
expect
(
page
).
to
have_content
(
user_4
.
name
)
expect
(
page
).
not_to
have_content
(
user_1
.
name
)
expect
(
page
).
not_to
have_content
(
user_2
.
name
)
end
end
end
it
'filters by type'
do
...
...
spec/models/user_spec.rb
浏览文件 @
b7dff1b0
...
...
@@ -256,6 +256,20 @@ describe User, models: true do
expect
(
users_without_two_factor
).
not_to
include
(
user_with_2fa
.
id
)
end
end
describe
'.todo_authors'
do
it
'filters users'
do
create
:user
user_2
=
create
:user
user_3
=
create
:user
current_user
=
create
:user
create
(
:todo
,
user:
current_user
,
author:
user_2
,
state: :done
)
create
(
:todo
,
user:
current_user
,
author:
user_3
,
state: :pending
)
expect
(
User
.
todo_authors
(
current_user
.
id
,
'pending'
)).
to
eq
[
user_3
]
expect
(
User
.
todo_authors
(
current_user
.
id
,
'done'
)).
to
eq
[
user_2
]
end
end
end
describe
"Respond to"
do
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录