aboutsummaryrefslogtreecommitdiffstats
path: root/test/channel
diff options
context:
space:
mode:
authorPratik Naik <pratiknaik@gmail.com>2015-10-20 17:17:18 -0500
committerPratik Naik <pratiknaik@gmail.com>2015-10-21 13:47:48 -0500
commit0ce0cf0c04b53ee6c7038d8912dd1ed433f7935f (patch)
tree152c3ba76fbdfab6342af72b525d9eac7d7363ac /test/channel
parent904b83b9c3d5dc1f1ceac1552dd5b80513aa3232 (diff)
downloadrails-0ce0cf0c04b53ee6c7038d8912dd1ed433f7935f.tar.gz
rails-0ce0cf0c04b53ee6c7038d8912dd1ed433f7935f.tar.bz2
rails-0ce0cf0c04b53ee6c7038d8912dd1ed433f7935f.zip
Allow rejecting subscriptions from the channel
Diffstat (limited to 'test/channel')
-rw-r--r--test/channel/rejection_test.rb25
1 files changed, 25 insertions, 0 deletions
diff --git a/test/channel/rejection_test.rb b/test/channel/rejection_test.rb
new file mode 100644
index 0000000000..0e9725742c
--- /dev/null
+++ b/test/channel/rejection_test.rb
@@ -0,0 +1,25 @@
+require 'test_helper'
+require 'stubs/test_connection'
+require 'stubs/room'
+
+class ActionCable::Channel::RejectionTest < ActiveSupport::TestCase
+ class SecretChannel < ActionCable::Channel::Base
+ def subscribed
+ reject! if params[:id] > 0
+ end
+ end
+
+ setup do
+ @user = User.new "lifo"
+ @connection = TestConnection.new(@user)
+ end
+
+ test "subscription rejection" 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 = ActiveSupport::JSON.encode "identifier" => "{id: 1}", "type" => "reject_subscription"
+ assert_equal expected, @connection.last_transmission
+ end
+
+end