aboutsummaryrefslogtreecommitdiffstats
path: root/railties
diff options
context:
space:
mode:
authorRyo Hashimoto <ryohashimoto@gmail.com>2015-12-19 13:43:11 +0900
committerRyo Hashimoto <ryohashimoto@gmail.com>2015-12-19 13:43:11 +0900
commit61366f5a3db91cae4313cc9f19396e96cddf643a (patch)
treecc9d9ddf1e9cc1856bc0f4ebec9555d607ad3971 /railties
parent914a45b5fef39c436322bca02566d0d11e1cbb84 (diff)
downloadrails-61366f5a3db91cae4313cc9f19396e96cddf643a.tar.gz
rails-61366f5a3db91cae4313cc9f19396e96cddf643a.tar.bz2
rails-61366f5a3db91cae4313cc9f19396e96cddf643a.zip
Action Cable channel generator should not create JS assets in --api mode
Diffstat (limited to 'railties')
-rw-r--r--railties/test/generators/channel_generator_test.rb30
1 files changed, 30 insertions, 0 deletions
diff --git a/railties/test/generators/channel_generator_test.rb b/railties/test/generators/channel_generator_test.rb
new file mode 100644
index 0000000000..5cc1cd83b1
--- /dev/null
+++ b/railties/test/generators/channel_generator_test.rb
@@ -0,0 +1,30 @@
+require 'generators/generators_test_helper'
+require 'rails/generators/channel/channel_generator'
+
+class ChannelGeneratorTest < Rails::Generators::TestCase
+ include GeneratorsTestHelper
+ tests Rails::Generators::ChannelGenerator
+
+ def test_channel_is_created
+ run_generator ['chat']
+
+ assert_file "app/channels/chat_channel.rb" do |channel|
+ assert_match(/class ChatChannel < ApplicationCable::Channel/, channel)
+ end
+
+ assert_file "app/assets/javascripts/channels/chat.coffee" do |channel|
+ assert_match(/App.cable.subscriptions.create "ChatChannel"/, channel)
+ end
+ end
+
+ def test_channel_asset_is_not_created
+ Rails::Generators.options[:rails][:assets] = false
+ run_generator ['chat']
+
+ assert_file "app/channels/chat_channel.rb" do |channel|
+ assert_match(/class ChatChannel < ApplicationCable::Channel/, channel)
+ end
+
+ assert_no_file "app/assets/javascripts/channels/chat.coffee"
+ end
+end