aboutsummaryrefslogtreecommitdiffstats
path: root/actioncable/test/client_test.rb
diff options
context:
space:
mode:
authorMatthew Draper <matthew@trebex.net>2016-02-19 11:17:51 +1030
committerMatthew Draper <matthew@trebex.net>2016-02-19 11:17:51 +1030
commit6da571add8e8fee0e6252f93978d63fb57f29417 (patch)
treec109080f914cd716a90985d60006837cbd35bb70 /actioncable/test/client_test.rb
parent042bfb8715ca301dc37e5e883951f6aa07fbc7ea (diff)
parentcefcc0f66e185b808fc93040b1d7805f95bf929f (diff)
downloadrails-6da571add8e8fee0e6252f93978d63fb57f29417.tar.gz
rails-6da571add8e8fee0e6252f93978d63fb57f29417.tar.bz2
rails-6da571add8e8fee0e6252f93978d63fb57f29417.zip
Merge pull request #23715 from maclover7/fix-unsubscribe
Fix `unsubscribed` server side behavior
Diffstat (limited to 'actioncable/test/client_test.rb')
-rw-r--r--actioncable/test/client_test.rb21
1 files changed, 21 insertions, 0 deletions
diff --git a/actioncable/test/client_test.rb b/actioncable/test/client_test.rb
index 26629216e5..1b07689127 100644
--- a/actioncable/test/client_test.rb
+++ b/actioncable/test/client_test.rb
@@ -199,4 +199,25 @@ class ClientTest < ActionCable::TestCase
c.close # disappear before read
end
end
+
+ def test_unsubscribe_client
+ with_puma_server do |port|
+ app = ActionCable.server
+ identifier = JSON.dump(channel: 'EchoChannel')
+
+ c = faye_client(port)
+ c.send_message command: 'subscribe', identifier: identifier
+ assert_equal({"identifier"=>"{\"channel\":\"EchoChannel\"}", "type"=>"confirm_subscription"}, c.read_message)
+ assert_equal(1, app.connections.count)
+ assert(app.remote_connections.where(identifier: identifier))
+
+ channel = app.connections.first.subscriptions.send(:subscriptions).first[1]
+ channel.expects(:unsubscribed)
+ c.close
+ sleep 0.1 # Data takes a moment to process
+
+ # All data is removed: No more connection or subscription information!
+ assert_equal(0, app.connections.count)
+ end
+ end
end