Use File.exist? instead of File.exists?

We've noticed the following warning while testing the upgrade to
Ruby 3.0:

warning: File.exists? is deprecated; use File.exist? instead

We're adding a Rubocop rule so we don't call the deprecated method
in the future.
This commit is contained in:
Javi Martín
2023-01-14 22:24:08 +01:00
parent 023bc6eb59
commit 5e7b3f72a2
3 changed files with 19 additions and 16 deletions

View File

@@ -18,8 +18,8 @@ describe "files tasks" do
travel_to(2.days.from_now) { run_rake_task }
expect(File.exists?(image.file_path)).to be false
expect(File.exists?(document.file_path)).to be false
expect(File.exist?(image.file_path)).to be false
expect(File.exist?(document.file_path)).to be false
end
it "does not delete recent cached attachments" do
@@ -33,8 +33,8 @@ describe "files tasks" do
travel_to(2.minutes.from_now) { run_rake_task }
expect(File.exists?(image.file_path)).to be true
expect(File.exists?(document.file_path)).to be true
expect(File.exist?(image.file_path)).to be true
expect(File.exist?(document.file_path)).to be true
end
it "does not delete old regular attachments" do
@@ -43,8 +43,8 @@ describe "files tasks" do
travel_to(2.days.from_now) { run_rake_task }
expect(File.exists?(image.file_path)).to be true
expect(File.exists?(document.file_path)).to be true
expect(File.exist?(image.file_path)).to be true
expect(File.exist?(document.file_path)).to be true
end
end
end