diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2013-11-21 17:51:33 -0800 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2013-11-21 17:51:33 -0800 |
commit | dfb1dbb719b67b2565495bf5ca6e4542cbccd127 (patch) | |
tree | 5639c905e606d01a85f6829b24ef7df1f2c9d05e | |
parent | 47229208fccb7fbb284935738beb74ad102d29ee (diff) | |
parent | c09ef94a494eb8d0f690a84bc82b2bddcfe13e1b (diff) | |
download | rails-dfb1dbb719b67b2565495bf5ca6e4542cbccd127.tar.gz rails-dfb1dbb719b67b2565495bf5ca6e4542cbccd127.tar.bz2 rails-dfb1dbb719b67b2565495bf5ca6e4542cbccd127.zip |
Merge pull request #12993 from laurocaetano/skip_turbolinks
Option to skip turbolinks
4 files changed, 21 insertions, 4 deletions
diff --git a/railties/CHANGELOG.md b/railties/CHANGELOG.md index 3822486412..0b252bf745 100644 --- a/railties/CHANGELOG.md +++ b/railties/CHANGELOG.md @@ -1,3 +1,11 @@ +* Remove turbolinks when generating a new application based on a template that skips it. + + Example + Skips turbolinks adding `add_gem_entry_filter { |gem| gem.name != "turbolinks" }` + to the template. + + *Lauro Caetano* + * Instrument an `load_config_initializer.railties` event on each load of configuration initializer from `config/initializers`. Subscribers should be attached before `load_config_initializers` initializer completed. diff --git a/railties/lib/rails/generators/app_base.rb b/railties/lib/rails/generators/app_base.rb index d79cf2b2f0..2022b4ed3d 100644 --- a/railties/lib/rails/generators/app_base.rb +++ b/railties/lib/rails/generators/app_base.rb @@ -113,7 +113,7 @@ module Rails end def add_gem_entry_filter - @gem_filter = lambda { |next_filter,entry| + @gem_filter = lambda { |next_filter, entry| yield(entry) && next_filter.call(entry) }.curry[@gem_filter] end diff --git a/railties/lib/rails/generators/rails/app/templates/app/assets/javascripts/application.js.tt b/railties/lib/rails/generators/rails/app/templates/app/assets/javascripts/application.js.tt index 8b91313e51..07ea09cdbd 100644 --- a/railties/lib/rails/generators/rails/app/templates/app/assets/javascripts/application.js.tt +++ b/railties/lib/rails/generators/rails/app/templates/app/assets/javascripts/application.js.tt @@ -13,6 +13,8 @@ <% unless options[:skip_javascript] -%> //= require <%= options[:javascript] %> //= require <%= options[:javascript] %>_ujs +<% if gemfile_entries.any? { |m| m.name == "turbolinks" } -%> //= require turbolinks <% end -%> +<% end -%> //= require_tree . diff --git a/railties/test/generators/app_generator_test.rb b/railties/test/generators/app_generator_test.rb index e6cda07ae5..8b0dc39d92 100644 --- a/railties/test/generators/app_generator_test.rb +++ b/railties/test/generators/app_generator_test.rb @@ -182,7 +182,7 @@ class AppGeneratorTest < Rails::Generators::TestCase template.unlink end - def test_application_html_checks_gems + def test_skip_turbolinks_when_it_is_not_on_gemfile template = Tempfile.open 'my_template' template.puts 'add_gem_entry_filter { |gem| gem.name != "turbolinks" }' template.flush @@ -191,11 +191,18 @@ class AppGeneratorTest < Rails::Generators::TestCase assert_file "Gemfile" do |contents| assert_no_match 'turbolinks', contents end - assert_file "Gemfile" do |contents| + + assert_file "app/views/layouts/application.html.erb" do |contents| assert_no_match 'turbolinks', contents end + assert_file "app/views/layouts/application.html.erb" do |contents| - assert_no_match 'turbolinks', contents + assert_no_match(/stylesheet_link_tag\s+"application", media: "all", "data-turbolinks-track" => true/, contents) + assert_no_match(/javascript_include_tag\s+"application", "data-turbolinks-track" => true/, contents) + end + + assert_file "app/assets/javascripts/application.js" do |contents| + assert_no_match %r{^//=\s+turbolinks\s}, contents end ensure template.close |