Patch #36358 » file-exists.diff
| Gemfile (作業コピー) | ||
|---|---|---|
|
end
|
||
|
local_gemfile = File.join(File.dirname(__FILE__), "Gemfile.local")
|
||
|
if File.exists?(local_gemfile)
|
||
|
if File.exist?(local_gemfile)
|
||
|
eval_gemfile local_gemfile
|
||
|
end
|
||
| app/models/import.rb (作業コピー) | ||
|---|---|---|
|
# 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
|
||
| config/application.rb (作業コピー) | ||
|---|---|---|
|
: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
|
||
| config/boot.rb (作業コピー) | ||
|---|---|---|
|
# 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'])
|
||
| config/routes.rb (作業コピー) | ||
|---|---|---|
|
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
|
||
| lib/redmine/scm/adapters/abstract_adapter.rb (作業コピー) | ||
|---|---|---|
|
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
|
||
| lib/redmine/thumbnail.rb (作業コピー) | ||
|---|---|---|
|
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}>"
|
||
| lib/redmine/utils.rb (作業コピー) | ||
|---|---|---|
|
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|
|
||
| lib/tasks/testing.rake (作業コピー) | ||
|---|---|---|
|
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
|
||
| ... | ... | |
|
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}"
|
||
| ... | ... | |
|
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
|
||
| test/extra/redmine_pm/repository_git_test_pm.rb (作業コピー) | ||
|---|---|---|
|
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
|
||
| test/extra/redmine_pm/repository_subversion_test_pm.rb (作業コピー) | ||
|---|---|---|
|
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
|
||
| test/functional/issues_controller_test.rb (作業コピー) | ||
|---|---|---|
|
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
|
||
| ... | ... | |
|
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
|
||
| ... | ... | |
|
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
|
||
| ... | ... | |
|
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
|
||
| test/unit/attachment_test.rb (作業コピー) | ||
|---|---|---|
|
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
|
||
| ... | ... | |
|
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
|
||
| test/unit/issue_import_test.rb (作業コピー) | ||
|---|---|---|
|
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
|
||