]> source.dussan.org Git - redmine.git/commitdiff
Use File.exist? instead of deprecated File.exists? (#36358).
authorGo MAEDA <maeda@farend.jp>
Mon, 27 Dec 2021 03:20:31 +0000 (03:20 +0000)
committerGo MAEDA <maeda@farend.jp>
Mon, 27 Dec 2021 03:20:31 +0000 (03:20 +0000)
git-svn-id: http://svn.redmine.org/redmine/trunk@21327 e93f8b46-1217-0410-a6f0-8f06a7374b81

13 files changed:
app/models/import.rb
config/application.rb
config/boot.rb
config/routes.rb
lib/redmine/scm/adapters/abstract_adapter.rb
lib/redmine/thumbnail.rb
lib/redmine/utils.rb
lib/tasks/testing.rake
test/extra/redmine_pm/repository_git_test_pm.rb
test/extra/redmine_pm/repository_subversion_test_pm.rb
test/functional/issues_controller_test.rb
test/unit/attachment_test.rb
test/unit/issue_import_test.rb

index a9c40270a0650e404627f3d713da744f558d45df..5665d7316c36fca3c888280bb0155beaa3f63f62 100644 (file)
@@ -111,7 +111,7 @@ class Import < ActiveRecord::Base
 
   # Returns true if the file to import exists
   def file_exists?
-    filepath.present? && File.exists?(filepath)
+    filepath.present? && File.exist?(filepath)
   end
 
   # Returns the headers as an array that
index e74fcbf6783bed21414056db30478c73755ba3b4..902007d03c163cb1ecc5ec2f779d77c193816230 100644 (file)
@@ -83,7 +83,7 @@ module RedmineApp
       :same_site => :lax
     )
 
-    if File.exists?(File.join(File.dirname(__FILE__), 'additional_environment.rb'))
+    if File.exist?(File.join(File.dirname(__FILE__), 'additional_environment.rb'))
       instance_eval File.read(File.join(File.dirname(__FILE__), 'additional_environment.rb'))
     end
   end
index 4bb97ac510e7f265b6542758e196f873bdecbaca..7479b5affe3299ba80f2ce9f3cd41f013ac221b3 100644 (file)
@@ -3,4 +3,4 @@
 # Set up gems listed in the Gemfile.
 ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
 
-require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])
+require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
index efb6db8e1e2ef338b96a47764639ac42ed1b8599..b608d5b7f138a701f7f629367fc4258c8f3e950d 100644 (file)
@@ -396,7 +396,7 @@ Rails.application.routes.draw do
 
   Dir.glob File.expand_path("#{Redmine::Plugin.directory}/*") do |plugin_dir|
     file = File.join(plugin_dir, "config/routes.rb")
-    if File.exists?(file)
+    if File.exist?(file)
       begin
         instance_eval File.read(file)
       rescue SyntaxError, StandardError => e
index d0c3293a6e4f23f88604c9ef5a8c4ad8083f5867..4c12f4a1398f76234507cb2660bde522856129dd 100644 (file)
@@ -216,7 +216,7 @@ module Redmine
             writable = false
             path = Redmine::Configuration['scm_stderr_log_file'].presence
             path ||= Rails.root.join("log/#{Rails.env}.scm.stderr.log").to_s
-            if File.exists?(path)
+            if File.exist?(path)
               if File.file?(path) && File.writable?(path)
                 writable = true
               else
index bb5c0ac060a734124e60ebe356dcebe654d75262..c1da6aa41eeec9d8cebb116c8d55b2439d8b2c9e 100644 (file)
@@ -36,14 +36,14 @@ module Redmine
       return nil unless convert_available?
       return nil if is_pdf && !gs_available?
 
-      unless File.exists?(target)
+      unless File.exist?(target)
         # Make sure we only invoke Imagemagick if the file type is allowed
         mime_type = File.open(source) {|f| Marcel::MimeType.for(f)}
         return nil if !ALLOWED_TYPES.include? mime_type
         return nil if is_pdf && mime_type != "application/pdf"
 
         directory = File.dirname(target)
-        unless File.exists?(directory)
+        unless File.exist?(directory)
           FileUtils.mkdir_p directory
         end
         size_option = "#{size}x#{size}>"
index 2a8a044439993cae7d41b53a3f6b00f8ee147e19..386919a25bfd6a02f707542f16b2bba538768306 100644 (file)
@@ -51,7 +51,7 @@ module Redmine
 
       def save_upload(upload, path)
         directory = File.dirname(path)
-        unless File.exists?(directory)
+        unless File.exist?(directory)
           FileUtils.mkdir_p directory
         end
         File.open(path, "wb") do |f|
index 6a44c3eb7f4feb3c5c38f3849130a8b39442f252..3088a4c2dd6e480e91d1576177f07a114e7b75f5 100644 (file)
@@ -31,7 +31,7 @@ namespace :test do
       desc "Creates a test subversion repository"
       task :subversion => :create_dir do
         repo_path = "tmp/test/subversion_repository"
-        unless File.exists?(repo_path)
+        unless File.exist?(repo_path)
           system "svnadmin create #{repo_path}"
           system "gunzip < test/fixtures/repositories/subversion_repository.dump.gz | svnadmin load #{repo_path}"
         end
@@ -40,7 +40,7 @@ namespace :test do
       desc "Creates a test mercurial repository"
       task :mercurial => :create_dir do
         repo_path = "tmp/test/mercurial_repository"
