From bf40bddfceebaff637161be6c5d992d6978679ff Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Mon, 14 Dec 2015 15:48:54 +0100 Subject: Get ready to merge into Rails --- actioncable/test/channel/rejection_test.rb | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 actioncable/test/channel/rejection_test.rb (limited to 'actioncable/test/channel/rejection_test.rb') diff --git a/actioncable/test/channel/rejection_test.rb b/actioncable/test/channel/rejection_test.rb new file mode 100644 index 0000000000..aa93396d44 --- /dev/null +++ b/actioncable/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 -- cgit v1.2.3