forked from rails/rails
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes rails#18876. Rake restart touches `tmp/restart.txt` to restart application on next request. Updated tests and documentation accordingly.
- Loading branch information
Showing
4 changed files
with
43 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ | |
log | ||
middleware | ||
misc | ||
restart | ||
routes | ||
statistics | ||
tmp | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
desc "Restart app by touching tmp/restart.txt" | ||
task restart: :environment do | ||
FileUtils.touch('tmp/restart.txt') | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
require "isolation/abstract_unit" | ||
|
||
module ApplicationTests | ||
module RakeTests | ||
class RakeRestartTest < ActiveSupport::TestCase | ||
include ActiveSupport::Testing::Isolation | ||
|
||
def setup | ||
build_app | ||
boot_rails | ||
end | ||
|
||
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` | ||
curr_mtime = File.mtime("tmp/restart.txt") | ||
assert_not_equal prev_mtime, curr_mtime | ||
end | ||
end | ||
end | ||
end | ||
end |