diff options
author | George Claghorn <george.claghorn@gmail.com> | 2018-12-31 11:12:01 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-12-31 11:12:01 -0500 |
commit | c45e3e74eda12885b37d55651540a7e6849b08d5 (patch) | |
tree | a5dae0dd052a5d262cc15afda8eda154d17e985d /actioncable/test | |
parent | 04d091209af3b2a8cf4bc827a30209d47ba27253 (diff) | |
parent | 9c8d4850f1d69db784ffafa93f38f780bf57c519 (diff) | |
download | rails-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.rb | 30 |
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 |