aboutsummaryrefslogtreecommitdiffstats
path: root/railties
diff options
context:
space:
mode:
authorYoong Kang Lim <yoongkang.lim@gmail.com>2015-05-26 21:52:10 +1000
committerGodfrey Chan <godfreykfc@gmail.com>2015-05-30 00:44:12 -0700
commitf06ce4c12a396795a3b2c1812951d9277bcb3a82 (patch)
treebbebbb70cfe0b71deacd3347aa67517102e88aab /railties
parent6fc83f8efeb1637af5d17b0d7b0c4b2e3db3c001 (diff)
downloadrails-f06ce4c12a396795a3b2c1812951d9277bcb3a82.tar.gz
rails-f06ce4c12a396795a3b2c1812951d9277bcb3a82.tar.bz2
rails-f06ce4c12a396795a3b2c1812951d9277bcb3a82.zip
Generate a `.keep` file in `tmp` folder
A lot of scripts assumes the existence of this folder and most would fail if it is absent. One example of this is `rake restart` (before the previous commit) – it tries to `touch tmp/restart.txt`, which would fail if `tmp` does not exist, which was the case for a freshly-cloned project as `tmp` is `.gitignored` by default. See #20299. [Yoong Kang Lim, Sunny Juneja]
Diffstat (limited to 'railties')
-rw-r--r--railties/CHANGELOG.md7
-rw-r--r--railties/lib/rails/generators/rails/app/app_generator.rb1
-rw-r--r--railties/lib/rails/generators/rails/app/templates/gitignore3
-rw-r--r--railties/test/generators/app_generator_test.rb27
4 files changed, 37 insertions, 1 deletions
diff --git a/railties/CHANGELOG.md b/railties/CHANGELOG.md
index 02fdaf09e0..d2662d61da 100644
--- a/railties/CHANGELOG.md
+++ b/railties/CHANGELOG.md
@@ -1,3 +1,10 @@
+* 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
diff --git a/railties/lib/rails/generators/rails/app/app_generator.rb b/railties/lib/rails/generators/rails/app/app_generator.rb
index 1047a2c429..152c26860e 100644
--- a/railties/lib/rails/generators/rails/app/app_generator.rb
+++ b/railties/lib/rails/generators/rails/app/app_generator.rb
@@ -141,6 +141,7 @@ module Rails
end
def tmp
+ empty_directory_with_keep_file "tmp"
empty_directory "tmp/cache"
empty_directory "tmp/cache/assets"
end
diff --git a/railties/lib/rails/generators/rails/app/templates/gitignore b/railties/lib/rails/generators/rails/app/templates/gitignore
index e4a00ad181..1b8cf8a9fa 100644
--- a/railties/lib/rails/generators/rails/app/templates/gitignore
+++ b/railties/lib/rails/generators/rails/app/templates/gitignore
@@ -15,7 +15,8 @@
<% end -%>
# Ignore all logfiles and tempfiles.
/log/*
+/tmp/*
<% if keeps? -%>
!/log/.keep
+!/tmp/.keep
<% end -%>
-/tmp
diff --git a/railties/test/generators/app_generator_test.rb b/railties/test/generators/app_generator_test.rb
index 2bfa05a0b8..af1c05cab1 100644
--- a/railties/test/generators/app_generator_test.rb
+++ b/railties/test/generators/app_generator_test.rb
@@ -44,6 +44,7 @@ DEFAULT_APP_FILES = %w(
vendor/assets
vendor/assets/stylesheets
vendor/assets/javascripts
+ tmp
tmp/cache
tmp/cache/assets
)
@@ -606,6 +607,32 @@ class AppGeneratorTest < Rails::Generators::TestCase
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/