Commit Graph

769 Commits

Author SHA1 Message Date
Hartley McGuire
07405c7b62
Fix markup directive in Action Cable templates
When converting Action Cable docs from RDoc to Markdown, these two
templates were accidentally included in the list of files converted (and
the `:markup:` directive added) because they incorrectly had an `.rb`
extension instead of `.rb.tt`.

This commit fixes the extension and removes the `:markup:` directive.
2024-06-30 19:37:35 -04:00
Xavier Noria
de4d874474 Add a comment for dirname vs __dir__ usage 2024-06-24 10:35:43 +02:00
Sajan
f0aaa3cfe8 Fix Action Cable loader path prefix
Since `__dir__` uses real path, when we load the gems from a symlinked path, Zeitwek loader
tries to load the ignored files and throws warnings or errors.
2024-06-21 15:07:54 +00:00
Justin Ko
f49ff82da2 :nodoc: for ActionCable::Connection::TestCookies 2024-05-31 17:30:03 -06:00
Justin Ko
24472e01c1
Improve ActionCable TestCookieJar interface
Fixes #51914
2024-05-28 20:09:39 +00:00
Rafael Mendonça França
8ea62041ae
Merge pull request #51866 from tnir/tn-update-eslint-from-4.3.0-to-8.40.0
chore(deps-dev): update eslint from 4.19.1 to 8.40.0
2024-05-23 12:23:12 -04:00
Rafael Mendonça França
7ee34d9efb
Enable Rails minitest plugin in our rake tasks 2024-05-23 16:16:37 +00:00
Takuya Noguchi
b6e49a7b1f chore(deps-dev): update eslint from 4.3.0 to 8.40.0
Also update eslint-plugin-import from 2.27.5 to 2.29.0.

Signed-off-by: Takuya Noguchi <takninnovationresearch@gmail.com>
2024-05-23 14:23:15 +09:00
Rafael Mendonça França
bf59d363fb
Clean CHANGELOG for 8.0 2024-05-13 16:55:52 +00:00
Rafael Mendonça França
37fd0e7fe4
Development of Rails 8.0 starts now
🎉
2024-05-13 16:45:20 +00:00
Xavier Noria
b05603f6e4 Let Action Cable's autoloader ignore the version file
Rails components version files are organized in a particular way.

On one hand, ActionCable::VERSION is defined in action_cable/gem_version.rb, but
that file does not follow Zeitwerk conventions, so we ignore it.

Addtionally, action_cable/gem_version.rb defines ActionCable.gem_version, and we
need to eager load it to have that method available for client code.

On the other hand, there is also action_cable/version.rb, which loads
action_cable/gem_version.rb. That file follows the conventions because by
loading it, the expected constant gets defined as a side-effect, but it does so
in an unusual indirect way.

All in all, the setup that we had technically works, but setting an autoload for
VERSION in ActionCable makes you think too much about the interactions between
these two files and the autoloads triggered by the existing require_relative,
which eager loads anyway.

I believe this simplification is easier to understand.
2024-04-22 19:58:23 +02:00
Takuya Noguchi
3f635e3a44
test: update karma npm from 3.1.4 to 6.4.2
karma 3.x was stable in 2018, but 6.x is now the latest.

Signed-off-by: Takuya Noguchi <takninnovationresearch@gmail.com>
2024-04-18 17:48:59 +00:00
Carlos Antonio da Silva
8ad19d9865 Minor tweaks / improvements to recent changelog/api docs [ci skip] 2024-04-08 14:48:44 -03:00
yauhenisushkevich
2a71de9cca
Record ping on every actioncable message 2024-04-05 15:23:52 +00:00
Hartley McGuire
6640b85b69
Fix md label-lists rendering incorrectly
When converting docs from RDoc to Markdown, some label-lists ended up
not rendering properly. This appears to be due to RDoc's Markdown
parser not recognizing label-list labels if the label has additional
markup around it (in this case, bold markers `**`).

Additionally, the markdown label-list was missing newlines between list
items which also caused the label-list to not render correctly.

This commit fixes both of these issues for cases where the RDoc
originally used <b> tags in a label-list label. Since label-list labels
will already be bolded, there is no reason to also use `**` on the
labels.
2024-03-06 18:11:14 -05:00
Jean Boussier
7263da542b Deprecate ConnectionPool#connection
Replaced by `#lease_connection` to better reflect what it does.

