Commit Graph

452 Commits

Author SHA1 Message Date
bogdanvlviv
d66d3a4bd1
Fix actionable test's assertion
Pull Request #32727 changed "mocha expects" in favor of `MethodCallAssertions`.
This commit fixes assertion that became less strict after the PR.
2018-05-28 09:20:24 +00:00
utilum
78288f75e1 remove unnecessary mocking in ActionCable tests 2018-05-22 02:29:18 +02:00
utilum
d1f58e9922 assert_called_with 2018-04-26 08:02:08 +02:00
utilum
94ceda00b9 assert_called 2018-04-26 08:02:08 +02:00
utilum
e4e25cc8dc assert_not_called 2018-04-26 08:02:08 +02:00
Ryuta Kamizono
e4a0a04883 Strip duplicated suffixes more strictly
In the previous code incorrectly removes intermediate words.
2018-04-22 14:30:07 +09:00
Daniel Colson
a1ac18671a Replace assert ! with assert_not
This autocorrects the violations after adding a custom cop in
3305c78dcd.
2018-04-19 08:11:33 -04:00
utilum
86cafe7c9d 2.6 warning: passing splat keyword arguments as a single Hash
Ruby 2.6.0 warns about this.

``` ruby -v
ruby 2.6.0dev (2018-04-04 trunk 63085) [x86_64-linux]
```

Before, see:
https://travis-ci.org/rails/rails/jobs/365740163#L1262-L1264
https://travis-ci.org/rails/rails/jobs/365944863#L2121-L2174
2018-04-15 10:09:38 +02:00
James Mead
30735ab726 Make Mocha setup explcitly Minitest-specific
This has been possible since Mocha v1.0 and makes it clear that we want
Mocha to integrate with Minitest, not Test::Unit.
2018-04-07 12:23:40 +01:00
Ryuta Kamizono
a07d068078 Class methods in the class_methods blocks are wrongly appeared in the doc
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
2018-04-04 09:04:15 +09:00
Rafael Mendonça França
ba0ae542ca
Remove changelog header for unreleased version
We only add the header when releasing to avoid some conflicts.

[ci skip]
2018-03-13 15:20:57 -04:00
Jeremy Daer
d4eb0dc89e Rails 6 requires Ruby 2.4.1+
Skipping over 2.4.0 to sidestep the `"symbol_from_string".to_sym.dup` bug.

References #32028
2018-02-17 15:34:57 -08:00
bogdanvlviv
0f98954a83
Clean up and consolidate .gitignores
* Global ignores at toplevel .gitignore
* Component-specific ignores in each toplevel directory
* Remove `actionview/test/tmp/.keep` for JRuby

```
rm actionview/test/tmp/ -fr
cd actionview/
bundle exec jruby -Itest test/template/digestor_test.rb
```

Related to #11743, #30392.

