Browse files

Merge remote-tracking branch 'origin/master'

* origin/master:
  Removal of javascript related gems when creating an app

Conflicts:
	railties/lib/rails/generators/app_base.rb
  • Loading branch information...
2 parents f5c5d21 + 494b628 commit 2e11f8e32109f078da424f0e9a550edd4f222079 @tenderlove tenderlove committed Oct 27, 2013
View
5 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
View
5 railties/lib/rails/generators/app_base.rb
@@ -223,11 +223,6 @@ def assets_gemfile_entry
'>= 1.3.0',
'Use Uglifier as compressor for JavaScript assets')
- if options[:skip_javascript]
- gems << coffee_gemfile_entry
- gems << javascript_runtime_gemfile_entry
- end
-
gems
end
View
10 railties/lib/rails/generators/rails/app/app_generator.rb
@@ -129,7 +129,9 @@ def vendor
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
@@ -237,6 +239,12 @@ def finish_template
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
View
1 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 %>
View
12 railties/test/generators/app_generator_test.rb
@@ -298,15 +298,17 @@ def test_other_javascript_libraries
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

0 comments on commit 2e11f8e

Please sign in to comment.