This adds `linguist-generated` and `linguist-vendored` attributes where
appropriate to suppress the files in diffs and exclude the files from
the project's language stats on GitHub.
See https://github.com/github/linguist for more information.
Prior to this commit, if `app/javascript/action_cable/index.js`
contained a syntax error, `JavascriptPackageTest` would still pass
because `system "yarn build"` would simply return `false` and the
compiled output would not change. This commit adds `exception: true` to
the `system` call so that an error will be raised if `yarn build` fails.
Also, since 4a23cb3415, Active Storage
compiles additional `app/assets/javascripts/actioncable.js` and
`app/assets/javascripts/actioncable.esm.js` files (with
`app/assets/javascripts/action_cable.js` being deprecated). This commit
adds assertions for those files as well.
It's possible since Rails 6 (3ea2857943) to let the framework create Event objects, but the guides and docs weren't updated to lead with this example.
Manually instantiating an Event doesn't record CPU time and allocations, I've seen it more than once that people copy-pasting the example code get confused about these stats returning 0. The tests here show that - just like the apps I've worked on - the old pattern keeps getting copy-pasted.
Ideally we should be able to checkout an Adapter instance without
triggering a connection to the server.
For some adapters like Trilogy that is the case today, but only if
you have a schema cache loaded, otherwise `check_version` will trigger
a query.
I think this check can be delayed to when we actually use the connection.
* Add Bun support to `rails new -j` generator
* Add additional generation consideration for Bun
* Use development gems to test the whole workflow
* Remove custom gems from local testing
* Revert lock
* Revert errant custom gem declaration
* Fix linting errors
* Fix remnants of bad merge
* Always use latest bun
* Update actioncable/lib/rails/generators/channel/channel_generator.rb
Co-authored-by: Cadu Ribeiro <mail@cadu.dev>
* Update guides/source/working_with_javascript_in_rails.md
Co-authored-by: Rafael Mendonça França <rafael@franca.dev>
* Only use the latest bun if nothing is specified
* Hardcode known good version
---------
Co-authored-by: Cadu Ribeiro <mail@cadu.dev>
Co-authored-by: Rafael Mendonça França <rafael@franca.dev>
This adds additional coverage to ActionCable::Server to validate that
its output follow the Rack SPEC.
In addition to using Rack::CONTENT_TYPE for the Content-Type header,
there was another change required: the Content-Type header cannot be
specified when the Response status is 204, so the default health check
status was updated to 200
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.
This commit resolves an integration bug between ActionCable and Redis >= 5.0 when using sentinels configuration.
The issue arises from the fact that the sentinels configuration is a nested array of hashes, while the Redis client expects keys to be symbols.
This fix modifies the preparation of the Redis configuration to ensure that all keys are represented as symbols.
Action Cable can be mounted standalone, but it loses the health check
route provided by the railties.
This change adds configuration for a health check rack app and a
health check route to "mount" the rack app.
Fixes#48185
This PR is similar to https://github.com/rails/rails/pull/47025, it makes Action Cable's `assert_broadcasts` return the messages that were broadast. This way you can do more analysis on them:
```ruby
messages = assert_broadcasts("test", 2) do
ActionCable.server.broadcast "test", { message: "one" }
ActionCable.server.broadcast "test", { message: "two" }
end
assert_equal 2, messages.length
assert_equal({ "message" => "one" }, messages.first)
assert_equal({ "message" => "two" }, messages.last)
```
This is helpful if you expect lots of messages to be broadcast or if you want to only match on some element of the data; `assert_broadcast_on` doesn't work well in either of those scenarios.
Currently when opening the main framework pages there is no introduction
to the framework. Instead we only see a whole lot of modules and the
`gem_version` and `version` methods.
By including the READMEs using the `:include:` directive each frameworks
has a nice introduction.
For markdown READMEs we need to add the :markup: directive.
[ci-skip]
Co-authored-by: zzak <zzakscott@gmail.com>
* Remove Copyright years
* Basecamp is now 37signals... again
Co-authored-by: David Heinemeier Hansson <dhh@hey.com>
---------
Co-authored-by: David Heinemeier Hansson <dhh@hey.com>