Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
6fb9bf87
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,发现更多精彩内容 >>
提交
6fb9bf87
编写于
5月 19, 2016
作者:
F
Felipe Artur
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Use the right default notification settings for non members
上级
fc9844e8
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
12 addition
and
23 deletion
+12
-23
app/models/user.rb
app/models/user.rb
+1
-7
spec/controllers/projects_controller_spec.rb
spec/controllers/projects_controller_spec.rb
+4
-3
spec/services/merge_requests/update_service_spec.rb
spec/services/merge_requests/update_service_spec.rb
+0
-1
spec/services/notification_service_spec.rb
spec/services/notification_service_spec.rb
+7
-12
未找到文件。
app/models/user.rb
浏览文件 @
6fb9bf87
...
...
@@ -777,13 +777,7 @@ class User < ActiveRecord::Base
end
def
notification_settings_for
(
source
)
notification_setting
=
notification_settings
.
find_or_initialize_by
(
source:
source
)
if
source
.
is_a?
(
Project
)
&&
!
source
.
team
.
member?
(
id
)
&&
!
notification_setting
.
persisted?
notification_setting
.
level
=
:disabled
end
notification_setting
notification_settings
.
find_or_initialize_by
(
source:
source
)
end
private
...
...
spec/controllers/projects_controller_spec.rb
浏览文件 @
6fb9bf87
...
...
@@ -24,20 +24,20 @@ describe ProjectsController do
context
"and does not have notification setting"
do
it
"initializes notification as disabled"
do
get
:show
,
namespace_id:
public_project
.
namespace
.
path
,
id:
public_project
.
path
expect
(
assigns
(
:notification_setting
).
level
).
to
eq
(
"
disabled
"
)
expect
(
assigns
(
:notification_setting
).
level
).
to
eq
(
"
global
"
)
end
end
context
"and has notification setting"
do
before
do
setting
=
user
.
notification_settings_for
(
public_project
)
setting
.
level
=
:
global
setting
.
level
=
:
watch
setting
.
save
end
it
"shows current notification setting"
do
get
:show
,
namespace_id:
public_project
.
namespace
.
path
,
id:
public_project
.
path
expect
(
assigns
(
:notification_setting
).
level
).
to
eq
(
"
global
"
)
expect
(
assigns
(
:notification_setting
).
level
).
to
eq
(
"
watch
"
)
end
end
end
...
...
@@ -45,6 +45,7 @@ describe ProjectsController do
context
"rendering default project view"
do
render_views
it
"renders the activity view"
do
allow
(
controller
).
to
receive
(
:current_user
).
and_return
(
user
)
allow
(
user
).
to
receive
(
:project_view
).
and_return
(
'activity'
)
...
...
spec/services/merge_requests/update_service_spec.rb
浏览文件 @
6fb9bf87
...
...
@@ -17,7 +17,6 @@ describe MergeRequests::UpdateService, services: true do
before
do
project
.
team
<<
[
user
,
:master
]
project
.
team
<<
[
user2
,
:developer
]
project
.
team
<<
[
user3
,
:developer
]
end
describe
'execute'
do
...
...
spec/services/notification_service_spec.rb
浏览文件 @
6fb9bf87
...
...
@@ -35,7 +35,7 @@ describe NotificationService, services: true do
describe
'Notes'
do
context
'issue note'
do
let
(
:project
)
{
create
(
:empty_project
,
:
internal
)
}
let
(
:project
)
{
create
(
:empty_project
,
:
private
)
}
let
(
:issue
)
{
create
(
:issue
,
project:
project
,
assignee:
create
(
:user
))
}
let
(
:mentioned_issue
)
{
create
(
:issue
,
assignee:
issue
.
assignee
)
}
let
(
:note
)
{
create
(
:note_on_issue
,
noteable:
issue
,
project_id:
issue
.
project_id
,
note:
'@mention referenced, @outsider also'
)
}
...
...
@@ -52,8 +52,8 @@ describe NotificationService, services: true do
it
do
add_users_with_subscription
(
note
.
project
,
issue
)
# Ensure create SentNotification by noteable = issue
7
times, not noteable = note
expect
(
SentNotification
).
to
receive
(
:record
).
with
(
issue
,
any_args
).
exactly
(
8
).
times
# Ensure create SentNotification by noteable = issue
6
times, not noteable = note
expect
(
SentNotification
).
to
receive
(
:record
).
with
(
issue
,
any_args
).
exactly
(
7
).
times
ActionMailer
::
Base
.
deliveries
.
clear
...
...
@@ -66,7 +66,7 @@ describe NotificationService, services: true do
should_email
(
@subscriber
)
should_email
(
@watcher_and_subscriber
)
should_email
(
@subscribed_participant
)
should_email
(
@u_guest_watcher
)
should_
not_
email
(
@u_guest_watcher
)
should_not_email
(
note
.
author
)
should_not_email
(
@u_participating
)
should_not_email
(
@u_disabled
)
...
...
@@ -101,7 +101,7 @@ describe NotificationService, services: true do
should_email
(
note
.
noteable
.
author
)
should_email
(
note
.
noteable
.
assignee
)
should_email
(
@u_mentioned
)
should_email
(
@u_guest_watcher
)
should_
not_
email
(
@u_guest_watcher
)
should_not_email
(
@u_watcher
)
should_not_email
(
note
.
author
)
should_not_email
(
@u_participating
)
...
...
@@ -121,10 +121,7 @@ describe NotificationService, services: true do
let
(
:note
)
{
create
(
:note_on_issue
,
noteable:
confidential_issue
,
project:
project
,
note:
"
#{
author
.
to_reference
}
#{
assignee
.
to_reference
}
#{
non_member
.
to_reference
}
#{
member
.
to_reference
}
#{
admin
.
to_reference
}
"
)
}
it
'filters out users that can not read the issue'
do
project
.
team
<<
[
admin
,
:master
]
project
.
team
<<
[
author
,
:developer
]
project
.
team
<<
[
member
,
:developer
]
project
.
team
<<
[
assignee
,
:developer
]
expect
(
SentNotification
).
to
receive
(
:record
).
with
(
confidential_issue
,
any_args
).
exactly
(
4
).
times
...
...
@@ -148,7 +145,7 @@ describe NotificationService, services: true do
before
do
build_team
(
note
.
project
)
note
.
project
.
team
<<
[
[
note
.
author
,
note
.
noteable
.
author
,
note
.
noteable
.
assignee
]
,
:master
]
note
.
project
.
team
<<
[
note
.
author
,
:master
]
ActionMailer
::
Base
.
deliveries
.
clear
end
...
...
@@ -190,7 +187,7 @@ describe NotificationService, services: true do
before
do
build_team
(
note
.
project
)
note
.
project
.
team
<<
[
[
note
.
author
,
note
.
noteable
.
author
]
,
:master
]
note
.
project
.
team
<<
[
note
.
author
,
:master
]
ActionMailer
::
Base
.
deliveries
.
clear
end
...
...
@@ -269,7 +266,6 @@ describe NotificationService, services: true do
before
do
build_team
(
issue
.
project
)
add_users_with_subscription
(
issue
.
project
,
issue
)
project
.
team
<<
[[
issue
.
assignee
,
issue
.
author
],
:developer
]
ActionMailer
::
Base
.
deliveries
.
clear
end
...
...
@@ -510,7 +506,6 @@ describe NotificationService, services: true do
before
do
build_team
(
merge_request
.
target_project
)
add_users_with_subscription
(
merge_request
.
target_project
,
merge_request
)
project
.
team
<<
[
merge_request
.
assignee
,
:developer
]
ActionMailer
::
Base
.
deliveries
.
clear
end
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录