2017-08-14 13:08:09 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-06-22 09:17:18 -04:00
|
|
|
require "isolation/abstract_unit"
|
|
|
|
|
|
|
|
module ApplicationTests
|
|
|
|
module RakeTests
|
|
|
|
class TmpTest < ActiveSupport::TestCase
|
2020-12-25 17:06:11 -05:00
|
|
|
include ActiveSupport::Testing::Isolation
|
2017-06-22 09:17:18 -04:00
|
|
|
|
|
|
|
def setup
|
|
|
|
build_app
|
|
|
|
end
|
|
|
|
|
|
|
|
def teardown
|
|
|
|
teardown_app
|
|
|
|
end
|
|
|
|
|
|
|
|
test "tmp:clear clear cache, socket and screenshot files" do
|
2020-12-25 17:06:11 -05:00
|
|
|
Dir.chdir(app_path) do
|
2017-06-22 09:17:18 -04:00
|
|
|
FileUtils.mkdir_p("tmp/cache")
|
|
|
|
FileUtils.touch("tmp/cache/cache_file")
|
|
|
|
|
|
|
|
FileUtils.mkdir_p("tmp/sockets")
|
|
|
|
FileUtils.touch("tmp/sockets/socket_file")
|
|
|
|
|
|
|
|
FileUtils.mkdir_p("tmp/screenshots")
|
|
|
|
FileUtils.touch("tmp/screenshots/fail.png")
|
|
|
|
|
2017-09-03 12:55:26 -04:00
|
|
|
rails "tmp:clear"
|
2017-06-22 09:17:18 -04:00
|
|
|
|
|
|
|
assert_not File.exist?("tmp/cache/cache_file")
|
|
|
|
assert_not File.exist?("tmp/sockets/socket_file")
|
|
|
|
assert_not File.exist?("tmp/screenshots/fail.png")
|
|
|
|
end
|
|
|
|
end
|
2017-07-01 20:13:55 -04:00
|
|
|
|
|
|
|
test "tmp:clear should work if folder missing" do
|
|
|
|
FileUtils.remove_dir("#{app_path}/tmp")
|
2017-09-03 12:55:26 -04:00
|
|
|
rails "tmp:clear"
|
2017-07-01 20:13:55 -04:00
|
|
|
end
|
2017-06-22 09:17:18 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|