Closes #29978.
2018-02-17 14:26:19 -08:00
Jeremy Daer
1e526788e6 Rails 6 requires Ruby 2.3+ 2018-02-17 10:03:37 -08:00
Rafael Mendonça França
0ea8e7db1a Remove support to Ruby 2.2
Rails 6 will only support Ruby >= 2.3.
2018-02-16 18:52:10 -05:00
Rafael Mendonça França
1c383df324 Start Rails 6.0 development!!!
🎉🎉🎉
2018-01-30 18:51:17 -05:00
Daniel Colson
82c39e1a0b Use assert_empty and assert_not_empty 2018-01-25 23:32:59 -05:00
Daniel Colson
94333a4c31 Use assert_predicate and assert_not_predicate 2018-01-25 23:32:59 -05:00
Daniel Colson
211adb47e7 Change refute to assert_not 2018-01-25 23:32:58 -05:00
Matthew Draper
acbcef6094
Merge pull request #31732 from koic/enable_autocorrect_for_lint_end_alignment_cop
Enable autocorrect for `Lint/EndAlignment` cop
2018-01-19 17:49:21 +10:30
Jared Beck
e1473e0cbf Testing actioncable against websocket-driver 0.7.0 (#30711)
* Depend on websocket-driver >= 0.6.1
2018-01-18 15:32:26 -06:00
Koichi ITO
5ac6ec54a6 Enable autocorrect for Lint/EndAlignment cop
### 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.
2018-01-18 17:19:13 +09:00
Lars Kanis
f820dc2dea PostgreSQL: Allow pg-1.0 gem to be used with ActiveRecord
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.
2018-01-10 21:55:43 +01:00
Yoshiyuki Hirano
b20354afcc Bump license years for 2018 2017-12-31 22:36:55 +09:00
Rafael Mendonça França
2837d0f334
Preparing for 5.2.0.beta2 release 2017-11-28 14:41:02 -05:00
Fatos Morina
37cf9b3466 Fix typos and add a few suggestions 2017-11-28 19:27:43 +01:00
Rafael Mendonça França
cceeeb6e57
Preparing for 5.2.0.beta1 release 2017-11-27 14:50:03 -05:00
Fumiaki MATSUSHIMA
788c908577 Fix unstable test test_delegate_socket_errors_to_on_error_handler
I often face the following error when running test/connection/client_socket_test.rb:

```
$ bin/test test/connection/client_socket_test.rb:38
Run options: --seed 44035

# Running:

F

Failure:
ActionCable::Connection::ClientSocketTest#test_delegate_socket_errors_to_on_error_handler
[/app/actioncable/test/connection/client_socket_test.rb:47]:
--- expected
+++ actual
@@ -1 +1 @@
-["foo"]
+["Broken pipe", "Broken pipe", "Broken pipe", "foo"]
```

It can be reproduced easily by applying the following patch:

```
diff --git a/actioncable/test/connection/client_socket_test.rb b/actioncable/test/connection/client_socket_test.rb
index 2051216010..6bb9f13ea7 100644
--- a/actioncable/test/connection/client_socket_test.rb
+++ b/actioncable/test/connection/client_socket_test.rb
@@ -34,7 +34,8 @@ def on_error(message)
     @server.config.allowed_request_origins = %w( http://rubyonrails.com )
   end

-  test "delegate socket errors to on_error handler" do
+  1000.times do |i|
+  test "delegate socket errors to on_error handler #{i}" do
     run_in_eventmachine do
       connection = open_connection

@@ -47,6 +48,7 @@ def on_error(message)
       assert_equal %w[ foo ], connection.errors
     end
   end
+  end

   test "closes hijacked i/o socket at shutdown" do
     run_in_eventmachine do
```

The cause is writing io from different thread at the same time.

`connection.process` sends handshake message from [StreamEventLoop's thread][] whereas
`connection.handle_open` sends welcome message from current thread.

[StreamEventLoop's thread]: 067fc779c4/actioncable/lib/action_cable/connection/stream_event_loop.rb (L75)
2017-11-23 14:37:06 +09:00
Rafael Mendonça França
8dd76a7a6f
Use .tt extension to all the template files
Make clear that the files are not to be run for interpreters.

Fixes #23847.
Fixes #30690.
Closes #23878.
2017-11-13 15:23:28 -05:00
Jeremy Daer
8f2490b57f Action Cable: run Redis tests against a default config without a password
Simplify our dev testing and CI story since we're also testing against
Redis for the Active Support cache store.

Directly test whether db, host, password, etc are passed through as
config instead of spinning up a Redis server with a password set on it.
2017-11-13 01:34:59 -07:00
Ryuta Kamizono
146b1c2e33 Enable Style/RedundantReturn rubocop rule, and fixed a couple more
Follow up of #31004.
2017-11-01 07:32:04 +09:00
प्रथमेश Sonpatki
55fdb125db Remove CHANGELOG entry that was backported to Rails 5.1.3. [ci skip] (#30986)
- Backport commit: 7122a2cdc3
2017-10-25 22:56:38 +05:30
Rafael Mendonça França
48766e32d3
Removed deprected evented redis adapter 2017-10-23 12:50:45 -04:00
Akira Matsuda
40a8db6329 [Action Cable] require_relative => require
This basically reverts f851e1f705f26d8f92f0fc1b265b20bc389d23cb
2017-10-21 22:48:29 +09:00
Jeremy Daer
5fb282239d Merge pull request #30748 from jeremy/redis-rb-4.0.1
redis-rb 4.0 support
2017-10-08 16:14:55 -07:00
Jeremy Daer
53c516d88d
redis-rb 4.0 support
* Use `gem 'redis', '~> 4.0'` for new app Gemfiles
* Loosen Action Cable redis-rb dep to `>= 3.3, < 5`
* Bump redis-namespace for looser Redis version dep
* Avoid using the underlying `redis.client` directly
* Use `Redis.new` instead of `Redis.connect`
2017-10-08 15:37:54 -07:00
Jeremy Daer
55a2c101b2
Distinguish missing adapter gems from load errors within the adapter
* When the adapter is missing, raise an exception that points out config
  typos and missing Gemfile entries. (We can assume that a non-builtin
  adapter was used since these are always available.)
* When loading an adapter raises a LoadError, prefix its error message
  to indicate that the adapter is likely missing an optional dependency.
2017-10-08 14:47:51 -07:00
Richard Machielse
4b629eca21
ActionCable: use find method when unsubscribing
If a frontend for some reason tries to unsubscribe from a non existing subscription, the following error is logged:

Could not execute command from ({"command"=>"unsubscribe", "identifier"=>"{\"channel\":\"SomeChannel\"}"}) [NoMethodError - undefined method `unsubscribe_from_channel' for nil:NilClass]

Instead, it will now properly log:

Could not execute command from ({"command"=>"unsubscribe", "identifier"=>"{\"channel\":\"SomeChannel\"}"}) [RuntimeError - Unable to find subscription with identifier: {"channel":"SomeChannel"}]
2017-09-26 11:47:55 +02:00
Yauheni Dakuka
c9527652c7 Fix quotes [ci skip] 2017-09-18 09:38:47 +03:00
Matthew Draper
2e6658ae51 Clarify intentions around method redefinitions
Don't use remove_method or remove_possible_method just before a new
definition: at best the purpose is unclear, and at worst it creates a
race condition.

Instead, prefer redefine_method when practical, and
silence_redefinition_of_method otherwise.
2017-09-01 14:27:13 +09:30
Yoshiyuki Hirano
5eb831d3f2 Use typewriter in doc for Action Cable [ci skip] 2017-08-26 07:56:46 +09:00
Yoshiyuki Hirano
3a11e0586e Update MIT licenses link [ci skip] 2017-08-22 08:46:02 +09:00
Matthew Draper
1da7fa8728 Attributes are protected, not private, to avoid the warning 2017-08-20 01:07:05 +09:30
Jon Moss
f84019cd63 Capitalize Redis
[ci skip]
2017-08-17 10:55:10 -04:00
Koichi ITO
7c260ae201 Fix RuboCop offenses
And enable `context_dependent` of Style/BracesAroundHashParameters cop.
2017-08-16 17:55:25 +09:00
Ryuta Kamizono
67f1b51f85 Remove unused close_connection in Action Cable tests (#30195) 2017-08-11 14:09:53 -04:00
Claudio B
af954ddd54 [ci skip] Prefer cookies.encrypted over signed (#30129)
In some examples and guides we are recommending to use code like:

```ruby
verified_user = User.find_by(id: cookies.signed[:user_id])
```

My suggestion is to use instead:

```ruby
verified_user = User.find_by(id: cookies.encrypted[:user_id])
```

which invites users to prefer the "newer" encrypted cookies over the
"legacy" signed cookies.
2017-08-07 22:32:03 -05:00
Jon Moss
5e222f3d91 Lint actioncable/CHANGELOG.md
Postgres --> PostgreSQL
ActionCable --> Action Cable

[ci skip]
2017-08-06 22:14:10 -04:00
Kir Shatrov
385825fb70 Use frozen string literal in actioncable/ 2017-07-23 23:30:29 +03:00
Kir Shatrov
87bf94d1ce Make actioncable ready for frozen strings 2017-07-23 23:20:40 +03:00