mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
revert dev:cache to rake task, fixes #23410
This commit is contained in:
parent
8526e9bed2
commit
ba2aea9807
6 changed files with 49 additions and 54 deletions
|
@ -14,6 +14,5 @@ command = ARGV.shift
|
|||
command = aliases[command] || command
|
||||
|
||||
require 'rails/command'
|
||||
require 'rails/commands/dev_cache'
|
||||
|
||||
Rails::Command.run(command, ARGV)
|
||||
|
|
|
@ -1,21 +0,0 @@
|
|||
require 'rails/command'
|
||||
|
||||
module Rails
|
||||
module Commands
|
||||
# This is a wrapper around the Rails dev:cache command
|
||||
class DevCache < Command
|
||||
set_banner :dev_cache, 'Toggle development mode caching on/off'
|
||||
def dev_cache
|
||||
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
|
||||
end
|
||||
end
|
|
@ -3,6 +3,7 @@ require 'rake'
|
|||
# Load Rails Rakefile extensions
|
||||
%w(
|
||||
annotations
|
||||
dev
|
||||
framework
|
||||
initializers
|
||||
log
|
||||
|
|
14
railties/lib/rails/tasks/dev.rake
Normal file
14
railties/lib/rails/tasks/dev.rake
Normal file
|
@ -0,0 +1,14 @@
|
|||
namespace :dev do
|
||||
desc 'Toggle development mode caching on/off'
|
||||
task :cache do
|
||||
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
|
34
railties/test/application/rake/dev_test.rb
Normal file
34
railties/test/application/rake/dev_test.rb
Normal file
|
@ -0,0 +1,34 @@
|
|||
require 'isolation/abstract_unit'
|
||||
|
||||
module ApplicationTests
|
||||
module RakeTests
|
||||
class RakeDevTest < ActiveSupport::TestCase
|
||||
include ActiveSupport::Testing::Isolation
|
||||
|
||||
def setup
|
||||
build_app
|
||||
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
|
||||
`rails dev:cache` # Create caching file.
|
||||
output = `rails dev:cache` # Delete caching file.
|
||||
assert_not File.exist?('tmp/caching-dev.txt')
|
||||
assert_match(/Development mode is no longer being cached/, output)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,32 +0,0 @@
|
|||
require_relative '../isolation/abstract_unit'
|
||||
|
||||
module CommandsTests
|
||||
class DevCacheTest < ActiveSupport::TestCase
|
||||
include ActiveSupport::Testing::Isolation
|
||||
|
||||
def setup
|
||||
build_app
|
||||
end
|
||||
|
||||
def teardown
|
||||
teardown_app
|
||||
end
|
||||
|
||||
test 'dev:cache creates file and outputs message' do
|
||||
Dir.chdir(app_path) do
|
||||
output = `rails dev:cache`
|
||||
assert File.exist?('tmp/caching-dev.txt')
|
||||
assert_match(%r{Development mode is now being cached}, output)
|
||||
end
|
||||
end
|
||||
|
||||
test 'dev:cache deletes file and outputs message' do
|
||||
Dir.chdir(app_path) do
|
||||
`rails dev:cache` # Create caching file.
|
||||
output = `rails dev:cache` # Delete caching file.
|
||||
assert_not File.exist?('tmp/caching-dev.txt')
|
||||
assert_match(%r{Development mode is no longer being cached}, output)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue