2015-10-20 18:17:18 -04:00
|
|
|
require 'test_helper'
|
|
|
|
require 'stubs/test_connection'
|
|
|
|
require 'stubs/room'
|
|
|
|
|
|
|
|
class ActionCable::Channel::RejectionTest < ActiveSupport::TestCase
|
|
|
|
class SecretChannel < ActionCable::Channel::Base
|
|
|
|
def subscribed
|
2015-11-05 10:37:15 -05:00
|
|
|
reject if params[:id] > 0
|
2015-10-20 18:17:18 -04:00
|
|
|
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 }
|
|
|
|
|
2016-03-11 18:32:02 -05:00
|
|
|
expected = { "identifier" => "{id: 1}", "type" => "reject_subscription" }
|
2015-10-20 18:17:18 -04:00
|
|
|
assert_equal expected, @connection.last_transmission
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|