`ActiveRecord::Base#connection` is deprecated in the same way
but without a removal timeline nor a deprecation warning.

Inside the Active Record test suite, we do remove `Base.connection`
to ensure it's not used internally.

Some callsites have been converted to use `with_connection`,
some other have been more simply migrated to `lease_connection`
and will serve as a list of callsites to convert for
https://github.com/rails/rails/pull/50793
2024-03-01 14:32:55 +01:00
Sean Doyle
cfab11c959 Action Cable assert_broadcasts API docs [ci skip]
Follow-up to [#48798][]
Reverts [#47837][]

The `capture_broadcasts` helper was introduced in [#48798][] to remove
the return value from the `assert_broadcasts` call. The behavior was
changed, but the corresponding documentation for the `assert_broadcasts`
method did not revert the changes added in [#47837][].

This change should probably also get backported to `7-1-0-stable`.

[#47837]: https://github.com/rails/rails/pull/47837
[#48798]: https://github.com/rails/rails/pull/48798

Co-authored-by: Matheus Richard <matheusrichardt@gmail.com>
2024-02-19 10:39:43 -05:00
Jun Jiang
d5786b2e9d ActionCable: Use ... to passthrough args 2024-02-17 05:28:42 +08:00
Jun Jiang
08cb349a4b ActionCable: avoid potential nil error 2024-02-17 05:28:42 +08:00
Jun Jiang
0df0947b70 ActionCable: Allow pass code and reason when closing a WebSocket connection 2024-02-17 05:28:42 +08:00
Yasuo Honda
aafbf0a4a7
Merge pull request #51040 from hendrixfan/remove-rollup-option
remove unknown rollup input option breakOnWarning
2024-02-14 11:40:05 +09:00
Wolfgang Fournès
33e5ce5fce remove unknown rollup input option breakOnWarning
As seen in https://buildkite.com/rails/rails/builds/104749#018d92dc-79b9-42bc-9a8c-bbcf5681f9eb/1165-1176 breakOnWarning does not seem to be a valid option for Rollup. I cannot find in the documentation, and therefore I think it can safely be removed.
2024-02-10 14:05:39 +01:00
Rafael Mendonça França
6fdd31d7db
Transform actioncable documentation to Markdown 2024-02-10 00:11:26 +00:00
Jean Boussier
cc63348160 Replace some low value dynamic delegator by handcrafted ones
Dynamic delegation make sense when there is a long list of methods
etc. But for very simple cases, writing one or two methods by hand
is just clearer and more efficient.
2024-01-25 11:51:00 +01:00
Jean Boussier
bffe05f246 Module#delegate stop accepting the private as: parameter
The feature remains usable internally, but via `ActiveSupport::Delegation`,
this way we don't allow third party use.
2024-01-25 11:51:00 +01:00
Petrik
8565f45100 Use relative includes of README's in documentation [ci-skip]
The Rails documentation uses the `:include:` directive to inline the
README of the framework into the main documentation page. As the
README's aren't in the root directory from where SDoc is run we need to
add the framework path to the include:

    # :include: activesupport/README.md

This results in a warning when installing the gems as generating the rdoc for the gem is run from the gem/framework root:

    Couldn't find file to include 'activesupport/README.rdoc' from lib/active_support.rb

The `:include:` RDoc directive supports includes relative to the current
file as well:

    # :include: ../README.md

This makes sure it works for the Rails API docs and the separate gems.

Co-authored-by: Jonathan Hefner <jonathan@hefner.pro>
2024-01-18 10:39:15 +01:00
Junichi Sato
523f86964f
Rename #assert_not_has_stream #assert_has_no_stream
This is a follow-up to https://github.com/rails/rails/pull/50585.

I propose to provide smoother reading experiences with the two methods
introduced in there, `#assert_not_has_stream` and `#assert_not_has_stream_for`,
by renaming them `#assert_has_no_stream` and `#assert_has_no_stream_for`, respectively.
2024-01-05 11:29:21 +09:00
Sebi
d9e2b159f9 Add assertions for stopped ActionCable streams
This adds two new assertion methods for ActionCable test cases:
`assert_not_has_stream` and `assert_not_has_stream_for`. These methods
can be used to assert that a stream has been stopped, e.g. via
`stop_stream` or `stop_stream_for`.
2024-01-04 19:41:35 +00:00
Zane Wolfgang Pickett
f634121c3d
Fix self is undefined for actioncable within ssr build systems by replacing it globalThis 2024-01-03 19:19:50 +00:00
Jean Boussier
6ba2fdb2fe Bump the required Ruby version to 3.1.0
Until now, Rails only droped compatibility with older
rubies on new majors, but I propose to change this policy
because it causes us to either keep compatibility with long
EOLed rubies or to bump the Rails major more often, and to
drop multiple Ruby versions at once when we bump the major.

In my opinion it's a bad alignments of incentives. And we'd
be much better to just drop support in new minors whenever they
go EOL (so 3 years).

Also Ruby being an upstream dependency, it's not even
a semver violation AFAICT.

Since Rails 7.2 isn't planned before a few months, we
can already drop Ruby 3.0 as it will be EOL in March.
2023-12-31 08:54:03 +01:00
Jean Boussier
be258503ac Module#delegate takes a new private as parameter
This is a continuation of https://github.com/rails/rails/pull/46875

The behavior of looking up the class method when `to: :class` is passed
is a bit error prone because it silently degrades.

By passing the expected owner of the delegated method, we can be more
strict, and also generate a delegator in a module rather than having
to do it at inclusion time.

I made this argument private API because we want it in Rails, but
I'm worried it might be a bit too sharp for public API. I can
be convinced otherwise though.
2023-12-08 15:09:59 +01:00
Jonathan Hefner
4dcd6ba8d3 Update .gitattributes for generated JavaScript [ci-skip]
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.
2023-11-05 15:48:08 -06:00
Jonathan Hefner
8e213f72dd Update JavascriptPackageTest for Action Cable
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 4a23cb3415eac03d76623112576559a722d1f23d, 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.
2023-11-05 15:13:30 -06:00
Nikita Vasilevsky
19f8ab2e7d
[Tests only] Enable Minitest/AssertPredicate rule 2023-10-13 19:26:47 +00:00
Jonathan Hefner
3534c40c33 Move example to API docs [ci-skip] 2023-10-07 11:55:34 -05:00
Jonathan Hefner
eac107cfa9 Link to ActionCable::Connection callback methods [ci-skip] 2023-10-07 11:52:34 -05:00
Jonathan Hefner
53a75d4082 Move after_subscribe note to after_subscribe doc [ci-skip] 2023-10-07 11:52:33 -05:00
Jonathan Hefner
b14b9ce6b9 Link to ActionCable::Channel callback methods [ci-skip] 2023-10-07 11:52:33 -05:00
Bart de Water
95b6fbd00f Stop building AS::Notifications::Event manually
It's possible since Rails 6 (3ea2857943dc294d7809930b4cc5b318b9c39577) 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.
2023-09-29 12:34:23 -04:00
Jean Boussier
2da1852ac9 Delay Adapter#check_version to #configure_connection
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.
2023-09-29 08:53:16 +02:00
Rafael Mendonça França
fb6c6007d0
Development of Rails 7.2 starts now
🎉
2023-09-27 03:59:11 +00:00
Rafael Mendonça França
e5386cb402
Preparing for 7.1.0.rc1 release 2023-09-27 03:08:31 +00:00
Rafael Mendonça França
699dfdb426
Preparing for 7.1.0.beta1 release 2023-09-13 00:36:01 +00:00
Jason Meller
274bc97d63
Add Bun support (#49241)
* 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>
2023-09-12 16:55:27 -04:00
Hartley McGuire
c3c844ef3a
Add Rack::Lint to ActionCable::Server health tests
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
2023-08-16 22:49:32 -04:00
Alex Ghiculescu
455e922b49
Introduce capture_emails and capture_broadcasts (#48798) 2023-07-25 06:42:54 +02:00
Marcin Henryk Bartkowiak
bcf9e3de0c Do not inspect transmit data if logger is not debug-enabled 2023-07-20 18:52:26 +02:00
Marcin Henryk Bartkowiak
99d7dc88ae Add block support to TaggedLoggerProxy 2023-07-20 18:26:10 +02:00
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
zzak
dd89f600f7
🔗 Remove RDoc auto-link from Rails module everywhere 2023-06-23 10:49:30 +09:00