Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
3acbbb1a
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 搜索 >>
未验证
提交
3acbbb1a
编写于
10月 09, 2017
作者:
R
Rémy Coutable
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Don't show an "Unsubscribe" link in snippet comment notifications
Signed-off-by:
N
Rémy Coutable
<
remy@rymai.me
>
上级
f277fa14
变更
4
展开全部
隐藏空白更改
内联
并排
Showing
4 changed file
with
390 addition
and
234 deletion
+390
-234
app/models/sent_notification.rb
app/models/sent_notification.rb
+5
-1
changelogs/unreleased/23888-fix-unsubscription-link-for-snippet-notification.yml
...3888-fix-unsubscription-link-for-snippet-notification.yml
+5
-0
spec/mailers/notify_spec.rb
spec/mailers/notify_spec.rb
+260
-231
spec/models/sent_notification_spec.rb
spec/models/sent_notification_spec.rb
+120
-2
未找到文件。
app/models/sent_notification.rb
浏览文件 @
3acbbb1a
...
...
@@ -53,13 +53,17 @@ class SentNotification < ActiveRecord::Base
end
def
unsubscribable?
!
for_commit?
!
(
for_commit?
||
for_snippet?
)
end
def
for_commit?
noteable_type
==
"Commit"
end
def
for_snippet?
noteable_type
.
end_with?
(
'Snippet'
)
end
def
noteable
if
for_commit?
project
.
commit
(
commit_id
)
rescue
nil
...
...
changelogs/unreleased/23888-fix-unsubscription-link-for-snippet-notification.yml
0 → 100644
浏览文件 @
3acbbb1a
---
title
:
Don't show an "Unsubscribe" link in snippet comment notifications
merge_request
:
14764
author
:
type
:
fixed
spec/mailers/notify_spec.rb
浏览文件 @
3acbbb1a
此差异已折叠。
点击以展开。
spec/models/sent_notification_spec.rb
浏览文件 @
3acbbb1a
require
'spec_helper'
describe
SentNotification
do
set
(
:user
)
{
create
(
:user
)
}
set
(
:project
)
{
create
(
:project
)
}
describe
'validation'
do
describe
'note validity'
do
context
"when the project doesn't match the noteable's project"
do
...
...
@@ -34,7 +37,6 @@ describe SentNotification do
end
describe
'.record'
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:issue
)
{
create
(
:issue
)
}
it
'creates a new SentNotification'
do
...
...
@@ -43,7 +45,6 @@ describe SentNotification do
end
describe
'.record_note'
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:note
)
{
create
(
:diff_note_on_merge_request
)
}
it
'creates a new SentNotification'
do
...
...
@@ -51,6 +52,123 @@ describe SentNotification do
end
end
describe
'#unsubscribable?'
do
shared_examples
'an unsubscribable notification'
do
|
noteable_type
|
subject
{
described_class
.
record
(
noteable
,
user
.
id
)
}
context
"for
#{
noteable_type
}
"
do
it
{
expect
(
subject
).
to
be_unsubscribable
}
end
end
shared_examples
'a non-unsubscribable notification'
do
|
noteable_type
|
subject
{
described_class
.
record
(
noteable
,
user
.
id
)
}
context
"for a
#{
noteable_type
}
"
do
it
{
expect
(
subject
).
not_to
be_unsubscribable
}
end
end
it_behaves_like
'an unsubscribable notification'
,
'issue'
do
let
(
:noteable
)
{
create
(
:issue
,
project:
project
)
}
end
it_behaves_like
'an unsubscribable notification'
,
'merge request'
do
let
(
:noteable
)
{
create
(
:merge_request
,
source_project:
project
)
}
end
it_behaves_like
'a non-unsubscribable notification'
,
'commit'
do
let
(
:project
)
{
create
(
:project
,
:repository
)
}
let
(
:noteable
)
{
project
.
commit
}
end
it_behaves_like
'a non-unsubscribable notification'
,
'personal snippet'
do
let
(
:noteable
)
{
create
(
:personal_snippet
,
project:
project
)
}
end
it_behaves_like
'a non-unsubscribable notification'
,
'project snippet'
do
let
(
:noteable
)
{
create
(
:project_snippet
,
project:
project
)
}
end
end
describe
'#for_commit?'
do
shared_examples
'a commit notification'
do
|
noteable_type
|
subject
{
described_class
.
record
(
noteable
,
user
.
id
)
}
context
"for
#{
noteable_type
}
"
do
it
{
expect
(
subject
).
to
be_for_commit
}
end
end
shared_examples
'a non-commit notification'
do
|
noteable_type
|
subject
{
described_class
.
record
(
noteable
,
user
.
id
)
}
context
"for a
#{
noteable_type
}
"
do
it
{
expect
(
subject
).
not_to
be_for_commit
}
end
end
it_behaves_like
'a non-commit notification'
,
'issue'
do
let
(
:noteable
)
{
create
(
:issue
,
project:
project
)
}
end
it_behaves_like
'a non-commit notification'
,
'merge request'
do
let
(
:noteable
)
{
create
(
:merge_request
,
source_project:
project
)
}
end
it_behaves_like
'a commit notification'
,
'commit'
do
let
(
:project
)
{
create
(
:project
,
:repository
)
}
let
(
:noteable
)
{
project
.
commit
}
end
it_behaves_like
'a non-commit notification'
,
'personal snippet'
do
let
(
:noteable
)
{
create
(
:personal_snippet
,
project:
project
)
}
end
it_behaves_like
'a non-commit notification'
,
'project snippet'
do
let
(
:noteable
)
{
create
(
:project_snippet
,
project:
project
)
}
end
end
describe
'#for_snippet?'
do
shared_examples
'a snippet notification'
do
|
noteable_type
|
subject
{
described_class
.
record
(
noteable
,
user
.
id
)
}
context
"for
#{
noteable_type
}
"
do
it
{
expect
(
subject
).
to
be_for_snippet
}
end
end
shared_examples
'a non-snippet notification'
do
|
noteable_type
|
subject
{
described_class
.
record
(
noteable
,
user
.
id
)
}
context
"for a
#{
noteable_type
}
"
do
it
{
expect
(
subject
).
not_to
be_for_snippet
}
end
end
it_behaves_like
'a non-snippet notification'
,
'issue'
do
let
(
:noteable
)
{
create
(
:issue
,
project:
project
)
}
end
it_behaves_like
'a non-snippet notification'
,
'merge request'
do
let
(
:noteable
)
{
create
(
:merge_request
,
source_project:
project
)
}
end
it_behaves_like
'a non-snippet notification'
,
'commit'
do
let
(
:project
)
{
create
(
:project
,
:repository
)
}
let
(
:noteable
)
{
project
.
commit
}
end
it_behaves_like
'a snippet notification'
,
'personal snippet'
do
let
(
:noteable
)
{
create
(
:personal_snippet
,
project:
project
)
}
end
it_behaves_like
'a snippet notification'
,
'project snippet'
do
let
(
:noteable
)
{
create
(
:project_snippet
,
project:
project
)
}
end
end
describe
'#create_reply'
do
context
'for issue'
do
let
(
:issue
)
{
create
(
:issue
)
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录