Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
87f407db
R
rails
项目概览
张重言
/
rails
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
rails
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
87f407db
编写于
12月 12, 2018
作者:
I
Ilia Kasianenko
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add Missing ActiveSupport::Rescuable to ActionCable::Channel
[timthez, Ilia Kasianenko]
上级
c4f37cc8
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
21 addition
and
1 deletion
+21
-1
actioncable/lib/action_cable/channel/base.rb
actioncable/lib/action_cable/channel/base.rb
+4
-0
actioncable/test/channel/base_test.rb
actioncable/test/channel/base_test.rb
+17
-1
未找到文件。
actioncable/lib/action_cable/channel/base.rb
浏览文件 @
87f407db
# frozen_string_literal: true
require
"set"
require
"active_support/rescuable"
module
ActionCable
module
Channel
...
...
@@ -99,6 +100,7 @@ class Base
include
Streams
include
Naming
include
Broadcasting
include
ActiveSupport
::
Rescuable
attr_reader
:params
,
:connection
,
:identifier
delegate
:logger
,
to: :connection
...
...
@@ -267,6 +269,8 @@ def dispatch_action(action, data)
else
public_send
action
end
rescue
Exception
=>
exception
rescue_with_handler
(
exception
)
||
raise
end
def
action_signature
(
action
,
data
)
...
...
actioncable/test/channel/base_test.rb
浏览文件 @
87f407db
...
...
@@ -26,6 +26,9 @@ class ChatChannel < BasicChannel
after_subscribe
:toggle_subscribed
after_unsubscribe
:toggle_subscribed
class
SomeCustomError
<
StandardError
;
end
rescue_from
SomeCustomError
,
with: :error_handler
def
initialize
(
*
)
@subscribed
=
false
super
...
...
@@ -68,10 +71,18 @@ def receive
@last_action
=
[
:receive
]
end
def
error_action
raise
SomeCustomError
end
private
def
rm_rf
@last_action
=
[
:rm_rf
]
end
def
error_handler
@last_action
=
[
:error_action
]
end
end
setup
do
...
...
@@ -168,7 +179,7 @@ def rm_rf
end
test
"actions available on Channel"
do
available_actions
=
%w(room last_action subscribed unsubscribed toggle_subscribed leave speak subscribed? get_latest receive chatters topic)
.
to_set
available_actions
=
%w(room last_action subscribed unsubscribed toggle_subscribed leave speak subscribed? get_latest receive chatters topic
error_action
)
.
to_set
assert_equal
available_actions
,
ChatChannel
.
action_methods
end
...
...
@@ -256,6 +267,11 @@ def rm_rf
end
end
test
"behaves like rescuable"
do
@channel
.
perform_action
"action"
=>
:error_action
assert_equal
[
:error_action
],
@channel
.
last_action
end
private
def
assert_logged
(
message
)
old_logger
=
@connection
.
logger
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录