提交 c09ef94a 编写于 作者: L Lauro Caetano

Remove turbolinks when generating a new application based on a template

that skips it.

It can be skipped adding `add_gem_entry_filter { |gem| gem.name != "turbolinks" }` to the template.
上级 47229208
* 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.
......
......@@ -113,7 +113,7 @@ def gemfile_entries
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
......
......@@ -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 .
......@@ -182,7 +182,7 @@ def test_add_skip_entry
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 @@ def test_application_html_checks_gems
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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册