aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeremy Daer <jeremydaer@gmail.com>2016-04-16 16:24:43 -0700
committerJeremy Daer <jeremydaer@gmail.com>2016-04-16 16:24:43 -0700
commit4c4dd06aa6d6aaa55bd56eac1c439f944b6733d1 (patch)
tree875a35d67d9ac94e8fc5f1457c6505baa0cda9d4
parentbca187219843fd49aba6415880d07fe8cb19f5f5 (diff)
parentaa757d0c1151f83104da241f30b1924d748a5d78 (diff)
downloadrails-4c4dd06aa6d6aaa55bd56eac1c439f944b6733d1.tar.gz
rails-4c4dd06aa6d6aaa55bd56eac1c439f944b6733d1.tar.bz2
rails-4c4dd06aa6d6aaa55bd56eac1c439f944b6733d1.zip
Merge pull request #24574 from y-yagi/donot_remove_cable.js
don't remove `cable.js` when a channel is removed
-rw-r--r--actioncable/lib/rails/generators/channel/channel_generator.rb4
-rw-r--r--railties/test/generators/channel_generator_test.rb12
2 files changed, 15 insertions, 1 deletions
diff --git a/actioncable/lib/rails/generators/channel/channel_generator.rb b/actioncable/lib/rails/generators/channel/channel_generator.rb
index 3bcf5f1898..05fd21a954 100644
--- a/actioncable/lib/rails/generators/channel/channel_generator.rb
+++ b/actioncable/lib/rails/generators/channel/channel_generator.rb
@@ -13,7 +13,9 @@ module Rails
template "channel.rb", File.join('app/channels', class_path, "#{file_name}_channel.rb")
if options[:assets]
- template "assets/cable.js", "app/assets/javascripts/cable.js"
+ if self.behavior == :invoke
+ template "assets/cable.js", "app/assets/javascripts/cable.js"
+ end
template "assets/channel.coffee", File.join('app/assets/javascripts/channels', class_path, "#{file_name}.coffee")
end
diff --git a/railties/test/generators/channel_generator_test.rb b/railties/test/generators/channel_generator_test.rb
index 23d0c7b4a4..d58b54ac24 100644
--- a/railties/test/generators/channel_generator_test.rb
+++ b/railties/test/generators/channel_generator_test.rb
@@ -46,4 +46,16 @@ class ChannelGeneratorTest < Rails::Generators::TestCase
assert_file "app/assets/javascripts/cable.js"
end
+
+ def test_channel_on_revoke
+ run_generator ['chat']
+ run_generator ['chat'], behavior: :revoke
+
+ assert_no_file "app/channels/chat_channel.rb"
+ assert_no_file "app/assets/javascripts/channels/chat.coffee"
+
+ assert_file "app/channels/application_cable/channel.rb"
+ assert_file "app/channels/application_cable/connection.rb"
+ assert_file "app/assets/javascripts/cable.js"
+ end
end