diff options
author | Kasper Timm Hansen <kaspth@gmail.com> | 2016-08-21 21:21:44 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-08-21 21:21:44 +0200 |
commit | 0f0349b7ee13015944f11bc34a907d2d4157dde4 (patch) | |
tree | bf7c5dc51487259014e550b76632a0c8aabdc8c3 /actioncable/test | |
parent | 0432652f234608634dc8d9c50792ed88235b0d53 (diff) | |
parent | 831e2c8d1bf13cd944f5683980cfe95f59db2ae8 (diff) | |
download | rails-0f0349b7ee13015944f11bc34a907d2d4157dde4.tar.gz rails-0f0349b7ee13015944f11bc34a907d2d4157dde4.tar.bz2 rails-0f0349b7ee13015944f11bc34a907d2d4157dde4.zip |
Merge pull request #23759 from maclover7/fix-23757
Prevent invocation of channel action if rejected connection
Diffstat (limited to 'actioncable/test')
-rw-r--r-- | actioncable/test/channel/rejection_test.rb | 15 |
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 |