diff options
author | Guillermo Iguaran <guilleiguaran@gmail.com> | 2013-10-27 11:53:04 -0700 |
---|---|---|
committer | Guillermo Iguaran <guilleiguaran@gmail.com> | 2013-10-27 11:53:04 -0700 |
commit | 494b62826b6257f145cce9ebbd58a1d842486621 (patch) | |
tree | fcaa2c71ff7d36f2d22dd58caf5a2bedf00f430a | |
parent | b7ca9b52fe23f979ca5c60039faeac3d844e3ee3 (diff) | |
parent | 84e261b9309d362a210ed55941f2852ec4230038 (diff) | |
download | rails-494b62826b6257f145cce9ebbd58a1d842486621.tar.gz rails-494b62826b6257f145cce9ebbd58a1d842486621.tar.bz2 rails-494b62826b6257f145cce9ebbd58a1d842486621.zip |
Merge pull request #12657 from robin850/skip-javascript
Removal of javascript related files when creating an app
5 files changed, 21 insertions, 14 deletions
diff --git a/railties/CHANGELOG.md b/railties/CHANGELOG.md index d12a1f21f8..8963f6e604 100644 --- a/railties/CHANGELOG.md +++ b/railties/CHANGELOG.md @@ -1,3 +1,8 @@ +* Removal of all javascript stuff (gems and files) when generating a new + application using the `--skip-javascript` option. + + *Robin Dupret* + * Make the application name snake cased when it contains spaces The application name is used to fill the `database.yml` and diff --git a/railties/lib/rails/generators/app_base.rb b/railties/lib/rails/generators/app_base.rb index 28a1a0b0f5..6cb3eed873 100644 --- a/railties/lib/rails/generators/app_base.rb +++ b/railties/lib/rails/generators/app_base.rb @@ -206,13 +206,6 @@ module Rails gem 'uglifier', '>= 1.3.0' GEMFILE - if options[:skip_javascript] - gemfile += <<-GEMFILE - #{coffee_gemfile_entry} - #{javascript_runtime_gemfile_entry} - GEMFILE - end - gemfile.gsub(/^[ \t]+/, '') end diff --git a/railties/lib/rails/generators/rails/app/app_generator.rb b/railties/lib/rails/generators/rails/app/app_generator.rb index 4e92f56b2d..6927cc52dd 100644 --- a/railties/lib/rails/generators/rails/app/app_generator.rb +++ b/railties/lib/rails/generators/rails/app/app_generator.rb @@ -129,7 +129,9 @@ module Rails end def vendor_javascripts - empty_directory_with_keep_file 'vendor/assets/javascripts' + unless options[:skip_javascript] + empty_directory_with_keep_file 'vendor/assets/javascripts' + end end def vendor_stylesheets @@ -226,6 +228,12 @@ module Rails build(:leftovers) end + def delete_js_folder_skipping_javascript + if options[:skip_javascript] + remove_dir 'app/assets/javascripts' + end + end + public_task :apply_rails_template, :run_bundle protected diff --git a/railties/lib/rails/generators/rails/app/templates/app/views/layouts/application.html.erb.tt b/railties/lib/rails/generators/rails/app/templates/app/views/layouts/application.html.erb.tt index c3d1578818..4cf47bd0a0 100644 --- a/railties/lib/rails/generators/rails/app/templates/app/views/layouts/application.html.erb.tt +++ b/railties/lib/rails/generators/rails/app/templates/app/views/layouts/application.html.erb.tt @@ -4,7 +4,6 @@ <title><%= camelized %></title> <%- if options[:skip_javascript] -%> <%%= stylesheet_link_tag "application", media: "all" %> - <%%= javascript_include_tag "application" %> <%- else -%> <%%= stylesheet_link_tag "application", media: "all", "data-turbolinks-track" => true %> <%%= javascript_include_tag "application", "data-turbolinks-track" => true %> diff --git a/railties/test/generators/app_generator_test.rb b/railties/test/generators/app_generator_test.rb index 24f01c878c..9b0c9ebf5b 100644 --- a/railties/test/generators/app_generator_test.rb +++ b/railties/test/generators/app_generator_test.rb @@ -298,15 +298,17 @@ class AppGeneratorTest < Rails::Generators::TestCase def test_javascript_is_skipped_if_required run_generator [destination_root, "--skip-javascript"] - assert_file "app/assets/javascripts/application.js" do |contents| - assert_no_match %r{^//=\s+require\s}, contents - end + + assert_no_file "app/assets/javascripts" + assert_no_file "vendor/assets/javascripts" + assert_file "app/views/layouts/application.html.erb" do |contents| assert_match(/stylesheet_link_tag\s+"application", media: "all" %>/, contents) - assert_match(/javascript_include_tag\s+"application" \%>/, contents) + assert_no_match(/javascript_include_tag\s+"application" \%>/, contents) end + assert_file "Gemfile" do |content| - assert_match(/coffee-rails/, content) + assert_no_match(/coffee-rails/, content) end end |