file-exists.diff

Go MAEDA, 2021-12-26 13:03

Download (9.65 KB)

View differences:

Gemfile (作業コピー)
104 104
end
105 105

  
106 106
local_gemfile = File.join(File.dirname(__FILE__), "Gemfile.local")
107
if File.exists?(local_gemfile)
107
if File.exist?(local_gemfile)
108 108
  eval_gemfile local_gemfile
109 109
end
110 110

  
app/models/import.rb (作業コピー)
111 111

  
112 112
  # Returns true if the file to import exists
113 113
  def file_exists?
114
    filepath.present? && File.exists?(filepath)
114
    filepath.present? && File.exist?(filepath)
115 115
  end
116 116

  
117 117
  # Returns the headers as an array that
config/application.rb (作業コピー)
83 83
      :same_site => :lax
84 84
    )
85 85

  
86
    if File.exists?(File.join(File.dirname(__FILE__), 'additional_environment.rb'))
86
    if File.exist?(File.join(File.dirname(__FILE__), 'additional_environment.rb'))
87 87
      instance_eval File.read(File.join(File.dirname(__FILE__), 'additional_environment.rb'))
88 88
    end
89 89
  end
config/boot.rb (作業コピー)
3 3
# Set up gems listed in the Gemfile.
4 4
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
5 5

  
6
require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])
6
require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
config/routes.rb (作業コピー)
396 396

  
397 397
  Dir.glob File.expand_path("#{Redmine::Plugin.directory}/*") do |plugin_dir|
398 398
    file = File.join(plugin_dir, "config/routes.rb")
399
    if File.exists?(file)
399
    if File.exist?(file)
400 400
      begin
401 401
        instance_eval File.read(file)
402 402
      rescue SyntaxError, StandardError => e
lib/redmine/scm/adapters/abstract_adapter.rb (作業コピー)
216 216
            writable = false
217 217
            path = Redmine::Configuration['scm_stderr_log_file'].presence
218 218
            path ||= Rails.root.join("log/#{Rails.env}.scm.stderr.log").to_s
219
            if File.exists?(path)
219
            if File.exist?(path)
220 220
              if File.file?(path) && File.writable?(path)
221 221
                writable = true
222 222
              else
lib/redmine/thumbnail.rb (作業コピー)
36 36
      return nil unless convert_available?
37 37
      return nil if is_pdf && !gs_available?
38 38

  
39
      unless File.exists?(target)
39
      unless File.exist?(target)
40 40
        # Make sure we only invoke Imagemagick if the file type is allowed
41 41
        mime_type = File.open(source) {|f| Marcel::MimeType.for(f)}
42 42
        return nil if !ALLOWED_TYPES.include? mime_type
43 43
        return nil if is_pdf && mime_type != "application/pdf"
44 44

  
45 45
        directory = File.dirname(target)
46
        unless File.exists?(directory)
46
        unless File.exist?(directory)
47 47
          FileUtils.mkdir_p directory
48 48
        end
49 49
        size_option = "#{size}x#{size}>"
lib/redmine/utils.rb (作業コピー)
51 51

  
52 52
      def save_upload(upload, path)
53 53
        directory = File.dirname(path)
54
        unless File.exists?(directory)
54
        unless File.exist?(directory)
55 55
          FileUtils.mkdir_p directory
56 56
        end
57 57
        File.open(path, "wb") do |f|
lib/tasks/testing.rake (作業コピー)
31 31
      desc "Creates a test subversion repository"
32 32
      task :subversion => :create_dir do
33 33
        repo_path = "tmp/test/subversion_repository"
34
        unless File.exists?(repo_path)
34
        unless File.exist?(repo_path)
35 35
          system "svnadmin create #{repo_path}"
36 36
          system "gunzip < test/fixtures/repositories/subversion_repository.dump.gz | svnadmin load #{repo_path}"
37 37
        end
......
40 40
      desc "Creates a test mercurial repository"
41 41
      task :mercurial => :create_dir do
42 42
        repo_path = "tmp/test/mercurial_repository"
43
        unless File.exists?(repo_path)
43
        unless File.exist?(repo_path)
44 44
          bundle_path = "test/fixtures/repositories/mercurial_repository.hg"
45 45
          system "hg init #{repo_path}"
46 46
          system "hg -R #{repo_path} pull #{bundle_path}"
......
48 48
      end
49 49

  
50 50
      def extract_tar_gz(prefix)
