diff options
author | Pratik <pratiknaik@gmail.com> | 2015-11-04 17:43:31 -0600 |
---|---|---|
committer | Pratik <pratiknaik@gmail.com> | 2015-11-04 17:43:31 -0600 |
commit | de64aa3440f85b74692b61f7e46a14a1a7003e56 (patch) | |
tree | 8ebac494bc23e5248558dbcabff0cc62ba48cc49 /test/channel | |
parent | 7c1631fa48b8862f37d1026b4f0cf1061dd6947a (diff) | |
parent | 1ce0e66f090631f5113cb844be32b2b7fe4dc88e (diff) | |
download | rails-de64aa3440f85b74692b61f7e46a14a1a7003e56.tar.gz rails-de64aa3440f85b74692b61f7e46a14a1a7003e56.tar.bz2 rails-de64aa3440f85b74692b61f7e46a14a1a7003e56.zip |
Merge pull request #102 from rails/subscription-rejection
Allow rejecting subscriptions from the channel
Diffstat (limited to 'test/channel')
-rw-r--r-- | test/channel/rejection_test.rb | 25 |
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 |