1
0
mirror of https://github.com/meineerde/redmine.git synced 2026-02-05 00:23:24 +00:00

Use File.exist? instead of deprecated File.exists? (#36358).

git-svn-id: http://svn.redmine.org/redmine/trunk@21327 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Go MAEDA 2021-12-27 03:20:31 +00:00
parent 91c00f51ec
commit 4db7397d2a
13 changed files with 23 additions and 23 deletions

View 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

View 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

View 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'])

View 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

View 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

View 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}>"

View 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|

View 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

View 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

View 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

View 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

View 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

View 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