aboutsummaryrefslogtreecommitdiffstats
path: root/actioncable/test
diff options
context:
space:
mode:
authorGeorge Claghorn <george.claghorn@gmail.com>2018-12-31 11:12:01 -0500
committerGitHub <noreply@github.com>2018-12-31 11:12:01 -0500
commitc45e3e74eda12885b37d55651540a7e6849b08d5 (patch)
treea5dae0dd052a5d262cc15afda8eda154d17e985d /actioncable/test
parent04d091209af3b2a8cf4bc827a30209d47ba27253 (diff)
parent9c8d4850f1d69db784ffafa93f38f780bf57c519 (diff)
downloadrails-c45e3e74eda12885b37d55651540a7e6849b08d5.tar.gz
rails-c45e3e74eda12885b37d55651540a7e6849b08d5.tar.bz2
rails-c45e3e74eda12885b37d55651540a7e6849b08d5.zip
Merge pull request #34740 from sponomarev/feature/assert_has_stream
Add streams assert methods to ActionCable channel test case
Diffstat (limited to 'actioncable/test')
-rw-r--r--actioncable/test/channel/test_case_test.rb30
1 files changed, 28 insertions, 2 deletions
diff --git a/actioncable/test/channel/test_case_test.rb b/actioncable/test/channel/test_case_test.rb
index 63d0d6207e..9c360d5dc3 100644
--- a/actioncable/test/channel/test_case_test.rb
+++ b/actioncable/test/channel/test_case_test.rb
@@ -93,13 +93,39 @@ class StreamsTestChannelTest < ActionCable::Channel::TestCase
def test_stream_without_params
subscribe
- assert_equal "test_0", streams.last
+ assert_has_stream "test_0"
end
def test_stream_with_params
subscribe id: 42
- assert_equal "test_42", streams.last
+ assert_has_stream "test_42"
+ end
+end
+
+class StreamsForTestChannel < ActionCable::Channel::Base
+ def subscribed
+ stream_for User.new(params[:id])
+ end
+end
+
+class StreamsForTestChannelTest < ActionCable::Channel::TestCase
+ def test_stream_with_params
+ subscribe id: 42
+
+ assert_has_stream_for User.new(42)
+ end
+end
+
+class NoStreamsTestChannel < ActionCable::Channel::Base
+ def subscribed; end # no-op
+end
+
+class NoStreamsTestChannelTest < ActionCable::Channel::TestCase
+ def test_stream_with_params
+ subscribe
+
+ assert_no_streams
end
end