aboutsummaryrefslogtreecommitdiffstats
path: root/actioncable/test
diff options
context:
space:
mode:
authorJon Moss <me@jonathanmoss.me>2016-02-18 12:31:04 -0500
committerJon Moss <me@jonathanmoss.me>2016-08-19 13:00:39 -0400
commit831e2c8d1bf13cd944f5683980cfe95f59db2ae8 (patch)
treef77ecf4e47ac7da4fe55e40b99ce228892c2faee /actioncable/test
parentc1d612cf5a9d25133ab50cc057ebb35d337e37fa (diff)
downloadrails-831e2c8d1bf13cd944f5683980cfe95f59db2ae8.tar.gz
rails-831e2c8d1bf13cd944f5683980cfe95f59db2ae8.tar.bz2
rails-831e2c8d1bf13cd944f5683980cfe95f59db2ae8.zip
Prevent invocation of channel action if rejected connection
Fixes #23757. Before this commit, even if `reject` was called in the `subscribe` method for an Action Cable channel, all actions on that channel could still be invoked. This calls a `return` if a rejected connection tries to invoke any actions on the channel.
Diffstat (limited to 'actioncable/test')
-rw-r--r--actioncable/test/channel/rejection_test.rb15
1 files changed, 15 insertions, 0 deletions
diff --git a/actioncable/test/channel/rejection_test.rb b/actioncable/test/channel/rejection_test.rb
index 0d2ac1c129..faf35ad048 100644
--- a/actioncable/test/channel/rejection_test.rb
+++ b/actioncable/test/channel/rejection_test.rb
@@ -7,6 +7,9 @@ class ActionCable::Channel::RejectionTest < ActiveSupport::TestCase
def subscribed
reject if params[:id] > 0
end
+
+ def secret_action
+ end
end
setup do
@@ -21,4 +24,16 @@ class ActionCable::Channel::RejectionTest < ActiveSupport::TestCase
expected = { "identifier" => "{id: 1}", "type" => "reject_subscription" }
assert_equal expected, @connection.last_transmission
end
+
+ test "does not execute action if subscription is rejected" do
+ @connection.expects(:subscriptions).returns mock().tap { |m| m.expects(:remove_subscription).with instance_of(SecretChannel) }
+ @channel = SecretChannel.new @connection, "{id: 1}", id: 1
+
+ expected = { "identifier" => "{id: 1}", "type" => "reject_subscription" }
+ assert_equal expected, @connection.last_transmission
+ assert_equal 1, @connection.transmissions.size
+
+ @channel.perform_action("action" => :secret_action)
+ assert_equal 1, @connection.transmissions.size
+ end
end