51
        unless File.exists?("tmp/test/#{prefix}_repository")
51
        unless File.exist?("tmp/test/#{prefix}_repository")
52 52
          # system "gunzip < test/fixtures/repositories/#{prefix}_repository.tar.gz | tar -xv -C tmp/test"
53 53
          system "tar -xvz -C tmp/test -f test/fixtures/repositories/#{prefix}_repository.tar.gz"
54 54
        end
test/extra/redmine_pm/repository_git_test_pm.rb (作業コピー)
74 74
    Dir.mktmpdir do |dir|
75 75
      assert_success "clone", git_url, dir
76 76
      Dir.chdir(dir) do
77
        assert File.exists?(File.join(dir, "#{filename}"))
77
        assert File.exist?(File.join(dir, "#{filename}"))
78 78
      end
79 79
    end
80 80
  end
test/extra/redmine_pm/repository_subversion_test_pm.rb (作業コピー)
305 305
        assert_success "update"
306 306

  
307 307
        # checks that the working copy was updated
308
        assert File.exists?(File.join(dir, "#{filename}_copy"))
308
        assert File.exist?(File.join(dir, "#{filename}_copy"))
309 309
        assert File.directory?(File.join(dir, "#{filename}_dir"))
310 310
      end
311 311
    end
test/functional/issues_controller_test.rb (作業コピー)
4716 4716
    assert_equal 'text/plain', attachment.content_type
4717 4717
    assert_equal 'test file', attachment.description
4718 4718
    assert_equal 59, attachment.filesize
4719
    assert File.exists?(attachment.diskfile)
4719
    assert File.exist?(attachment.diskfile)
4720 4720
    assert_equal 59, File.size(attachment.diskfile)
4721 4721
  end
4722 4722

  
......
4780 4780

  
4781 4781
    attachment = Attachment.order('id DESC').first
4782 4782
    assert_equal 'testfile.txt', attachment.filename
4783
    assert File.exists?(attachment.diskfile)
4783
    assert File.exist?(attachment.diskfile)
4784 4784
    assert_nil attachment.container
4785 4785

  
4786 4786
    assert_select 'input[name=?][value=?]', 'attachments[p0][token]', attachment.token
......
6289 6289
    assert_equal 'text/plain', attachment.content_type
6290 6290
    assert_equal 'test file', attachment.description
6291 6291
    assert_equal 59, attachment.filesize
6292
    assert File.exists?(attachment.diskfile)
6292
    assert File.exist?(attachment.diskfile)
6293 6293
    assert_equal 59, File.size(attachment.diskfile)
6294 6294

  
6295 6295
    mail = ActionMailer::Base.deliveries.last
......
6323 6323

  
6324 6324
    attachment = Attachment.order('id DESC').first
6325 6325
    assert_equal 'testfile.txt', attachment.filename
6326
    assert File.exists?(attachment.diskfile)
6326
    assert File.exist?(attachment.diskfile)
6327 6327
    assert_nil attachment.container
6328 6328

  
6329 6329
    assert_select 'input[name=?][value=?]', 'attachments[p0][token]', attachment.token
test/unit/attachment_test.rb (作業コピー)
208 208
    copy = a.copy
209 209
    copy.save!
210 210

  
211
    assert File.exists?(diskfile)
211
    assert File.exist?(diskfile)
212 212
    a.destroy
213
    assert File.exists?(diskfile)
213
    assert File.exist?(diskfile)
214 214
    copy.destroy
215
    assert !File.exists?(diskfile)
215
    assert !File.exist?(diskfile)
216 216
  end
217 217

  
218 218
  def test_create_should_auto_assign_content_type
......
387 387
    assert_equal 59, attachment.filesize
388 388
    assert_equal 'test', attachment.description
389 389
    assert_equal 'text/plain', attachment.content_type
390
    assert File.exists?(attachment.diskfile)
390
    assert File.exist?(attachment.diskfile)
391 391
    assert_equal 59, File.size(attachment.diskfile)
392 392
  end
393 393

  
test/unit/issue_import_test.rb (作業コピー)
366 366
  def test_run_should_remove_the_file
367 367
    import = generate_import_with_mapping
368 368
    file_path = import.filepath
369
    assert File.exists?(file_path)
369
    assert File.exist?(file_path)
370 370

  
371 371
    import.run
372
    assert !File.exists?(file_path)
372
    assert !File.exist?(file_path)
373 373
  end
374 374

  
375 375
  def test_run_should_consider_project_shared_versions