From 46adddbfb55c9d7305c8e7b08a1fee22f5cfcebb Mon Sep 17 00:00:00 2001 From: Akshay Vishnoi Date: Fri, 18 Dec 2015 21:09:38 +0530 Subject: [ActionCable] Test invalid action on channel --- actioncable/test/channel/base_test.rb | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'actioncable') diff --git a/actioncable/test/channel/base_test.rb b/actioncable/test/channel/base_test.rb index ec19d7de8e..fce1987d42 100644 --- a/actioncable/test/channel/base_test.rb +++ b/actioncable/test/channel/base_test.rb @@ -159,4 +159,26 @@ class ActionCable::Channel::BaseTest < ActiveSupport::TestCase available_actions = %w(room last_action subscribed unsubscribed toggle_subscribed leave speak subscribed? get_latest receive chatters topic).to_set assert_equal available_actions, ChatChannel.action_methods end + + test "invalid action on Channel" do + assert_logged("Unable to process ActionCable::Channel::BaseTest::ChatChannel#invalid_action") do + @channel.perform_action 'action' => :invalid_action + end + end + + def assert_logged(message) + old_logger = @connection.logger + log = StringIO.new + @connection.instance_variable_set(:@logger, Logger.new(log)) + + begin + yield + + log.rewind + assert_match message, log.read + ensure + @connection.instance_variable_set(:@logger, old_logger) + end + end + end -- cgit v1.2.3