Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #20961 from ccallebs/add-dev-mode-caching
Add dev caching toggle / server options
- Loading branch information
Showing
7 changed files
with
114 additions
and
2 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
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 |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
# Load Rails Rakefile extensions | ||
%w( | ||
annotations | ||
dev | ||
framework | ||
initializers | ||
log | ||
|
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,15 @@ | ||
namespace :dev do | ||
task :cache do | ||
desc 'Toggle development mode caching on/off' | ||
|
||
if File.exist? 'tmp/caching-dev.txt' | ||
File.delete 'tmp/caching-dev.txt' | ||
puts 'Development mode is no longer being cached.' | ||
else | ||
FileUtils.touch 'tmp/caching-dev.txt' | ||
puts 'Development mode is now being cached.' | ||
end | ||
|
||
FileUtils.touch 'tmp/restart.txt' | ||
end | ||
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,35 @@ | ||
require 'isolation/abstract_unit' | ||
|
||
module ApplicationTests | ||
module RakeTests | ||
class RakeDevTest < ActiveSupport::TestCase | ||
include ActiveSupport::Testing::Isolation | ||
|
||
def setup | ||
build_app | ||
boot_rails | ||
end | ||
|
||
def teardown | ||
teardown_app | ||
end | ||
|
||
test 'dev:cache creates file and outputs message' do | ||
Dir.chdir(app_path) do | ||
output = `rake dev:cache` | ||
assert File.exist?('tmp/caching-dev.txt') | ||
assert_match(/Development mode is now being cached/, output) | ||
end | ||
end | ||
|
||
test 'dev:cache deletes file and outputs message' do | ||
Dir.chdir(app_path) do | ||
output = `rake dev:cache` | ||
output = `rake dev:cache` | ||
assert_not File.exist?('tmp/caching-dev.txt') | ||
assert_match(/Development mode is no longer being cached/, output) | ||
end | ||
end | ||
end | ||
end | ||
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