Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tmp:create creates the same dirs that tmp:clear removes #48057

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 4 additions & 3 deletions guides/source/command_line.md
Original file line number Diff line number Diff line change
Expand Up @@ -651,10 +651,11 @@ The `Rails.root/tmp` directory is, like the *nix /tmp directory, the holding pla
The `tmp:` namespaced commands will help you clear and create the `Rails.root/tmp` directory:

* `bin/rails tmp:cache:clear` clears `tmp/cache`.
* `bin/rails tmp:sockets:clear` clears `tmp/sockets`.
* `bin/rails tmp:screenshots:clear` clears `tmp/screenshots`.
* `bin/rails tmp:clear` clears all cache, sockets, and screenshot files.
* `bin/rails tmp:create` creates tmp directories for cache, sockets, and pids.
* `bin/rails tmp:sockets:clear` clears `tmp/sockets`.
* `bin/rails tmp:storage:clear` clears `tmp/storage`.
* `bin/rails tmp:clear` clears all cache, screenshot, sockets, and storage files.
* `bin/rails tmp:create` creates tmp directories for cache, pids, screenshots, sockets, and storage.

### Miscellaneous

Expand Down
4 changes: 4 additions & 0 deletions railties/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
* `bin/rake tmp:create` now creates tmp/screenshots and tmp/storage directories

*Jason Karns*

* Trying to set a config key with the same name of a method now raises:

```ruby
Expand Down
13 changes: 7 additions & 6 deletions railties/lib/rails/tasks/tmp.rake
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
# frozen_string_literal: true

namespace :tmp do
desc "Clear cache, socket and screenshot files from tmp/ (narrow w/ tmp:cache:clear, tmp:sockets:clear, tmp:screenshots:clear)"
task clear: ["tmp:cache:clear", "tmp:sockets:clear", "tmp:screenshots:clear", "tmp:storage:clear"]
desc "Clear cache, screenshot, socket, and storage files from tmp/ (narrow w/ tmp:cache:clear, tmp:screenshots:clear, tmp:sockets:clear, tmp:storage:clear)"
task clear: ["tmp:cache:clear", "tmp:screenshots:clear", "tmp:sockets:clear", "tmp:storage:clear"]

tmp_dirs = [ "tmp/cache",
"tmp/sockets",
tmp_dirs = [ "tmp/cache/assets",
"tmp/pids",
"tmp/cache/assets" ]
"tmp/screenshots",
"tmp/sockets",
"tmp/storage" ]

tmp_dirs.each { |d| directory d }

desc "Create tmp directories for cache, sockets, and pids"
desc "Create tmp directories for cache, pids, screenshots, sockets, and storage"
task create: tmp_dirs

namespace :cache do
Expand Down
14 changes: 14 additions & 0 deletions railties/test/application/rake/tmp_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,20 @@ def teardown
FileUtils.remove_dir("#{app_path}/tmp")
rails "tmp:clear"
end

test "tmp:create creates cache, sockets, pids, screenshots, and storage folders" do
Dir.chdir(app_path) do
FileUtils.remove_dir("#{app_path}/tmp")

rails "tmp:create"

assert Dir.exist?("tmp/cache/assets")
assert Dir.exist?("tmp/sockets")
assert Dir.exist?("tmp/pids")
assert Dir.exist?("tmp/screenshots")
assert Dir.exist?("tmp/storage")
end
end
end
end
end