diff options
author | Kasper Timm Hansen <kaspth@gmail.com> | 2018-12-12 15:30:44 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-12-12 15:30:44 +0100 |
commit | 0fc6804c7e385140976520fd4d1a269eb735160b (patch) | |
tree | 54d8cd9d085528674ce4a2df2f6f4517f0041285 /actioncable/test | |
parent | 7d83ef4f7bd9e5766ebdb438370621a98be06a7c (diff) | |
parent | 87f407db3ebac3dfaf53e19590e8707bd0183496 (diff) | |
download | rails-0fc6804c7e385140976520fd4d1a269eb735160b.tar.gz rails-0fc6804c7e385140976520fd4d1a269eb735160b.tar.bz2 rails-0fc6804c7e385140976520fd4d1a269eb735160b.zip |
Merge pull request #34686 from got2be/actioncable-channel-rescuable
Add Missing ActiveSupport::Rescuable to ActionCable::Channel
Diffstat (limited to 'actioncable/test')
-rw-r--r-- | actioncable/test/channel/base_test.rb | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/actioncable/test/channel/base_test.rb b/actioncable/test/channel/base_test.rb index eb0e1673b0..c2968226c7 100644 --- a/actioncable/test/channel/base_test.rb +++ b/actioncable/test/channel/base_test.rb @@ -26,6 +26,9 @@ class ActionCable::Channel::BaseTest < ActionCable::TestCase 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 @@ class ActionCable::Channel::BaseTest < ActionCable::TestCase @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 @@ class ActionCable::Channel::BaseTest < ActionCable::TestCase 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 @@ class ActionCable::Channel::BaseTest < ActionCable::TestCase 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 |