Commit Graph

470 Commits

Author SHA1 Message Date
bogdanvlviv
86e7de7968
DRY in assert_broadcasts
Test `assert_no_broadcasts` failure
2018-08-23 12:39:03 +03:00
bogdanvlviv
d2ccf0c6f7
Simplify configuring of ActionCable.server.config.logger for actioncable tests
See `git grep "= Logger.new(nil)"`
2018-08-23 12:36:19 +03:00
bogdanvlviv
0e42d3db59
Clarify api docs of ActionCable::SubscriptionAdapter::Test
Remove extra `:nodoc:` comment since private methods doesn't require that.
2018-08-23 12:30:16 +03:00
Vladimir Dementyev
c11ca09962
Add Action Cable test case and test helper 2018-08-19 19:23:33 -04:00
Vladimir Dementyev
f7dd2d67d6
Add Action Cable test adapter 2018-08-19 19:06:30 -04:00
Bart de Water
eb5fea40a4 Enable Start/EndWith and RegexpMatch cops
In cases where the MatchData object is not used, this provides a speed-up:
https://github.com/JuanitoFatas/fast-ruby/#stringmatch-vs-stringmatch-vs-stringstart_withstringend_with-code-start-code-end
2018-07-28 17:37:17 -04:00
Alberto Almagro
e42af97345 Remove thirdparty FIXME
This FIXME belongs to a code example that was imported from the
internet. As we aren't going to do anything about it, I prefer to remove
it so it stops from appearing on searches.
2018-07-25 22:59:11 +02:00
Ryuta Kamizono
6f58b2cfc9 Enable Layout/EmptyLinesAroundBlockBody to reduce review cost in the future
We sometimes ask "✂️ extra blank lines" to a contributor in reviews like
https://github.com/rails/rails/pull/33337#discussion_r201509738.

It is preferable to deal automatically without depending on manpower.
2018-07-12 21:29:48 +09:00
Samuel Williams
93e185e1d4
Better compatibility with SPEC.
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.
2018-07-04 12:45:35 +12:00
utilum
436ec799a4 Remove redundant accessors
introduced in a0ea528b61.
2018-06-11 16:39:50 +02:00
Rafael França
9204c0c5fa
Merge pull request #33102 from bogdanvlviv/refactor-actioncable-tests
Refactor actioncable's tests
2018-06-08 18:54:57 -04:00
Rafael Mendonça França
c07c708cf6
Merge pull request #27577 from maclover7/jm-fix-27547
Action Cable owns database connection, not Active Record
2018-06-08 18:21:05 -04:00
bogdanvlviv
74a9a29277
Include ActiveSupport::Testing::MethodCallAssertions to ActionCable::TestCase
Remove all `include ActiveSupport::Testing::MethodCallAssertions`
in actioncable's tests since we can do it only in `ActionCable::TestCase`
in order to prevent code duplication.
We use the same approach for other modules of Rails.
2018-06-08 23:29:05 +03:00
bogdanvlviv
d97f1670bd
Inherit all actioncable's test classes from ActionCable::TestCase
We have defined `ActionCable::TestCase` in `actioncable/test/test_helper.rb`
that we can use in order to prevent code duplication and build common
interface for actioncable's test.
2018-06-08 23:23:06 +03:00
utilum
76f1404303 Remove mocha from ActionCable tests
Q.E.D.
2018-05-31 17:53:55 +02:00
utilum
a0ea528b61 Use Ruby instead of mocha 2018-05-31 17:48:20 +02:00
utilum
84854d9d05 Use minitest/mock instead of mocha 2018-05-31 17:48:20 +02:00
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