From fc95836f8776b708ac30e4f1b83cc2a3cddfa77d Mon Sep 17 00:00:00 2001 From: Vladimir Dementyev Date: Sun, 13 Jan 2019 22:53:46 -0500 Subject: Add connection_test to app generator --- railties/lib/rails/generators/rails/app/app_generator.rb | 2 ++ .../test/channels/application_cable/connection_test.rb.tt | 13 +++++++++++++ railties/test/generators/app_generator_test.rb | 3 +++ 3 files changed, 18 insertions(+) create mode 100644 railties/lib/rails/generators/rails/app/templates/test/channels/application_cable/connection_test.rb.tt (limited to 'railties') diff --git a/railties/lib/rails/generators/rails/app/app_generator.rb b/railties/lib/rails/generators/rails/app/app_generator.rb index 33002790d4..e777590be8 100644 --- a/railties/lib/rails/generators/rails/app/app_generator.rb +++ b/railties/lib/rails/generators/rails/app/app_generator.rb @@ -213,6 +213,7 @@ module Rails 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 @@ -440,6 +441,7 @@ module Rails if options[:skip_action_cable] remove_dir "app/javascript/channels" remove_dir "app/channels" + remove_dir "test/channels" end end diff --git a/railties/lib/rails/generators/rails/app/templates/test/channels/application_cable/connection_test.rb.tt b/railties/lib/rails/generators/rails/app/templates/test/channels/application_cable/connection_test.rb.tt new file mode 100644 index 0000000000..cc8337fc6d --- /dev/null +++ b/railties/lib/rails/generators/rails/app/templates/test/channels/application_cable/connection_test.rb.tt @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +require "test_helper" + +class ApplicationCable::ConnectionTest < ActionCable::Connection::TestCase + # test "connects with cookies" do + # cookies.signed[:user_id] = 42 + # + # connect + # + # assert_equal connection.user_id, "42" + # end +end diff --git a/railties/test/generators/app_generator_test.rb b/railties/test/generators/app_generator_test.rb index 839e6feb39..e0cd7f90ce 100644 --- a/railties/test/generators/app_generator_test.rb +++ b/railties/test/generators/app_generator_test.rb @@ -81,6 +81,7 @@ DEFAULT_APP_FILES = %w( test/test_helper.rb test/fixtures test/fixtures/files + test/channels/application_cable/connection_test.rb test/controllers test/models test/helpers @@ -363,6 +364,8 @@ class AppGeneratorTest < Rails::Generators::TestCase assert_file "#{app_root}/config/environments/production.rb" do |content| assert_no_match(/config\.action_cable/, content) end + + assert_no_file "#{app_root}/test/channels/application_cable/connection_test.rb" end def test_app_update_does_not_generate_bootsnap_contents_when_skip_bootsnap_is_given -- cgit v1.2.3