rails/actioncable
julianfssen 9c5175e067 Delegate StubConnection#pubsub and StubConnection#config to ActionCable.server
Previously, `ActionCable::Channel::ConnectionStub` would
throw a `NoMethodError` when the channel under test calls
`stop_stream_for`, as shown in the example below:

```ruby
class ChatChannel < ActionCable::Channel::Base
  def subscribed
    stream_from "test"
  end

  def unsubscribed
    stop_stream_from "test"
  end
end

class ChatChannelTest < ActionCable::Channel::TestCase
  test "unsubscribe" do
    stub_connection

    subscribe

    # `unsubscribe` raises `NoMethodError` as `pubsub` does not
      exist on `ActionCable::Channel::ConnectionStub`
    unsubscribe

    assert_no_streams
  end
end
```

Calling `unsubscribe` causes an exception as `stop_stream_from` calls
`pubsub` when unsubscribing, which is not implemented in
`ActionCable::Channel::ConnectionStub`.

This commit fixes this issue by assigning the `ActionCable.server`
singleton to a `@server` instance variable in
`ActionCable::Channel::ConnectionStub`. This lets us delegate
the `config` and `pubsub` method calls to it.
2023-07-15 13:04:46 +08:00
..
app Allows adding more protocols to the WebSocket sub protocols 2022-10-19 09:00:15 +02:00
bin Use frozen string literal in actioncable/ 2017-07-23 23:30:29 +03:00
lib Delegate StubConnection#pubsub and StubConnection#config to ActionCable.server 2023-07-15 13:04:46 +08:00
test Delegate StubConnection#pubsub and StubConnection#config to ActionCable.server 2023-07-15 13:04:46 +08:00
.babelrc Convert ActionCable javascript to ES2015 modules with modern build environment 2018-11-02 08:41:05 -07:00
.eslintrc Output Action Cable JS without transpiling and as ESM (#42856) 2021-08-06 14:00:43 +02:00
.gitignore Ensure @rails/actioncable package contains complete source 2019-08-15 09:19:59 -04:00
actioncable.gemspec Require Zeitwerk 2.6 2022-06-13 23:43:42 +02:00
CHANGELOG.md Delegate StubConnection#pubsub and StubConnection#config to ActionCable.server 2023-07-15 13:04:46 +08:00
karma.conf.js Output Action Cable JS without transpiling and as ESM (#42856) 2021-08-06 14:00:43 +02:00
MIT-LICENSE Remove Copyright years (#47467) 2023-02-23 11:38:16 +01:00
package.json Start Rails 7.1 development 2021-12-07 15:52:30 +00:00
Rakefile Load framework test files in deterministic order 2019-12-16 16:55:06 +00:00
README.md 🔗 Remove RDoc auto-link from Rails module everywhere 2023-06-23 10:49:30 +09:00
rollup.config.js Output Action Cable JS without transpiling and as ESM (#42856) 2021-08-06 14:00:43 +02:00
rollup.config.test.js Output Action Cable JS without transpiling and as ESM (#42856) 2021-08-06 14:00:43 +02:00

Action Cable Integrated WebSockets for \Rails

Action Cable seamlessly integrates WebSockets with the rest of your \Rails application. It allows for real-time features to be written in Ruby in the same style and form as the rest of your \Rails application, while still being performant and scalable. It's a full-stack offering that provides both a client-side JavaScript framework and a server-side Ruby framework. You have access to your full domain model written with Active Record or your ORM of choice.

You can read more about Action Cable in the Action Cable Overview guide.

Support

API documentation is at:

Bug reports for the Ruby on \Rails project can be filed here:

Feature requests should be discussed on the rails-core mailing list here: