aboutsummaryrefslogtreecommitdiffstats
path: root/actioncable/lib/action_cable/channel/test_case.rb
Commit message (Collapse)AuthorAgeFilesLines
* fix fixture syntax in cable docs and guidesVladimir Dementyev2019-01-221-3/+3
|
* Move `channel_name` to Channel.broadcasting_forVladimir Dementyev2019-01-221-3/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | That would allow us to test broadcasting made with channel, e.g.: ```ruby class ChatRelayJob < ApplicationJob def perform_later(room, msg) ChatChannel.broadcast_to room, message: msg end end ``` To test this functionality we need to know the underlying stream name (to use `assert_broadcasts`), which relies on `channel_name`. We had to use the following code: ```ruby assert_broadcasts(ChatChannel.broadcasting_for([ChatChannel.channel_name, room]), 1) do ChatRelayJob.perform_now end ``` The problem with this approach is that we use _internal_ API (we shouldn't care about `channel_name` prefix in our code). With this commit we could re-write the test as following: ```ruby assert_broadcasts(ChatChannel.broadcasting_for(room), 1) do ChatRelayJob.perform_now end ```
* Add streams assert methods to ActionCable channel test caseSergey Ponomarev2018-12-181-4/+45
|
* Fix typosR.T. Lechow2018-10-011-2/+2
| | | | Fixes some typos.
* Remove Rails 5.0 workaround from ActionCable::Channel::TestCaseVladimir Dementyev2018-09-271-6/+2
| | | | | | | The hack was merged from action-cable-testing gem by mistake. We don't need it in Rails 6. (cherry picked from commit 92030ec4b4309835ed0e792229984a1f0a044cef)
* Add ActionCable::Channel::TestCaseVladimir Dementyev2018-09-261-0/+275
ActionCable::Channel::TestCase provides an ability to unit-test channel classes. There are several reasons to write unit/functional cable tests: - Access control (who has access to the channel? who can perform action and with which argument? - Frontend-less applications have no system tests at all–and we still need a way to test channels logic. See also #27191