Commit Graph

558 Commits

Author SHA1 Message Date
Ryuta Kamizono
c81af6ae72 Enable Layout/EmptyLinesAroundAccessModifier cop
We sometimes say "✂️ newline after `private`" in a code review (e.g.
https://github.com/rails/rails/pull/18546#discussion_r23188776,
https://github.com/rails/rails/pull/34832#discussion_r244847195).

Now `Layout/EmptyLinesAroundAccessModifier` cop have new enforced style
`EnforcedStyle: only_before` (https://github.com/rubocop-hq/rubocop/pull/7059).

That cop and enforced style will reduce the our code review cost.
2019-06-13 12:00:45 +09:00
Alex Emelyanov
99c98c8034 ActionCable: optimize logger.debug calling 2019-06-08 19:23:47 +05:00
Rafael Mendonça França
9834be6565
Start Rails 6.1 development 2019-04-24 15:57:14 -04:00
Blake Stoddard
70d64169ae ActionCable: don't allowlist keys passed to the Redis initializer
Support all Redis features without needing to maintain a list of valid options that must stay in sync with the upstream client library.
2019-04-22 09:59:53 -04:00
Matthew Draper
e485c14a3e s/Travis/Buildkite/ 2019-04-09 11:28:49 +09:30
Fumiaki MATSUSHIMA
61c4be4777 Output junit format test report 2019-04-04 14:34:46 +09:00
rmacklin
d03177ffbc Simplify ActionCable.createWebSocketURL and realphabetize exports (#35810)
* Remove unnecessary variable from ActionCable.createWebSocketURL

* Improve ActionCable test by creating the Consumer before reassigning URL

With this change, the test now actually verifies that the Consumer's url
property changes dynamically (from testURL to `${testURL}foo`).

* Fix alphabetization of ActionCable exports
2019-04-02 23:04:43 +02:00
Sharang Dashputre
771973c13d url -> URL where apt except inside actionpack/ 2019-04-01 22:56:35 +05:30
Ryan Castner
6d488a22d3 feat(js): Dynamic ActionCable URL (#35579)
* Failing test case

* feat: Dynamic Url Generation

Change createWebSocketURL to be a closure that allows url to be evaluated at the time the webSocket is established

* refactor: createWebSocketURL to Consumer, remove need for closure

Move initial call to createWebSocketURL in createConsumer

* docs: Add documentation for dynamic url and string args to createConsumer

Co-Authored-By: rmacklin <rmacklin@users.noreply.github.com>

[Ryan Castner, rmacklin]
2019-03-31 19:41:12 +02:00
eileencodes
a2bd669ed2 v6.0.0.beta3 release
-----BEGIN PGP SIGNATURE-----
 
 iQEzBAABCAAdFiEEEvJkGf0BARV+D0L2ulxXUSC76N8FAlyJN4cACgkQulxXUSC7
 6N9ZXAf/Wx7edIct8kZzcC6irlROx4DzpNbrrH792sO1OAcnoFDE7DPkokllTEP/
 4kzC42lca/XG27MCl7E0dtVD8hIyAl89nxid6cwKFVZVTPIRVc1wjXkoiWy/cvd7
 6+9IjxhlgrzxGnw3aWZJG7H3iqz69yr55aoSDU/TbMqq5kQrqNF95vr2nc8LEUco
 SLQj0pO/tfJdHquSeX0JiXn3VSEHT+5TdLGQ3J/w0wFU6mkecH4MJMJvMwLFx/v4
 llnvF6HyfSLASWbrpdD3h6MQHpImDoee5vILXAHzPdSaEVcVa1cDFtMcPMYiu8Dw
 AGdCAaHQhZFFGoYK472+o6pur0dxEA==
 =5dET
 -----END PGP SIGNATURE-----

Merge tag 'v6.0.0.beta3'

v6.0.0.beta3 release
2019-03-13 13:11:10 -04:00
eileencodes
7c87fd5635 Prep release
* Update RAILS_VERSION
* Bundle
* rake update_versions
* rake changelog:header
2019-03-11 11:58:15 -04:00
Kasper Timm Hansen
5f7e01c84c
Fix style issues and build source after #35525
Ran `cd actioncable && yarn build`.

[ Kasper Timm Hansen & Ryan Castner ]
2019-03-11 14:32:43 +01:00
Kasper Timm Hansen
33800d2330
Merge pull request #35525 from audiolion/feature/dynamic-actioncable-websocket-url
feat(js): Dynamic Actioncable WebSocket URL
2019-03-11 13:54:28 +01:00
Ryan Castner
9333f86adb
address pr feedback
change if statement to ternary, use const for consistency, add spacing after ternary expression
2019-03-09 14:55:54 -05:00
Abhay Nikam
476abd403b Updated links from http to https in guides, docs, etc 2019-03-09 16:43:47 +05:30
Ryan Castner
c7ca85ef31 feat(js): Dynamic Actioncable WebSocket URL
Allow createWebSocketURL fn to accept a function to generate the websocket URL rather than a string.
2019-03-07 22:14:20 -05:00
Rafael Mendonça França
5e6e505083
Preparing for 6.0.0.beta2 release 2019-02-25 17:45:04 -05:00
Yasuo Honda
15e37b1fad Address uninitialized constant PostgresqlAdapterTest::ChannelPrefixTest (NameError)
```
$ bundle exec ruby -w -Itest test/subscription_adapter/postgresql_test.rb
Traceback (most recent call last):
	1: from test/subscription_adapter/postgresql_test.rb:8:in `<main>'
test/subscription_adapter/postgresql_test.rb:10:in `<class:PostgresqlAdapterTest>': uninitialized constant PostgresqlAdapterTest::ChannelPrefixTest (NameError)
```

https://travis-ci.org/rails/rails/jobs/493530508

Follow up #35276
2019-02-15 02:10:38 +00:00
Vladimir Dementyev
c43c839847 feat: support channel_prefix in pg subscription adapter 2019-02-14 16:22:03 -08:00
Vladimir Dementyev
3cd69fa2c0
Allow passing custom config to ActionCable::Server::Base
That allows us to create a separate, isolated Action Cable server
instance within the same app.
2019-02-12 17:17:46 -05:00
Matthew Draper
287920ca7d Respect ENV variables when finding DBs etc for the test suite
If they're not set we'll still fall back to localhost, but this makes it
possible to run the tests against a remote Postgres / Redis / whatever.
2019-02-06 01:20:06 +10:30
David Heinemeier Hansson
5588fb4802 Use ES6 short style 2019-02-04 16:22:12 -08:00
David Heinemeier Hansson
1fc3a2cc1b Match rails generator output 2019-02-04 16:22:00 -08:00
Vladimir Dementyev
8ed276b2f7
Add ActionCable channel/connection load hooks 2019-01-29 22:07:49 -05:00
Javan Makhmali
e3d43333db Add CHANGELOG entries for npm package renames [ci skip] 2019-01-28 06:29:26 -05:00
Kasper Timm Hansen
36c840057f
Merge pull request #35021 from palkan/refactor/broadcasting-for-testing
Action Cable: move channel_name to Channel.broadcasting_for
2019-01-24 23:40:33 +01:00
Sergey Ponomarev
c125990c7c
Fix attribute typo in ActionCable connection test request 2019-01-23 09:35:48 -05:00
Vladimir Dementyev
cfe65cb478
fix fixture syntax in cable docs and guides 2019-01-22 16:53:01 -05:00
Vladimir Dementyev
513dd2cfdb
Add note about broadcast_to/broadcasting_for to change log 2019-01-22 15:29:12 -05:00
Vladimir Dementyev
35bef64718
Add Channel#broadcast_to 2019-01-22 15:14:35 -05:00
Vladimir Dementyev
dc80459a9e
Move channel_name to Channel.broadcasting_for
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
```
2019-01-22 15:14:20 -05:00
Rafael Mendonça França
5a0230c67f
Preparing for 6.0.0.beta1 release 2019-01-18 15:42:12 -05:00
Rafael França
92cc996a09
Merge pull request #34959 from alkesh26/action-cable-typo-fixes
Typo fixes in action cable.
2019-01-18 08:49:27 -05:00
alkesh26
393566c250 typo fixes in action cable 2019-01-17 22:02:35 +05:30
Javan Makhmali
481192171e
Merge pull request #34941 from rmacklin/allow-actioncable-to-run-in-web-workers
Avoid ReferenceError exceptions if ActionCable is used in a web worker
2019-01-16 17:10:57 -05:00
bogdanvlviv
a43052cbbc
Remove frozen_string_literal from Action Cable's template files
Related to 837f602fa1b3281113dac965a8ef96de3cac8b02

Fix the testing guide.
2019-01-16 15:14:35 +00:00
Richard Macklin
39493185d3 Remove explicit document receiver from add/removeEventListener calls
This allows ActionCable to be used in a web worker, where the `document`
global is undefined. Previously, attempting to use ActionCable inside a
web worker would result in this exception after you try to open a
connection:
```
ReferenceError: document is not defined
```

The visibilitychange event won't ever get triggered in a worker, so
adding the listener is effectively a no-op there. But the listener is
mainly a convenience, rather than a critical piece of the javascript
interface, so using ActionCable in a worker will still work. (And you
could listen for visibilitychange yourself in a window script, then tell
the worker to reconnect if you still want that behavior.)
2019-01-15 22:14:33 -08:00
Richard Macklin
ac8ffbe76a Replace window references in ActionCable with self
Before this change, attempting to use ActionCable inside a web worker
would result in an exception being thrown:
```
ReferenceError: window is not defined
```

By replacing the `window` reference with `self`, which is available in
both a window context and a worker context, we can avoid this error.

Ref:
https://developer.mozilla.org/en-US/docs/Web/API/Window/self
2019-01-14 17:44:35 -08:00
Rafael França
0ffafd475b
Merge pull request #34934 from rmacklin/simplify-actioncable-methods-after-decaffeination
Clean up ActionCable JS a bit more after the CoffeeScript conversion
2019-01-14 15:24:26 -05:00
Richard Macklin
739f88e52e Simplify this.isActive() && this.webSocket into this.isActive()
in Connection#close. We can do this because `isActive()` can only
return `true` if `this.webSocket` is truthy. (We can't have an active
connection without having instantiated a WebSocket. This is confirmed
in the code: Connection#isActive calls Connection#isState which calls
Connection#getState, which checks if `this.webSocket` is truthy and
returns `null` otherwise.)
2019-01-14 11:52:46 -08:00
Richard Macklin
6320916513 Simplify ActionCable.getConfig, Connection#getProtocol, and Connection#close
by relying on the implicit undefined return value
2019-01-14 11:35:04 -08:00
Richard Macklin
dbe073aebf Simplify ActionCable.createConsumer by using default argument 2019-01-14 11:33:24 -08:00
Vladimir Dementyev
a4099debcf
Add Action Cable Testing guides 2019-01-14 11:16:59 -05:00
Vladimir Dementyev
0f41aa30d3
Add channel test generator 2019-01-13 21:54:31 -05:00
Kasper Timm Hansen
3631d7eee4
Update Action Cable connection testing.
* Don't reimplement assert_raises

  Also test what happens in case there's no explicit rejection.

* Avoid OpenStruct. Remove space beneath private.

* Simplify verification methods for code under test.

* Match documentation with other Rails docs.

  Also remove mention of the custom path argument for now.
  Unsure how useful that really is.
2019-01-14 01:19:56 +01:00
Ryuta Kamizono
66ab843a66
Merge pull request #34930 from bogdanvlviv/merge-actioncable-README.md-to-the-guide
Merge `actioncable/README.md` to the Action Cable Overview guide [ci skip]
2019-01-14 05:48:39 +09:00
bogdanvlviv
8e7d9ce8cb
Merge actioncable/README.md to the Action Cable Overview guide [ci skip]
In #34709 we updated the guide, but `actioncable/README.md` is still
outdated. Instead of fixing content in the file. I suggest
not duplicate the info that is already in the guide and instead remove
the info from the file and just add a message:
"You can read more about Action Cable in the
[Action Cable Overview](https://edgeguides.rubyonrails.org/action_cable_overview.html) guide."

The same approach is being used for Action Mailbox and Action Text,
see #34812 and #34878.
2019-01-13 19:45:04 +00:00
Kasper Timm Hansen
907b528854
Merge pull request #34845 from palkan/feature/action-cable-connection-testing
Add ActionCable::Connection::TestCase
2019-01-13 18:30:47 +01:00
Javan Makhmali
86b489e3d6 Move all npm packages to @rails scope
Fixes #33083
2019-01-10 11:01:57 -05:00
Kasper Timm Hansen
647d7e6167
Revert "Revert "Merge pull request #34387 from yhirano55/rails_info_properties_json""
I reverted the wrong commit. Damn it.

This reverts commit f66a977fc7ae30d2a07124ad91924c4ee638a703.
2019-01-08 22:19:22 +01:00