Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
c61a54f7
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,发现更多精彩内容 >>
提交
c61a54f7
编写于
9月 16, 2016
作者:
R
Rémy Coutable
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix initial implementation to actually render the unsubscribe page
Signed-off-by:
N
Rémy Coutable
<
remy@rymai.me
>
上级
b3357308
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
54 addition
and
13 deletion
+54
-13
app/controllers/sent_notifications_controller.rb
app/controllers/sent_notifications_controller.rb
+5
-2
app/views/sent_notifications/unsubscribe.html.haml
app/views/sent_notifications/unsubscribe.html.haml
+14
-3
spec/controllers/sent_notifications_controller_spec.rb
spec/controllers/sent_notifications_controller_spec.rb
+10
-4
spec/features/unsubscribe_links_spec.rb
spec/features/unsubscribe_links_spec.rb
+25
-4
未找到文件。
app/controllers/sent_notifications_controller.rb
浏览文件 @
c61a54f7
...
...
@@ -2,12 +2,15 @@ class SentNotificationsController < ApplicationController
skip_before_action
:authenticate_user!
def
unsubscribe
return
redirect_to
new_user_session_path
unless
current_user
||
params
[
:force
]
@sent_notification
=
SentNotification
.
for
(
params
[
:id
])
return
render_404
unless
@sent_notification
&&
@sent_notification
.
unsubscribable?
return
unsubscribe_and_redirect
if
current_user
||
params
[
:force
]
end
private
def
unsubscribe_and_redirect
noteable
=
@sent_notification
.
noteable
noteable
.
unsubscribe
(
@sent_notification
.
recipient
)
...
...
app/views/sent_notifications/unsubscribe.html.haml
浏览文件 @
c61a54f7
%h3
.page-title
Are you sure you want to unsubscribe from this thread?
-
noteable
=
@sent_notification
.
noteable
-
noteable_type
=
@sent_notification
.
noteable_type
.
humanize
(
capitalize:
false
)
-
noteable_text
=
%(#{noteable_type} "#{noteable.title}" (#{noteable.to_reference}))
-
title
=
"Unsubscribe from
#{
noteable_text
}
"
=
link_to
"Unsubscribe"
,
unsubscribe_sent_notification_path
(
@sent_notification
,
force:
true
),
class:
'btn btn-primary wide'
-
page_title
title
%h3
.page-title
=
title
%p
=
"Are you sure you want to unsubscribe from
#{
noteable_text
}
?"
%p
=
link_to
'Unsubscribe'
,
unsubscribe_sent_notification_path
(
@sent_notification
,
force:
true
),
class:
'btn btn-primary append-right-10'
=
link_to
'Cancel'
,
new_user_session_path
,
class:
'btn append-right-10'
spec/controllers/sent_notifications_controller_spec.rb
浏览文件 @
c61a54f7
...
...
@@ -41,7 +41,7 @@ describe SentNotificationsController, type: :controller do
end
it
'redirects to the login page'
do
expect
(
response
).
to
re
direct_to
(
new_user_session_path
)
expect
(
response
).
to
re
nder_template
:unsubscribe
end
end
end
...
...
@@ -83,19 +83,25 @@ describe SentNotificationsController, type: :controller do
end
context
'when the force param is not passed'
do
let
(
:merge_request
)
do
create
(
:merge_request
,
source_project:
project
,
author:
user
)
do
|
merge_request
|
merge_request
.
subscriptions
.
create
(
user:
user
,
subscribed:
true
)
end
end
let
(
:sent_notification
)
{
create
(
:sent_notification
,
noteable:
merge_request
,
recipient:
user
)
}
before
{
get
(
:unsubscribe
,
id:
sent_notification
.
reply_key
)
}
it
'unsubscribes the user'
do
expect
(
issue
.
subscribed?
(
user
)).
to
be_falsey
expect
(
merge_request
.
subscribed?
(
user
)).
to
be_falsey
end
it
'sets the flash message'
do
expect
(
controller
).
to
set_flash
[
:notice
].
to
(
/unsubscribed/
).
now
end
it
'redirects to the
issue
page'
do
it
'redirects to the
merge request
page'
do
expect
(
response
).
to
redirect_to
(
namespace_project_
issue_path
(
project
.
namespace
,
project
,
issue
))
to
redirect_to
(
namespace_project_
merge_request_path
(
project
.
namespace
,
project
,
merge_request
))
end
end
end
...
...
spec/features/unsubscribe_links_spec.rb
浏览文件 @
c61a54f7
...
...
@@ -19,11 +19,32 @@ describe 'Unsubscribe links', feature: true do
end
context
'when logged out'
do
it
'redirects to the login page when visiting the link from the body'
do
visit
body_link
context
'when visiting the link from the body'
do
it
'shows the unsubscribe confirmation page and redirects to root path when confirming'
do
visit
body_link
expect
(
current_path
).
to
eq
unsubscribe_sent_notification_path
(
SentNotification
.
last
)
expect
(
page
).
to
have_text
(
%(Unsubscribe from issue "#{issue.title}" (#{issue.to_reference}))
)
expect
(
page
).
to
have_text
(
%(Are you sure you want to unsubscribe from issue "#{issue.title}" (#{issue.to_reference})?)
)
expect
(
issue
.
subscribed?
(
recipient
)).
to
be_truthy
click_link
'Unsubscribe'
expect
(
issue
.
subscribed?
(
recipient
)).
to
be_falsey
expect
(
current_path
).
to
eq
new_user_session_path
end
it
'shows the unsubscribe confirmation page and redirects to root path when canceling'
do
visit
body_link
expect
(
current_path
).
to
eq
unsubscribe_sent_notification_path
(
SentNotification
.
last
)
expect
(
issue
.
subscribed?
(
recipient
)).
to
be_truthy
click_link
'Cancel'
expect
(
current_path
).
to
eq
new_user_session_path
expect
(
issue
.
subscribed?
(
recipient
)).
to
be_truthy
expect
(
issue
.
subscribed?
(
recipient
)).
to
be_truthy
expect
(
current_path
).
to
eq
new_user_session_path
end
end
it
'unsubscribes from the issue when visiting the link from the header'
do
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录