Skip to content

Commit 3ce3a4e

Browse files
authored
Remove channels from default app/ structure (rails#52344)
* Remove channels from default app/ structure Now that Hotwire is the default, the majority of apps won't need custom channels. And those that do can get the files back via the generator. * Remove trailing space * Remove additional needless elements * No longer to be generated * No longer generated
1 parent f805b35 commit 3ce3a4e

File tree

9 files changed

+3
-38
lines changed

9 files changed

+3
-38
lines changed

guides/source/action_cable_overview.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,8 @@ unsubscribing, or performing an action:
183183

184184
A *channel* encapsulates a logical unit of work, similar to what a controller does in a
185185
typical MVC setup. By default, Rails creates a parent `ApplicationCable::Channel` class
186-
(which extends [`ActionCable::Channel::Base`][]) for encapsulating shared logic between your channels.
186+
(which extends [`ActionCable::Channel::Base`][]) for encapsulating shared logic between your channels,
187+
when you use the channel generator for the first time.
187188

188189
#### Parent Channel Setup
189190

@@ -195,8 +196,7 @@ module ApplicationCable
195196
end
196197
```
197198

198-
Then you would create your own channel classes. For example, you could have a
199-
`ChatChannel` and an `AppearanceChannel`:
199+
Your own channel classes could then look like these examples:
200200

201201
```ruby
202202
# app/channels/chat_channel.rb

railties/lib/rails/generators/rails/app/app_generator.rb

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,6 @@ def test
244244
empty_directory_with_keep_file "test/helpers"
245245
empty_directory_with_keep_file "test/integration"
246246

247-
template "test/channels/application_cable/connection_test.rb"
248247
template "test/test_helper.rb"
249248
end
250249

@@ -546,8 +545,6 @@ def delete_action_mailer_files_skipping_action_mailer
546545
def delete_action_cable_files_skipping_action_cable
547546
if options[:skip_action_cable]
548547
remove_dir "app/javascript/channels"
549-
remove_dir "app/channels"
550-
remove_dir "test/channels"
551548
end
552549
end
553550

railties/lib/rails/generators/rails/app/templates/app/channels/application_cable/channel.rb.tt

Lines changed: 0 additions & 4 deletions
This file was deleted.

railties/lib/rails/generators/rails/app/templates/app/channels/application_cable/connection.rb.tt

Lines changed: 0 additions & 4 deletions
This file was deleted.

railties/lib/rails/generators/rails/app/templates/test/channels/application_cable/connection_test.rb.tt

Lines changed: 0 additions & 13 deletions
This file was deleted.

railties/test/generators/api_app_generator_test.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ def test_generator_if_skip_action_cable_is_given
7171
run_generator [destination_root, "--api", "--skip-action-cable"]
7272
assert_file "config/application.rb", /#\s+require\s+["']action_cable\/engine["']/
7373
assert_no_file "config/cable.yml"
74-
assert_no_file "app/channels"
7574
assert_file "Gemfile" do |content|
7675
assert_no_match(/"redis"/, content)
7776
end
@@ -136,7 +135,6 @@ def default_files
136135
Rakefile
137136
Dockerfile
138137
config.ru
139-
app/channels
140138
app/controllers
141139
app/mailers
142140
app/models

railties/test/generators/app_generator_test.rb

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@
1919
Rakefile
2020
app/assets/images/.keep
2121
app/assets/stylesheets/application.css
22-
app/channels/application_cable/channel.rb
23-
app/channels/application_cable/connection.rb
2422
app/controllers/application_controller.rb
2523
app/controllers/concerns/.keep
2624
app/helpers/application_helper.rb
@@ -72,7 +70,6 @@
7270
script/.keep
7371
storage/.keep
7472
test/application_system_test_case.rb
75-
test/channels/application_cable/connection_test.rb
7673
test/controllers/.keep
7774
test/fixtures/files/.keep
7875
test/helpers/.keep
@@ -244,7 +241,6 @@ def test_app_update_does_not_generate_action_cable_contents_when_skip_action_cab
244241
assert_file "config/environments/production.rb" do |content|
245242
assert_no_match(/config\.action_cable/, content)
246243
end
247-
assert_no_file "test/channels/application_cable/connection_test.rb"
248244
end
249245

250246
def test_app_update_does_not_generate_bootsnap_contents_when_skip_bootsnap_is_given

railties/test/generators/plugin_generator_test.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@
2727
test/dummy/Rakefile
2828
test/dummy/app/assets/images/.keep
2929
test/dummy/app/assets/stylesheets/application.css
30-
test/dummy/app/channels/application_cable/channel.rb
31-
test/dummy/app/channels/application_cable/connection.rb
3230
test/dummy/app/controllers/application_controller.rb
3331
test/dummy/app/controllers/concerns/.keep
3432
test/dummy/app/helpers/application_helper.rb

railties/test/generators/shared_generator_tests.rb

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -334,9 +334,6 @@ def test_generator_if_skip_action_cable_is_given
334334
run_generator [destination_root, "--skip-action-cable", "--webpack"]
335335
assert_file "#{application_path}/config/application.rb", /#\s+require\s+["']action_cable\/engine["']/
336336
assert_no_file "#{application_path}/config/cable.yml"
337-
assert_no_file "#{application_path}/app/javascript/consumer.js"
338-
assert_no_directory "#{application_path}/app/javascript/channels"
339-
assert_no_directory "#{application_path}/app/channels"
340337
assert_file "Gemfile" do |content|
341338
assert_no_match(/"redis"/, content)
342339
end

0 commit comments

Comments
 (0)