aboutsummaryrefslogtreecommitdiffstats
path: root/railties/test
diff options
context:
space:
mode:
authoryuuji.yaginuma <yuuji.yaginuma@gmail.com>2017-06-22 22:17:18 +0900
committeryuuji.yaginuma <yuuji.yaginuma@gmail.com>2017-06-27 07:13:00 +0900
commit6fbd405a2eb585591bb57de5adae71f890a24af3 (patch)
tree42c7da14d4ab21bd7659f254e0fee47bd18aae53 /railties/test
parent61cc630ac7e7f8554dc049a3e5a2509c00303ef8 (diff)
downloadrails-6fbd405a2eb585591bb57de5adae71f890a24af3.tar.gz
rails-6fbd405a2eb585591bb57de5adae71f890a24af3.tar.bz2
rails-6fbd405a2eb585591bb57de5adae71f890a24af3.zip
Clear screenshots files in `tmp:clear` task
If system test fails, it creates screenshot under `tmp/screenshots`. https://github.com/rails/rails/blob/34fe2a4fc778d18b7fe6bdf3629c1481bee789b9/actionpack/lib/action_dispatch/system_testing/test_helpers/screenshot_helper.rb#L45 But currently, screenshot files is not cleared by `tmp:clear` task. This patch make clears screenshot files with `tmp:clear` task as well as other tmp files.
Diffstat (limited to 'railties/test')
-rw-r--r--railties/test/application/rake/tmp_test.rb36
1 files changed, 36 insertions, 0 deletions
diff --git a/railties/test/application/rake/tmp_test.rb b/railties/test/application/rake/tmp_test.rb
new file mode 100644
index 0000000000..bc9865b0de
--- /dev/null
+++ b/railties/test/application/rake/tmp_test.rb
@@ -0,0 +1,36 @@
+require "isolation/abstract_unit"
+
+module ApplicationTests
+ module RakeTests
+ class TmpTest < ActiveSupport::TestCase
+ include ActiveSupport::Testing::Isolation
+
+ def setup
+ build_app
+ end
+
+ def teardown
+ teardown_app
+ end
+
+ test "tmp:clear clear cache, socket and screenshot files" do
+ Dir.chdir(app_path) do
+ 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")
+
+ `rails tmp:clear`
+
+ 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
+ end
+ end
+end