Skip to content

Commit 6f0d51e

Browse files
committed
Correctly check whether Action Cable is enabled in AuthenticationGenerator
`AuthenticationGenerator` doesn't handle `skip_action_cable` option so far(`AppGenerator` only handles it). https://github.com/rails/rails/blob/e6429269fd5a8a7d728557f4e7d7f82c0ad1478c/railties/lib/rails/generators/rails/authentication/authentication_generator.rb#L6-L8 So the current check doesn't work correctly. Instead of depending on that option, this PR changes to check whether the engine is enabled or not. We already do the same thing. https://github.com/rails/rails/blob/e6429269fd5a8a7d728557f4e7d7f82c0ad1478c/railties/lib/rails/commands/app/update_command.rb#L71
1 parent 68714ea commit 6f0d51e

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

railties/lib/rails/generators/rails/authentication/authentication_generator.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def create_authentication_files
1919
template "app/controllers/concerns/authentication.rb"
2020
template "app/controllers/passwords_controller.rb"
2121

22-
template "app/channels/application_cable/connection.rb" unless options.skip_action_cable?
22+
template "app/channels/application_cable/connection.rb" if defined?(ActionCable::Engine)
2323

2424
template "app/mailers/passwords_mailer.rb"
2525

railties/test/generators/authentication_generator_test.rb

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,11 +108,14 @@ def test_model_test_is_skipped_if_test_framework_is_given
108108
end
109109

110110
def test_connection_class_skipped_without_action_cable
111-
generator([destination_root], skip_action_cable: true)
112-
111+
old_value = ActionCable.const_get(:Engine)
112+
ActionCable.send(:remove_const, :Engine)
113+
generator([destination_root])
113114
run_generator_instance
114115

115116
assert_no_file "app/channels/application_cable/connection.rb"
117+
ensure
118+
ActionCable.const_set(:Engine, old_value)
116119
end
117120

118121
private

0 commit comments

Comments
 (0)