-        unless File.exists?(repo_path)
+        unless File.exist?(repo_path)
           bundle_path = "test/fixtures/repositories/mercurial_repository.hg"
           system "hg init #{repo_path}"
           system "hg -R #{repo_path} pull #{bundle_path}"
@@ -48,7 +48,7 @@ namespace :test do
       end
 
       def extract_tar_gz(prefix)
-        unless File.exists?("tmp/test/#{prefix}_repository")
+        unless File.exist?("tmp/test/#{prefix}_repository")
           # system "gunzip < test/fixtures/repositories/#{prefix}_repository.tar.gz | tar -xv -C tmp/test"
           system "tar -xvz -C tmp/test -f test/fixtures/repositories/#{prefix}_repository.tar.gz"
         end
index fac1017b61e3fe7e0907edc9e052c5fe25a8a6d0..1cb8ec853255d9a2e73b7e506c59bc346cb9efce 100644 (file)
@@ -74,7 +74,7 @@ class RedminePmTest::RepositoryGitTest < RedminePmTest::TestCase
     Dir.mktmpdir do |dir|
       assert_success "clone", git_url, dir
       Dir.chdir(dir) do
-        assert File.exists?(File.join(dir, "#{filename}"))
+        assert File.exist?(File.join(dir, "#{filename}"))
       end
     end
   end
index 9934b3e904ec81c6751c0b8fc311624a5b43902b..ce0d628e6f822f4bf7ce19c6025832459ca0d4ab 100644 (file)
@@ -305,7 +305,7 @@ class RedminePmTest::RepositorySubversionTest < RedminePmTest::TestCase
         assert_success "update"
 
         # checks that the working copy was updated
-        assert File.exists?(File.join(dir, "#{filename}_copy"))
+        assert File.exist?(File.join(dir, "#{filename}_copy"))
         assert File.directory?(File.join(dir, "#{filename}_dir"))
       end
     end
index 434775e59c05f8091e88d86861c4549aee2953e3..52b63f1e00996ff6f4bd356e215e01d32a221350 100644 (file)
@@ -4716,7 +4716,7 @@ class IssuesControllerTest < Redmine::ControllerTest
     assert_equal 'text/plain', attachment.content_type
     assert_equal 'test file', attachment.description
     assert_equal 59, attachment.filesize
-    assert File.exists?(attachment.diskfile)
+    assert File.exist?(attachment.diskfile)
     assert_equal 59, File.size(attachment.diskfile)
   end
 
@@ -4780,7 +4780,7 @@ class IssuesControllerTest < Redmine::ControllerTest
 
     attachment = Attachment.order('id DESC').first
     assert_equal 'testfile.txt', attachment.filename
-    assert File.exists?(attachment.diskfile)
+    assert File.exist?(attachment.diskfile)
     assert_nil attachment.container
 
     assert_select 'input[name=?][value=?]', 'attachments[p0][token]', attachment.token
@@ -6289,7 +6289,7 @@ class IssuesControllerTest < Redmine::ControllerTest
     assert_equal 'text/plain', attachment.content_type
     assert_equal 'test file', attachment.description
     assert_equal 59, attachment.filesize
-    assert File.exists?(attachment.diskfile)
+    assert File.exist?(attachment.diskfile)
     assert_equal 59, File.size(attachment.diskfile)
 
     mail = ActionMailer::Base.deliveries.last
@@ -6323,7 +6323,7 @@ class IssuesControllerTest < Redmine::ControllerTest
 
     attachment = Attachment.order('id DESC').first
     assert_equal 'testfile.txt', attachment.filename
-    assert File.exists?(attachment.diskfile)
+    assert File.exist?(attachment.diskfile)
     assert_nil attachment.container
 
     assert_select 'input[name=?][value=?]', 'attachments[p0][token]', attachment.token
index 954c44269e0de68cb2bedc8799e78f1b7d7984ee..e0b53e07b87e12fb3dae5529223b4749fc48a05e 100644 (file)
@@ -208,11 +208,11 @@ class AttachmentTest < ActiveSupport::TestCase
     copy = a.copy
     copy.save!
 
-    assert File.exists?(diskfile)
+    assert File.exist?(diskfile)
     a.destroy
-    assert File.exists?(diskfile)
+    assert File.exist?(diskfile)
     copy.destroy
-    assert !File.exists?(diskfile)
+    assert !File.exist?(diskfile)
   end
 
   def test_create_should_auto_assign_content_type
@@ -387,7 +387,7 @@ class AttachmentTest < ActiveSupport::TestCase
     assert_equal 59, attachment.filesize
     assert_equal 'test', attachment.description
     assert_equal 'text/plain', attachment.content_type
-    assert File.exists?(attachment.diskfile)
+    assert File.exist?(attachment.diskfile)
     assert_equal 59, File.size(attachment.diskfile)
   end
 
index 1a74138905941d7fc00b30ea2d8a8f640bccfd31..cc16a27e53dc642e9d6243eac7565e1076a2ca80 100644 (file)
@@ -366,10 +366,10 @@ class IssueImportTest < ActiveSupport::TestCase
   def test_run_should_remove_the_file
     import = generate_import_with_mapping
     file_path = import.filepath
-    assert File.exists?(file_path)
+    assert File.exist?(file_path)
 
     import.run
-    assert !File.exists?(file_path)
+    assert !File.exist?(file_path)
   end
 
   def test_run_should_consider_project_shared_versions