diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2015-12-21 18:58:08 -0200 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2015-12-21 18:58:08 -0200 |
commit | f51a30c66692a5da2d5152d5e7e6130d88480c03 (patch) | |
tree | 8cf708d286323be6b099cc90ee8e3946d0eaa9e9 | |
parent | daa890331e763a77759901d504601cf83a242504 (diff) | |
download | rails-f51a30c66692a5da2d5152d5e7e6130d88480c03.tar.gz rails-f51a30c66692a5da2d5152d5e7e6130d88480c03.tar.bz2 rails-f51a30c66692a5da2d5152d5e7e6130d88480c03.zip |
Use the generators options to not generate channel assets
-rw-r--r-- | actioncable/lib/rails/generators/channel/channel_generator.rb | 5 | ||||
-rw-r--r-- | railties/test/generators/channel_generator_test.rb | 8 |
2 files changed, 6 insertions, 7 deletions
diff --git a/actioncable/lib/rails/generators/channel/channel_generator.rb b/actioncable/lib/rails/generators/channel/channel_generator.rb index 925dd3d098..c5d398810a 100644 --- a/actioncable/lib/rails/generators/channel/channel_generator.rb +++ b/actioncable/lib/rails/generators/channel/channel_generator.rb @@ -5,11 +5,14 @@ module Rails argument :actions, type: :array, default: [], banner: "method method" + class_option :assets, type: :boolean + check_class_collision suffix: "Channel" def create_channel_file template "channel.rb", File.join('app/channels', class_path, "#{file_name}_channel.rb") - if Rails::Generators.options[:rails][:assets] + + if options[:assets] template "assets/channel.coffee", File.join('app/assets/javascripts/channels', class_path, "#{file_name}.coffee") end end diff --git a/railties/test/generators/channel_generator_test.rb b/railties/test/generators/channel_generator_test.rb index f58ff83ac9..c1f0c03fbf 100644 --- a/railties/test/generators/channel_generator_test.rb +++ b/railties/test/generators/channel_generator_test.rb @@ -17,17 +17,13 @@ class ChannelGeneratorTest < Rails::Generators::TestCase end end - def test_channel_asset_is_not_created - enable_assets = Rails::Generators.options[:rails][:assets] - Rails::Generators.options[:rails][:assets] = false - run_generator ['chat'] + def test_channel_asset_is_not_created_when_skip_assets_is_passed + run_generator ['chat', '--skip-assets'] 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" - ensure - Rails::Generators.options[:rails][:assets] = enable_assets end end |