提交 d7cbdbef 编写于 作者: G Godfrey Chan

Merge pull request #20370 from manishspuri/master

Add tmp directory before touching
* Generator a `.keep` file in the `tmp` folder by default as many scripts
assume the existence of this folder and most would fail if it is absent.
See #20299.
*Yoong Kang Lim*, *Sunny Juneja*
* `config.static_index` configures directory `index.html` filename
Set `config.static_index` to serve a static directory index file not named
......
......@@ -141,6 +141,7 @@ def test
end
def tmp
empty_directory_with_keep_file "tmp"
empty_directory "tmp/cache"
empty_directory "tmp/cache/assets"
end
......
......@@ -25,5 +25,5 @@ chdir APP_ROOT do
system 'ruby bin/rake log:clear tmp:clear'
puts "\n== Restarting application server =="
touch 'tmp/restart.txt'
system 'ruby bin/rake restart'
end
......@@ -15,7 +15,8 @@
<% end -%>
# Ignore all logfiles and tempfiles.
/log/*
/tmp/*
<% if keeps? -%>
!/log/.keep
!/tmp/.keep
<% end -%>
/tmp
desc "Restart app by touching tmp/restart.txt"
task :restart do
FileUtils.mkdir_p('tmp')
FileUtils.touch('tmp/restart.txt')
end
......@@ -13,12 +13,12 @@ def setup
def teardown
teardown_app
end
test 'rake restart touches tmp/restart.txt' do
Dir.chdir(app_path) do
`rake restart`
assert File.exist?("tmp/restart.txt")
prev_mtime = File.mtime("tmp/restart.txt")
sleep(1)
`rake restart`
......@@ -26,6 +26,14 @@ def teardown
assert_not_equal prev_mtime, curr_mtime
end
end
test 'rake restart should work even if tmp folder does not exist' do
Dir.chdir(app_path) do
FileUtils.remove_dir('tmp')
`rake restart`
assert File.exist?('tmp/restart.txt')
end
end
end
end
end
......@@ -285,5 +285,12 @@ def test_template_load_initializers
assert_match(/Hello, World!/, output)
end
def test_tmp_clear_should_work_if_folder_missing
FileUtils.remove_dir("#{app_path}/tmp")
errormsg = Dir.chdir(app_path) { `bundle exec rake tmp:clear` }
assert_predicate $?, :success?
assert_empty errormsg
end
end
end
......@@ -44,6 +44,7 @@
vendor/assets
vendor/assets/stylesheets
vendor/assets/javascripts
tmp
tmp/cache
tmp/cache/assets
)
......@@ -606,6 +607,32 @@ def test_gitignore_when_non_sqlite3_db
end
end
def test_create_keeps
run_generator
folders_with_keep = %w(
app/assets/images
app/mailers
app/models
app/controllers/concerns
app/models/concerns
lib/tasks
lib/assets
log
test/fixtures
test/fixtures/files
test/controllers
test/mailers
test/models
test/helpers
test/integration
tmp
vendor/assets/stylesheets
)
folders_with_keep.each do |folder|
assert_file("#{folder}/.keep")
end
end
def test_psych_gem
run_generator
gem_regex = /gem 'psych',\s+'~> 2.0',\s+platforms: :rbx/
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册