| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
|
|
|
| |
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.
|
| |
|
| |
|
|
|
| |
Support all Redis features without needing to maintain a list of valid options that must stay in sync with the upstream client library.
|
| |
|
|
|
|
|
|
|
| |
* Update RAILS_VERSION
* Bundle
* rake update_versions
* rake changelog:header
|
| |
|
| |
|
|
|
|
|
| |
That allows us to create a separate, isolated Action Cable server
instance within the same app.
|
| |
|
|\
| |
| | |
Action Cable: 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
```
|
|/ |
|
| |
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* 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.
|
| |
|
|\
| |
| | |
Add streams assert methods to ActionCable channel test case
|
| | |
|
|/
|
|
|
|
|
|
|
|
| |
Currently we sometimes find a redundant begin block in code review
(e.g. https://github.com/rails/rails/pull/33604#discussion_r209784205).
I'd like to enable `Style/RedundantBegin` cop to avoid that, since
rescue/else/ensure are allowed inside do/end blocks in Ruby 2.5
(https://bugs.ruby-lang.org/issues/12906), so we'd probably meets with
that situation than before.
|
|
|
|
| |
[timthez, Ilia Kasianenko]
|
| |
|
| |
|
|
|
|
| |
Fixes some typos.
|
|
|
|
|
|
|
| |
The hack was merged from action-cable-testing gem by mistake.
We don't need it in Rails 6.
(cherry picked from commit 92030ec4b4309835ed0e792229984a1f0a044cef)
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
In Ruby 2.3 or later, `String#+@` is available and `+@` is faster than `dup`.
```ruby
# frozen_string_literal: true
require "bundler/inline"
gemfile(true) do
source "https://rubygems.org"
gem "benchmark-ips"
end
Benchmark.ips do |x|
x.report('+@') { +"" }
x.report('dup') { "".dup }
x.compare!
end
```
```
$ ruby -v benchmark.rb
ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-linux]
Warming up --------------------------------------
+@ 282.289k i/100ms
dup 187.638k i/100ms
Calculating -------------------------------------
+@ 6.775M (± 3.6%) i/s - 33.875M in 5.006253s
dup 3.320M (± 2.2%) i/s - 16.700M in 5.032125s
Comparison:
+@: 6775299.3 i/s
dup: 3320400.7 i/s - 2.04x slower
```
|
| |
|
|
|
|
| |
Test `assert_no_broadcasts` failure
|
|
|
|
| |
Remove extra `:nodoc:` comment since private methods doesn't require that.
|
| |
|
| |
|
|
|
|
|
|
| |
If `env` is duped or otherwise not the same as the original `env` that was
generated at the top of rack middleware, it is impossible for the server hijack
proc to update the right `env` instance. Therefore, capturing the return value
is more reliable. This is the recommendation of the rack SPEC.
|
|\
| |
| |
| | |
Action Cable owns database connection, not Active Record
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Before this commit, the database connection used in Action Cable's
PostgreSQL adapter was "owned" by `ActiveRecord::Base.connection_pool`.
This meant that if, for example, `#clear_reloadable_connections!` was called on the pool, Active
Record would "steal" the database connection from Action Cable, and
would cause all sorts of issues. This became evident during file
reloads; despite Action Cable trying its hardest to return its borrowed
database connection to Active Record via `@pubsub.shutdown`, Active Record calls
`#clear_reloadable_connections!` on the connection pool, and due to the order of callbacks, Active
Record's callback was being executed first. This meant that if you tried
to rerender a view after a file was reloaded, you would have to wait
through Active Record's timeout and such.
Now, Action Cable takes direct ownership of the database connection it
uses. It removes the connection from the pool to avoid the situation
described above. Action Cable also makes sure to call `#disconnect!` on
the connection when appropriate, to match the previous behavior of
Active Record.
[ Jon Moss & Matthew Draper]
|
| |
| |
| |
| |
| |
| |
| | |
It is wrongly appeared as instance public methods in the doc.
http://api.rubyonrails.org/v5.1.6/classes/ActionCable/Channel/Callbacks.html
http://api.rubyonrails.org/v5.1.6/classes/ActiveRecord/Timestamp.html
|
| | |
|
| |
| |
| |
| | |
:tada::tada::tada:
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
### Summary
This PR changes .rubocop.yml.
Regarding the code using `if ... else ... end`, I think the coding style
that Rails expects is as follows.
```ruby
var = if cond
a
else
b
end
```
However, the current .rubocop.yml setting does not offense for the
following code.
```ruby
var = if cond
a
else
b
end
```
I think that the above code expects offense to be warned.
Moreover, the layout by autocorrect is unnatural.
```ruby
var = if cond
a
else
b
end
```
This PR adds a setting to .rubocop.yml to make an offense warning and
autocorrect as expected by the coding style.
And this change also fixes `case ... when ... end` together.
Also this PR itself is an example that arranges the layout using
`rubocop -a`.
### Other Information
Autocorrect of `Lint/EndAlignment` cop is `false` by default.
https://github.com/bbatsov/rubocop/blob/v0.51.0/config/default.yml#L1443
This PR changes this value to `true`.
Also this PR has changed it together as it is necessary to enable
`Layout/ElseAlignment` cop to make this behavior.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
pg-1.0.0 is just released and most Gemfiles don't restrict
it's version. But the version is checked when connecting to
the database, which leads to the following error:
Gem::LoadError: can't activate pg (~> 0.18), already activated pg-1.0.0
See also this pg issue:
https://bitbucket.org/ged/ruby-pg/issues/270/pg-100-x64-mingw32-rails-server-not-start
Preparation for pg-1.0 was done in commit f28a331023fab,
but the pg version constraint was not yet relaxed.
|
| | |
|
| | |
|
| |
| |
| |
| | |
Follow up of #31004.
|
| | |
|
| |
| |
| |
| | |
This basically reverts f851e1f705f26d8f92f0fc1b265b20bc389d23cb
|
|\ \
| | |
| | | |
redis-rb 4.0 support
|