Remove channels from default app/ structure (#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
This commit is contained in:
parent
f805b35c1b
commit
3ce3a4e94c
@ -183,7 +183,8 @@ unsubscribing, or performing an action:
|
||||
|
||||
A *channel* encapsulates a logical unit of work, similar to what a controller does in a
|
||||
typical MVC setup. By default, Rails creates a parent `ApplicationCable::Channel` class
|
||||
(which extends [`ActionCable::Channel::Base`][]) for encapsulating shared logic between your channels.
|
||||
(which extends [`ActionCable::Channel::Base`][]) for encapsulating shared logic between your channels,
|
||||
when you use the channel generator for the first time.
|
||||
|
||||
#### Parent Channel Setup
|
||||
|
||||
@ -195,8 +196,7 @@ module ApplicationCable
|
||||
end
|
||||
```
|
||||
|
||||
Then you would create your own channel classes. For example, you could have a
|
||||
`ChatChannel` and an `AppearanceChannel`:
|
||||
Your own channel classes could then look like these examples:
|
||||
|
||||
```ruby
|
||||
# app/channels/chat_channel.rb
|
||||
|
@ -244,7 +244,6 @@ def test
|
||||
empty_directory_with_keep_file "test/helpers"
|
||||
empty_directory_with_keep_file "test/integration"
|
||||
|
||||
template "test/channels/application_cable/connection_test.rb"
|
||||
template "test/test_helper.rb"
|
||||
end
|
||||
|
||||
@ -546,8 +545,6 @@ def delete_action_mailer_files_skipping_action_mailer
|
||||
def delete_action_cable_files_skipping_action_cable
|
||||
if options[:skip_action_cable]
|
||||
remove_dir "app/javascript/channels"
|
||||
remove_dir "app/channels"
|
||||
remove_dir "test/channels"
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -1,4 +0,0 @@
|
||||
module ApplicationCable
|
||||
class Channel < ActionCable::Channel::Base
|
||||
end
|
||||
end
|
@ -1,4 +0,0 @@
|
||||
module ApplicationCable
|
||||
class Connection < ActionCable::Connection::Base
|
||||
end
|
||||
end
|
@ -1,13 +0,0 @@
|
||||
require "test_helper"
|
||||
|
||||
module ApplicationCable
|
||||
class ConnectionTest < ActionCable::Connection::TestCase
|
||||
# test "connects with cookies" do
|
||||
# cookies.signed[:user_id] = 42
|
||||
#
|
||||
# connect
|
||||
#
|
||||
# assert_equal connection.user_id, "42"
|
||||
# end
|
||||
end
|
||||
end
|
@ -71,7 +71,6 @@ def test_generator_if_skip_action_cable_is_given
|
||||
run_generator [destination_root, "--api", "--skip-action-cable"]
|
||||
assert_file "config/application.rb", /#\s+require\s+["']action_cable\/engine["']/
|
||||
assert_no_file "config/cable.yml"
|
||||
assert_no_file "app/channels"
|
||||
assert_file "Gemfile" do |content|
|
||||
assert_no_match(/"redis"/, content)
|
||||
end
|
||||
@ -136,7 +135,6 @@ def default_files
|
||||
Rakefile
|
||||
Dockerfile
|
||||
config.ru
|
||||
app/channels
|
||||
app/controllers
|
||||
app/mailers
|
||||
app/models
|
||||
|
@ -19,8 +19,6 @@
|
||||
Rakefile
|
||||
app/assets/images/.keep
|
||||
app/assets/stylesheets/application.css
|
||||
app/channels/application_cable/channel.rb
|
||||
app/channels/application_cable/connection.rb
|
||||
app/controllers/application_controller.rb
|
||||
app/controllers/concerns/.keep
|
||||
app/helpers/application_helper.rb
|
||||
@ -72,7 +70,6 @@
|
||||
script/.keep
|
||||
storage/.keep
|
||||
test/application_system_test_case.rb
|
||||
test/channels/application_cable/connection_test.rb
|
||||
test/controllers/.keep
|
||||
test/fixtures/files/.keep
|
||||
test/helpers/.keep
|
||||
@ -244,7 +241,6 @@ def test_app_update_does_not_generate_action_cable_contents_when_skip_action_cab
|
||||
assert_file "config/environments/production.rb" do |content|
|
||||
assert_no_match(/config\.action_cable/, content)
|
||||
end
|
||||
assert_no_file "test/channels/application_cable/connection_test.rb"
|
||||
end
|
||||
|
||||
def test_app_update_does_not_generate_bootsnap_contents_when_skip_bootsnap_is_given
|
||||
|
@ -27,8 +27,6 @@
|
||||
test/dummy/Rakefile
|
||||
test/dummy/app/assets/images/.keep
|
||||
test/dummy/app/assets/stylesheets/application.css
|
||||
test/dummy/app/channels/application_cable/channel.rb
|
||||
test/dummy/app/channels/application_cable/connection.rb
|
||||
test/dummy/app/controllers/application_controller.rb
|
||||
test/dummy/app/controllers/concerns/.keep
|
||||
test/dummy/app/helpers/application_helper.rb
|
||||
|
@ -334,9 +334,6 @@ def test_generator_if_skip_action_cable_is_given
|
||||
run_generator [destination_root, "--skip-action-cable", "--webpack"]
|
||||
assert_file "#{application_path}/config/application.rb", /#\s+require\s+["']action_cable\/engine["']/
|
||||
assert_no_file "#{application_path}/config/cable.yml"
|
||||
assert_no_file "#{application_path}/app/javascript/consumer.js"
|
||||
assert_no_directory "#{application_path}/app/javascript/channels"
|
||||
assert_no_directory "#{application_path}/app/channels"
|
||||
assert_file "Gemfile" do |content|
|
||||
assert_no_match(/"redis"/, content)
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user