Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
4cfcf1ee
R
rails
项目概览
张重言
/
rails
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
rails
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
4cfcf1ee
编写于
5月 26, 2017
作者:
M
Matthew Draper
提交者:
GitHub
5月 26, 2017
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #29176 from bogdanvlviv/define-path-with__dir__
Define path with __dir__
上级
88182317
40bdbce1
变更
117
展开全部
显示空白变更内容
内联
并排
Showing
117 changed file
with
197 addition
and
204 deletion
+197
-204
Gemfile
Gemfile
+1
-1
Rakefile
Rakefile
+1
-1
actioncable/README.md
actioncable/README.md
+1
-1
actioncable/Rakefile
actioncable/Rakefile
+4
-6
actioncable/actioncable.gemspec
actioncable/actioncable.gemspec
+1
-1
actioncable/lib/rails/generators/channel/channel_generator.rb
...oncable/lib/rails/generators/channel/channel_generator.rb
+1
-1
actioncable/test/test_helper.rb
actioncable/test/test_helper.rb
+1
-1
actionmailer/actionmailer.gemspec
actionmailer/actionmailer.gemspec
+1
-1
actionmailer/lib/rails/generators/mailer/mailer_generator.rb
actionmailer/lib/rails/generators/mailer/mailer_generator.rb
+1
-1
actionmailer/test/abstract_unit.rb
actionmailer/test/abstract_unit.rb
+2
-2
actionmailer/test/caching_test.rb
actionmailer/test/caching_test.rb
+1
-1
actionmailer/test/log_subscriber_test.rb
actionmailer/test/log_subscriber_test.rb
+1
-1
actionpack/Rakefile
actionpack/Rakefile
+1
-1
actionpack/actionpack.gemspec
actionpack/actionpack.gemspec
+1
-1
actionpack/lib/action_dispatch/journey/gtg/transition_table.rb
...npack/lib/action_dispatch/journey/gtg/transition_table.rb
+1
-1
actionpack/lib/action_dispatch/middleware/debug_exceptions.rb
...onpack/lib/action_dispatch/middleware/debug_exceptions.rb
+1
-1
actionpack/test/abstract_unit.rb
actionpack/test/abstract_unit.rb
+5
-5
actionpack/test/controller/action_pack_assertions_test.rb
actionpack/test/controller/action_pack_assertions_test.rb
+1
-1
actionpack/test/controller/api/data_streaming_test.rb
actionpack/test/controller/api/data_streaming_test.rb
+1
-1
actionpack/test/controller/caching_test.rb
actionpack/test/controller/caching_test.rb
+1
-1
actionpack/test/controller/helper_test.rb
actionpack/test/controller/helper_test.rb
+4
-4
actionpack/test/controller/integration_test.rb
actionpack/test/controller/integration_test.rb
+1
-1
actionpack/test/controller/live_stream_test.rb
actionpack/test/controller/live_stream_test.rb
+1
-1
actionpack/test/controller/mime/accept_format_test.rb
actionpack/test/controller/mime/accept_format_test.rb
+1
-1
actionpack/test/controller/new_base/render_file_test.rb
actionpack/test/controller/new_base/render_file_test.rb
+5
-5
actionpack/test/controller/new_base/render_implicit_action_test.rb
...k/test/controller/new_base/render_implicit_action_test.rb
+1
-1
actionpack/test/controller/render_test.rb
actionpack/test/controller/render_test.rb
+6
-6
actionpack/test/controller/send_file_test.rb
actionpack/test/controller/send_file_test.rb
+1
-1
actionpack/test/controller/test_case_test.rb
actionpack/test/controller/test_case_test.rb
+3
-3
actionpack/test/dispatch/request/multipart_params_parsing_test.rb
...ck/test/dispatch/request/multipart_params_parsing_test.rb
+1
-1
actionpack/test/dispatch/request/url_encoded_params_parsing_test.rb
.../test/dispatch/request/url_encoded_params_parsing_test.rb
+2
-2
actionview/Rakefile
actionview/Rakefile
+4
-6
actionview/actionview.gemspec
actionview/actionview.gemspec
+1
-1
actionview/lib/action_view.rb
actionview/lib/action_view.rb
+1
-1
actionview/test/abstract_unit.rb
actionview/test/abstract_unit.rb
+7
-7
actionview/test/actionpack/abstract/abstract_controller_test.rb
...view/test/actionpack/abstract/abstract_controller_test.rb
+2
-2
actionview/test/actionpack/abstract/helper_test.rb
actionview/test/actionpack/abstract/helper_test.rb
+2
-2
actionview/test/actionpack/controller/capture_test.rb
actionview/test/actionpack/controller/capture_test.rb
+1
-1
actionview/test/actionpack/controller/layout_test.rb
actionview/test/actionpack/controller/layout_test.rb
+3
-3
actionview/test/actionpack/controller/render_test.rb
actionview/test/actionpack/controller/render_test.rb
+6
-6
actionview/test/active_record_unit.rb
actionview/test/active_record_unit.rb
+3
-3
actionview/test/template/digestor_test.rb
actionview/test/template/digestor_test.rb
+1
-1
actionview/test/template/render_test.rb
actionview/test/template/render_test.rb
+2
-2
actionview/test/template/resolver_patterns_test.rb
actionview/test/template/resolver_patterns_test.rb
+1
-1
actionview/test/ujs/config.ru
actionview/test/ujs/config.ru
+1
-1
activejob/Rakefile
activejob/Rakefile
+2
-3
activejob/activejob.gemspec
activejob/activejob.gemspec
+1
-1
activejob/lib/rails/generators/job/job_generator.rb
activejob/lib/rails/generators/job/job_generator.rb
+1
-1
activejob/test/adapters/delayed_job.rb
activejob/test/adapters/delayed_job.rb
+1
-1
activejob/test/support/integration/dummy_app_template.rb
activejob/test/support/integration/dummy_app_template.rb
+1
-1
activejob/test/support/integration/helper.rb
activejob/test/support/integration/helper.rb
+1
-1
activemodel/Rakefile
activemodel/Rakefile
+3
-5
activemodel/activemodel.gemspec
activemodel/activemodel.gemspec
+1
-1
activemodel/lib/active_model.rb
activemodel/lib/active_model.rb
+1
-1
activemodel/lib/active_model/validations.rb
activemodel/lib/active_model/validations.rb
+1
-1
activerecord/Rakefile
activerecord/Rakefile
+3
-3
activerecord/activerecord.gemspec
activerecord/activerecord.gemspec
+1
-1
activerecord/lib/active_record.rb
activerecord/lib/active_record.rb
+1
-1
activerecord/lib/rails/generators/active_record.rb
activerecord/lib/rails/generators/active_record.rb
+1
-1
activerecord/test/cases/adapters/postgresql/bytea_test.rb
activerecord/test/cases/adapters/postgresql/bytea_test.rb
+1
-1
activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb
...associations/has_and_belongs_to_many_associations_test.rb
+1
-1
activerecord/test/cases/inheritance_test.rb
activerecord/test/cases/inheritance_test.rb
+1
-1
activerecord/test/cases/reload_models_test.rb
activerecord/test/cases/reload_models_test.rb
+1
-1
activerecord/test/cases/yaml_serialization_test.rb
activerecord/test/cases/yaml_serialization_test.rb
+2
-2
activerecord/test/config.rb
activerecord/test/config.rb
+1
-1
activesupport/activesupport.gemspec
activesupport/activesupport.gemspec
+1
-1
activesupport/bin/generate_tables
activesupport/bin/generate_tables
+1
-1
activesupport/lib/active_support/core_ext.rb
activesupport/lib/active_support/core_ext.rb
+1
-1
activesupport/lib/active_support/deprecation/reporting.rb
activesupport/lib/active_support/deprecation/reporting.rb
+1
-1
activesupport/lib/active_support/i18n.rb
activesupport/lib/active_support/i18n.rb
+1
-1
activesupport/lib/active_support/multibyte/unicode.rb
activesupport/lib/active_support/multibyte/unicode.rb
+1
-1
activesupport/test/dependencies_test.rb
activesupport/test/dependencies_test.rb
+10
-10
activesupport/test/dependencies_test_helpers.rb
activesupport/test/dependencies_test_helpers.rb
+1
-1
activesupport/test/testing/file_fixtures_test.rb
activesupport/test/testing/file_fixtures_test.rb
+2
-2
activesupport/test/xml_mini/jdom_engine_test.rb
activesupport/test/xml_mini/jdom_engine_test.rb
+1
-1
guides/bug_report_templates/action_controller_gem.rb
guides/bug_report_templates/action_controller_gem.rb
+1
-1
guides/bug_report_templates/action_controller_master.rb
guides/bug_report_templates/action_controller_master.rb
+1
-1
guides/rails_guides/helpers.rb
guides/rails_guides/helpers.rb
+1
-1
guides/source/generators.md
guides/source/generators.md
+2
-2
guides/source/rails_application_templates.md
guides/source/rails_application_templates.md
+1
-1
guides/source/security.md
guides/source/security.md
+1
-1
rails.gemspec
rails.gemspec
+1
-1
railties/Rakefile
railties/Rakefile
+5
-5
railties/exe/rails
railties/exe/rails
+2
-2
railties/lib/rails/application_controller.rb
railties/lib/rails/application_controller.rb
+1
-1
railties/lib/rails/command/actions.rb
railties/lib/rails/command/actions.rb
+1
-1
railties/lib/rails/engine.rb
railties/lib/rails/engine.rb
+1
-1
railties/lib/rails/generators.rb
railties/lib/rails/generators.rb
+1
-1
railties/lib/rails/generators/base.rb
railties/lib/rails/generators/base.rb
+1
-1
railties/lib/rails/generators/css/assets/assets_generator.rb
railties/lib/rails/generators/css/assets/assets_generator.rb
+1
-1
railties/lib/rails/generators/js/assets/assets_generator.rb
railties/lib/rails/generators/js/assets/assets_generator.rb
+1
-1
railties/lib/rails/generators/rails/app/app_generator.rb
railties/lib/rails/generators/rails/app/app_generator.rb
+1
-1
railties/lib/rails/generators/rails/app/templates/bin/bundle
railties/lib/rails/generators/rails/app/templates/bin/bundle
+1
-1
railties/lib/rails/generators/rails/app/templates/bin/setup.tt
...ies/lib/rails/generators/rails/app/templates/bin/setup.tt
+1
-1
railties/lib/rails/generators/rails/app/templates/bin/update.tt
...es/lib/rails/generators/rails/app/templates/bin/update.tt
+1
-1
railties/lib/rails/generators/rails/app/templates/test/test_helper.rb
.../rails/generators/rails/app/templates/test/test_helper.rb
+1
-1
railties/lib/rails/generators/rails/generator/templates/%file_name%_generator.rb.tt
...ors/rails/generator/templates/%file_name%_generator.rb.tt
+1
-1
railties/lib/rails/generators/rails/plugin/templates/%name%.gemspec
...ib/rails/generators/rails/plugin/templates/%name%.gemspec
+1
-1
railties/lib/rails/generators/rails/plugin/templates/Rakefile
...ties/lib/rails/generators/rails/plugin/templates/Rakefile
+1
-1
railties/lib/rails/generators/rails/plugin/templates/bin/rails.tt
.../lib/rails/generators/rails/plugin/templates/bin/rails.tt
+4
-4
railties/lib/rails/generators/rails/plugin/templates/bin/test.tt
...s/lib/rails/generators/rails/plugin/templates/bin/test.tt
+1
-1
railties/lib/rails/generators/rails/plugin/templates/test/test_helper.rb
...ils/generators/rails/plugin/templates/test/test_helper.rb
+4
-4
railties/lib/rails/generators/test_case.rb
railties/lib/rails/generators/test_case.rb
+2
-2
railties/lib/rails/generators/testing/behaviour.rb
railties/lib/rails/generators/testing/behaviour.rb
+2
-2
railties/lib/rails/tasks/framework.rake
railties/lib/rails/tasks/framework.rake
+1
-1
railties/railties.gemspec
railties/railties.gemspec
+1
-1
railties/test/abstract_unit.rb
railties/test/abstract_unit.rb
+1
-1
railties/test/application/test_runner_test.rb
railties/test/application/test_runner_test.rb
+1
-1
railties/test/code_statistics_calculator_test.rb
railties/test/code_statistics_calculator_test.rb
+1
-1
railties/test/code_statistics_test.rb
railties/test/code_statistics_test.rb
+1
-1
railties/test/fixtures/lib/generators/usage_template/usage_template_generator.rb
...lib/generators/usage_template/usage_template_generator.rb
+1
-1
railties/test/generators/generators_test_helper.rb
railties/test/generators/generators_test_helper.rb
+2
-2
railties/test/generators/plugin_generator_test.rb
railties/test/generators/plugin_generator_test.rb
+6
-6
railties/test/generators_test.rb
railties/test/generators_test.rb
+1
-1
railties/test/isolation/abstract_unit.rb
railties/test/isolation/abstract_unit.rb
+1
-1
railties/test/rails_info_test.rb
railties/test/rails_info_test.rb
+1
-1
tasks/release.rb
tasks/release.rb
+1
-1
未找到文件。
Gemfile
浏览文件 @
4cfcf1ee
...
...
@@ -90,7 +90,7 @@ group :cable do
end
# Add your own local bundler stuff.
local_gemfile
=
File
.
dirname
(
__FILE__
)
+
"/.Gemfile"
local_gemfile
=
File
.
expand_path
(
".Gemfile"
,
__dir__
)
instance_eval
File
.
read
local_gemfile
if
File
.
exist?
local_gemfile
group
:test
do
...
...
Rakefile
浏览文件 @
4cfcf1ee
require
"net/http"
$:
.
unshift
File
.
expand_path
(
".."
,
__FILE__
)
$:
.
unshift
__dir__
require
"tasks/release"
require
"railties/lib/rails/api/task"
...
...
actioncable/README.md
浏览文件 @
4cfcf1ee
...
...
@@ -409,7 +409,7 @@ application. The recommended basic setup is as follows:
```
ruby
# cable/config.ru
require
::
File
.
expand_path
(
'../
../config/environment'
,
__FILE
__
)
require
::
File
.
expand_path
(
'../
config/environment'
,
__dir
__
)
Rails
.
application
.
eager_load!
run
ActionCable
.
server
...
...
actioncable/Rakefile
浏览文件 @
4cfcf1ee
...
...
@@ -3,15 +3,13 @@ require "pathname"
require
"open3"
require
"action_cable"
dir
=
File
.
dirname
(
__FILE__
)
task
default: :test
task
package:
%w( assets:compile assets:verify )
Rake
::
TestTask
.
new
do
|
t
|
t
.
libs
<<
"test"
t
.
test_files
=
Dir
.
glob
(
"
#{
dir
}
/test/**/*_test.rb"
)
t
.
test_files
=
Dir
.
glob
(
"
#{
__dir__
}
/test/**/*_test.rb"
)
t
.
warning
=
true
t
.
verbose
=
true
t
.
ruby_opts
=
[
"--dev"
]
if
defined?
(
JRUBY_VERSION
)
...
...
@@ -46,7 +44,7 @@ namespace :assets do
desc
"Verify compiled Action Cable assets"
task
:verify
do
file
=
"lib/assets/compiled/action_cable.js"
pathname
=
Pathname
.
new
(
"
#{
dir
}
/
#{
file
}
"
)
pathname
=
Pathname
.
new
(
"
#{
__dir__
}
/
#{
file
}
"
)
print
"[verify]
#{
file
}
exists "
if
pathname
.
exist?
...
...
@@ -64,8 +62,8 @@ namespace :assets do
fail
end
print
"[verify]
#{
dir
}
can be required as a module "
_
,
stderr
,
status
=
Open3
.
capture3
(
"node"
,
"--print"
,
"window = {}; require('
#{
dir
}
');"
)
print
"[verify]
#{
__dir__
}
can be required as a module "
_
,
stderr
,
status
=
Open3
.
capture3
(
"node"
,
"--print"
,
"window = {}; require('
#{
__dir__
}
');"
)
if
status
.
success?
puts
"[OK]"
else
...
...
actioncable/actioncable.gemspec
浏览文件 @
4cfcf1ee
version
=
File
.
read
(
File
.
expand_path
(
"../
../RAILS_VERSION"
,
__FILE
__
)).
strip
version
=
File
.
read
(
File
.
expand_path
(
"../
RAILS_VERSION"
,
__dir
__
)).
strip
Gem
::
Specification
.
new
do
|
s
|
s
.
platform
=
Gem
::
Platform
::
RUBY
...
...
actioncable/lib/rails/generators/channel/channel_generator.rb
浏览文件 @
4cfcf1ee
module
Rails
module
Generators
class
ChannelGenerator
<
NamedBase
source_root
File
.
expand_path
(
"
../templates"
,
__FILE
__
)
source_root
File
.
expand_path
(
"
templates"
,
__dir
__
)
argument
:actions
,
type: :array
,
default:
[],
banner:
"method method"
...
...
actioncable/test/test_helper.rb
浏览文件 @
4cfcf1ee
...
...
@@ -11,7 +11,7 @@
end
# Require all the stubs and models
Dir
[
File
.
dirname
(
__FILE__
)
+
"/stubs/*.rb"
].
each
{
|
file
|
require
file
}
Dir
[
File
.
expand_path
(
"stubs/*.rb"
,
__dir__
)
].
each
{
|
file
|
require
file
}
class
ActionCable::TestCase
<
ActiveSupport
::
TestCase
def
wait_for_async
...
...
actionmailer/actionmailer.gemspec
浏览文件 @
4cfcf1ee
version
=
File
.
read
(
File
.
expand_path
(
"../
../RAILS_VERSION"
,
__FILE
__
)).
strip
version
=
File
.
read
(
File
.
expand_path
(
"../
RAILS_VERSION"
,
__dir
__
)).
strip
Gem
::
Specification
.
new
do
|
s
|
s
.
platform
=
Gem
::
Platform
::
RUBY
...
...
actionmailer/lib/rails/generators/mailer/mailer_generator.rb
浏览文件 @
4cfcf1ee
module
Rails
module
Generators
class
MailerGenerator
<
NamedBase
source_root
File
.
expand_path
(
"
../templates"
,
__FILE
__
)
source_root
File
.
expand_path
(
"
templates"
,
__dir
__
)
argument
:actions
,
type: :array
,
default:
[],
banner:
"method method"
...
...
actionmailer/test/abstract_unit.rb
浏览文件 @
4cfcf1ee
...
...
@@ -9,7 +9,7 @@
module
Rails
def
self
.
root
File
.
expand_path
(
"..
/"
,
File
.
dirname
(
__FILE__
)
)
File
.
expand_path
(
"..
"
,
__dir__
)
end
end
...
...
@@ -28,7 +28,7 @@ def self.root
# Disable available locale checks to avoid warnings running the test suite.
I18n
.
enforce_available_locales
=
false
FIXTURE_LOAD_PATH
=
File
.
expand_path
(
"fixtures"
,
File
.
dirname
(
__FILE__
)
)
FIXTURE_LOAD_PATH
=
File
.
expand_path
(
"fixtures"
,
__dir__
)
ActionMailer
::
Base
.
view_paths
=
FIXTURE_LOAD_PATH
class
ActiveSupport::TestCase
...
...
actionmailer/test/caching_test.rb
浏览文件 @
4cfcf1ee
...
...
@@ -5,7 +5,7 @@
CACHE_DIR
=
"test_cache"
# Don't change '/../temp/' cavalierly or you might hose something you don't want hosed
FILE_STORE_PATH
=
File
.
join
(
File
.
dirname
(
__FILE__
)
,
"/../temp/"
,
CACHE_DIR
)
FILE_STORE_PATH
=
File
.
join
(
__dir__
,
"/../temp/"
,
CACHE_DIR
)
class
FragmentCachingMailer
<
ActionMailer
::
Base
abstract!
...
...
actionmailer/test/log_subscriber_test.rb
浏览文件 @
4cfcf1ee
...
...
@@ -36,7 +36,7 @@ def test_deliver_is_notified
end
def
test_receive_is_notified
fixture
=
File
.
read
(
File
.
dirname
(
__FILE__
)
+
"/fixtures/raw_email"
)
fixture
=
File
.
read
(
File
.
expand_path
(
"fixtures/raw_email"
,
__dir__
)
)
TestMailer
.
receive
(
fixture
)
wait
assert_equal
(
1
,
@logger
.
logged
(
:info
).
size
)
...
...
actionpack/Rakefile
浏览文件 @
4cfcf1ee
...
...
@@ -26,7 +26,7 @@ namespace :test do
end
task
:lines
do
load
File
.
expand_path
(
".."
,
File
.
dirname
(
__FILE__
)
)
+
"/tools/line_statistics"
load
File
.
expand_path
(
".."
,
__dir__
)
+
"/tools/line_statistics"
files
=
FileList
[
"lib/**/*.rb"
]
CodeTools
::
LineStatistics
.
new
(
files
).
print_loc
end
...
...
actionpack/actionpack.gemspec
浏览文件 @
4cfcf1ee
version
=
File
.
read
(
File
.
expand_path
(
"../
../RAILS_VERSION"
,
__FILE
__
)).
strip
version
=
File
.
read
(
File
.
expand_path
(
"../
RAILS_VERSION"
,
__dir
__
)).
strip
Gem
::
Specification
.
new
do
|
s
|
s
.
platform
=
Gem
::
Platform
::
RUBY
...
...
actionpack/lib/action_dispatch/journey/gtg/transition_table.rb
浏览文件 @
4cfcf1ee
...
...
@@ -82,7 +82,7 @@ def to_svg
end
def
visualizer
(
paths
,
title
=
"FSM"
)
viz_dir
=
File
.
join
File
.
dirname
(
__FILE__
)
,
".."
,
"visualizer"
viz_dir
=
File
.
join
__dir__
,
".."
,
"visualizer"
fsm_js
=
File
.
read
File
.
join
(
viz_dir
,
"fsm.js"
)
fsm_css
=
File
.
read
File
.
join
(
viz_dir
,
"fsm.css"
)
erb
=
File
.
read
File
.
join
(
viz_dir
,
"index.html.erb"
)
...
...
actionpack/lib/action_dispatch/middleware/debug_exceptions.rb
浏览文件 @
4cfcf1ee
...
...
@@ -10,7 +10,7 @@ module ActionDispatch
# This middleware is responsible for logging exceptions and
# showing a debugging page in case the request is local.
class
DebugExceptions
RESCUES_TEMPLATE_PATH
=
File
.
expand_path
(
"
../templates"
,
__FILE
__
)
RESCUES_TEMPLATE_PATH
=
File
.
expand_path
(
"
templates"
,
__dir
__
)
class
DebugView
<
ActionView
::
Base
def
debug_params
(
params
)
...
...
actionpack/test/abstract_unit.rb
浏览文件 @
4cfcf1ee
$:
.
unshift
(
File
.
dirname
(
__FILE__
)
+
"/lib"
)
$:
.
unshift
(
File
.
dirname
(
__FILE__
)
+
"/fixtures/helpers"
)
$:
.
unshift
(
File
.
dirname
(
__FILE__
)
+
"/fixtures/alternate_helpers"
)
$:
.
unshift
File
.
expand_path
(
"lib"
,
__dir__
)
$:
.
unshift
File
.
expand_path
(
"fixtures/helpers"
,
__dir__
)
$:
.
unshift
File
.
expand_path
(
"fixtures/alternate_helpers"
,
__dir__
)
require
"active_support/core_ext/kernel/reporting"
...
...
@@ -56,7 +56,7 @@ def root; end;
# Disable available locale checks to avoid warnings running the test suite.
I18n
.
enforce_available_locales
=
false
FIXTURE_LOAD_PATH
=
File
.
join
(
File
.
dirname
(
__FILE__
)
,
"fixtures"
)
FIXTURE_LOAD_PATH
=
File
.
join
(
__dir__
,
"fixtures"
)
SharedTestRoutes
=
ActionDispatch
::
Routing
::
RouteSet
.
new
...
...
@@ -156,7 +156,7 @@ def with_routing(&block)
end
def
with_autoload_path
(
path
)
path
=
File
.
join
(
File
.
dirname
(
__FILE__
)
,
"fixtures"
,
path
)
path
=
File
.
join
(
__dir__
,
"fixtures"
,
path
)
if
ActiveSupport
::
Dependencies
.
autoload_paths
.
include?
(
path
)
yield
else
...
...
actionpack/test/controller/action_pack_assertions_test.rb
浏览文件 @
4cfcf1ee
...
...
@@ -83,7 +83,7 @@ def raise_exception_on_post
end
def
render_file_absolute_path
render
file:
File
.
expand_path
(
"../../
../README.rdoc"
,
__FILE
__
)
render
file:
File
.
expand_path
(
"../../
README.rdoc"
,
__dir
__
)
end
def
render_file_relative_path
...
...
actionpack/test/controller/api/data_streaming_test.rb
浏览文件 @
4cfcf1ee
require
"abstract_unit"
module
TestApiFileUtils
def
file_path
()
File
.
expand_path
(
__FILE__
)
end
def
file_path
()
__FILE__
end
def
file_data
()
@data
||=
File
.
open
(
file_path
,
"rb"
)
{
|
f
|
f
.
read
}
end
end
...
...
actionpack/test/controller/caching_test.rb
浏览文件 @
4cfcf1ee
...
...
@@ -4,7 +4,7 @@
CACHE_DIR
=
"test_cache"
# Don't change '/../temp/' cavalierly or you might hose something you don't want hosed
FILE_STORE_PATH
=
File
.
join
(
File
.
dirname
(
__FILE__
),
"/
../temp/"
,
CACHE_DIR
)
FILE_STORE_PATH
=
File
.
join
(
__dir__
,
"
../temp/"
,
CACHE_DIR
)
class
FragmentCachingMetalTestController
<
ActionController
::
Metal
abstract!
...
...
actionpack/test/controller/helper_test.rb
浏览文件 @
4cfcf1ee
require
"abstract_unit"
ActionController
::
Base
.
helpers_path
=
File
.
expand_path
(
"../
../fixtures/helpers"
,
__FILE
__
)
ActionController
::
Base
.
helpers_path
=
File
.
expand_path
(
"../
fixtures/helpers"
,
__dir
__
)
module
Fun
class
GamesController
<
ActionController
::
Base
...
...
@@ -48,7 +48,7 @@ class MeTooController < JustMeController
class
HelpersPathsController
<
ActionController
::
Base
paths
=
[
"helpers2_pack"
,
"helpers1_pack"
].
map
do
|
path
|
File
.
join
(
File
.
expand_path
(
"../
../fixtures"
,
__FILE
__
),
path
)
File
.
join
(
File
.
expand_path
(
"../
fixtures"
,
__dir
__
),
path
)
end
$:
.
unshift
(
*
paths
)
...
...
@@ -61,7 +61,7 @@ def index
end
class
HelpersTypoController
<
ActionController
::
Base
path
=
File
.
expand_path
(
"../
../fixtures/helpers_typo"
,
__FILE
__
)
path
=
File
.
expand_path
(
"../
fixtures/helpers_typo"
,
__dir
__
)
$:
.
unshift
(
path
)
self
.
helpers_path
=
path
end
...
...
@@ -178,7 +178,7 @@ def test_all_helpers
end
def
test_all_helpers_with_alternate_helper_dir
@controller_class
.
helpers_path
=
File
.
expand_path
(
"../
../fixtures/alternate_helpers"
,
__FILE
__
)
@controller_class
.
helpers_path
=
File
.
expand_path
(
"../
fixtures/alternate_helpers"
,
__dir
__
)
# Reload helpers
@controller_class
.
_helpers
=
Module
.
new
...
...
actionpack/test/controller/integration_test.rb
浏览文件 @
4cfcf1ee
...
...
@@ -1091,7 +1091,7 @@ def app
end
def
self
.
fixture_path
File
.
dirname
(
__FILE__
)
+
"/../fixtures/multipart"
File
.
expand_path
(
"../fixtures/multipart"
,
__dir__
)
end
routes
.
draw
do
...
...
actionpack/test/controller/live_stream_test.rb
浏览文件 @
4cfcf1ee
...
...
@@ -152,7 +152,7 @@ def blocking_stream
end
def
write_sleep_autoload
path
=
File
.
join
(
File
.
dirname
(
__FILE__
),
"../fixtures"
)
path
=
File
.
expand_path
(
"../fixtures"
,
__dir__
)
ActiveSupport
::
Dependencies
.
autoload_paths
<<
path
response
.
headers
[
"Content-Type"
]
=
"text/event-stream"
...
...
actionpack/test/controller/mime/accept_format_test.rb
浏览文件 @
4cfcf1ee
...
...
@@ -29,7 +29,7 @@ def test_javascript_with_no_format_only_star_star
end
class
AbstractPostController
<
ActionController
::
Base
self
.
view_paths
=
File
.
dirname
(
__FILE__
)
+
"/../../fixtures/post_test/"
self
.
view_paths
=
File
.
expand_path
(
"../../fixtures/post_test"
,
__dir__
)
end
# For testing layouts which are set automatically
...
...
actionpack/test/controller/new_base/render_file_test.rb
浏览文件 @
4cfcf1ee
...
...
@@ -2,15 +2,15 @@
module
RenderFile
class
BasicController
<
ActionController
::
Base
self
.
view_paths
=
File
.
dirname
(
__FILE__
)
self
.
view_paths
=
__dir__
def
index
render
file:
File
.
join
(
File
.
dirname
(
__FILE__
),
*
%w[.. .. fixtures test hello_world]
)
render
file:
File
.
expand_path
(
"../../fixtures/test/hello_world"
,
__dir__
)
end
def
with_instance_variables
@secret
=
"in the sauce"
render
file:
File
.
join
(
File
.
dirname
(
__FILE__
),
"../../fixtures/test/render_file_with_ivar"
)
render
file:
File
.
expand_path
(
"../../fixtures/test/render_file_with_ivar"
,
__dir__
)
end
def
relative_path
...
...
@@ -25,11 +25,11 @@ def relative_path_with_dot
def
pathname
@secret
=
"in the sauce"
render
file:
Pathname
.
new
(
File
.
dirname
(
__FILE__
)
).
join
(
*
%w[.. .. fixtures test dot.directory render_file_with_ivar]
)
render
file:
Pathname
.
new
(
__dir__
).
join
(
*
%w[.. .. fixtures test dot.directory render_file_with_ivar]
)
end
def
with_locals
path
=
File
.
join
(
File
.
dirname
(
__FILE__
),
"../../fixtures/test/render_file_with_locals"
)
path
=
File
.
expand_path
(
"../../fixtures/test/render_file_with_locals"
,
__dir__
)
render
file:
path
,
locals:
{
secret:
"in the sauce"
}
end
end
...
...
actionpack/test/controller/new_base/render_implicit_action_test.rb
浏览文件 @
4cfcf1ee
...
...
@@ -6,7 +6,7 @@ class SimpleController < ::ApplicationController
"render_implicit_action/simple/hello_world.html.erb"
=>
"Hello world!"
,
"render_implicit_action/simple/hyphen-ated.html.erb"
=>
"Hello hyphen-ated!"
,
"render_implicit_action/simple/not_implemented.html.erb"
=>
"Not Implemented"
),
ActionView
::
FileSystemResolver
.
new
(
File
.
expand_path
(
"../../
../controller"
,
__FILE
__
))]
),
ActionView
::
FileSystemResolver
.
new
(
File
.
expand_path
(
"../../
controller"
,
__dir
__
))]
def
hello_world
()
end
end
...
...
actionpack/test/controller/render_test.rb
浏览文件 @
4cfcf1ee
...
...
@@ -257,7 +257,7 @@ def determine_layout
module
TemplateModificationHelper
private
def
modify_template
(
name
)
path
=
File
.
expand_path
(
"../
../fixtures/
#{
name
}
.erb"
,
__FILE
__
)
path
=
File
.
expand_path
(
"../
fixtures/
#{
name
}
.erb"
,
__dir
__
)
original
=
File
.
read
(
path
)
File
.
write
(
path
,
"
#{
original
}
Modified!"
)
ActionView
::
LookupContext
::
DetailsKey
.
clear
...
...
@@ -287,9 +287,9 @@ def setup
def
test_dynamic_render_with_file
# This is extremely bad, but should be possible to do.
assert
File
.
exist?
(
File
.
join
(
File
.
dirname
(
__FILE__
),
"../../test/abstract_unit.rb"
))
assert
File
.
exist?
(
File
.
expand_path
(
"../../test/abstract_unit.rb"
,
__dir__
))
response
=
get
:dynamic_render_with_file
,
params:
{
id:
'../\\../test/abstract_unit.rb'
}
assert_equal
File
.
read
(
File
.
join
(
File
.
dirname
(
__FILE__
),
"../../test/abstract_unit.rb"
)),
assert_equal
File
.
read
(
File
.
expand_path
(
"../../test/abstract_unit.rb"
,
__dir__
)),
response
.
body
end
...
...
@@ -306,16 +306,16 @@ def test_dynamic_render_with_absolute_path
end
def
test_dynamic_render
assert
File
.
exist?
(
File
.
join
(
File
.
dirname
(
__FILE__
),
"../../test/abstract_unit.rb"
))
assert
File
.
exist?
(
File
.
expand_path
(
"../../test/abstract_unit.rb"
,
__dir__
))
assert_raises
ActionView
::
MissingTemplate
do
get
:dynamic_render
,
params:
{
id:
'../\\../test/abstract_unit.rb'
}
end
end
def
test_permitted_dynamic_render_file_hash
assert
File
.
exist?
(
File
.
join
(
File
.
dirname
(
__FILE__
),
"../../test/abstract_unit.rb"
))
assert
File
.
exist?
(
File
.
expand_path
(
"../../test/abstract_unit.rb"
,
__dir__
))
response
=
get
:dynamic_render_permit
,
params:
{
id:
{
file:
'../\\../test/abstract_unit.rb'
}
}
assert_equal
File
.
read
(
File
.
join
(
File
.
dirname
(
__FILE__
),
"../../test/abstract_unit.rb"
)),
assert_equal
File
.
read
(
File
.
expand_path
(
"../../test/abstract_unit.rb"
,
__dir__
)),
response
.
body
end
...
...
actionpack/test/controller/send_file_test.rb
浏览文件 @
4cfcf1ee
...
...
@@ -2,7 +2,7 @@
module
TestFileUtils
def
file_name
()
File
.
basename
(
__FILE__
)
end
def
file_path
()
File
.
expand_path
(
__FILE__
)
end
def
file_path
()
__FILE__
end
def
file_data
()
@data
||=
File
.
open
(
file_path
,
"rb"
)
{
|
f
|
f
.
read
}
end
end
...
...
actionpack/test/controller/test_case_test.rb
浏览文件 @
4cfcf1ee
...
...
@@ -122,7 +122,7 @@ def test_file_upload
end
def
test_send_file
send_file
(
File
.
expand_path
(
__FILE__
)
)
send_file
(
__FILE__
)
end
def
redirect_to_same_controller
...
...
@@ -780,7 +780,7 @@ def test_multiple_mixed_method_process_should_scrub_rack_input
end
end
FILES_DIR
=
File
.
dirname
(
__FILE__
)
+
"/../fixtures/multipart"
FILES_DIR
=
File
.
expand_path
(
"../fixtures/multipart"
,
__dir__
)
READ_BINARY
=
"rb:binary"
READ_PLAIN
=
"r:binary"
...
...
@@ -855,7 +855,7 @@ def test_fixture_file_upload_relative_to_fixture_path
end
def
test_fixture_file_upload_ignores_fixture_path_given_full_path
TestCaseTest
.
stub
:fixture_path
,
File
.
dirname
(
__FILE__
)
do
TestCaseTest
.
stub
:fixture_path
,
__dir__
do
uploaded_file
=
fixture_file_upload
(
"
#{
FILES_DIR
}
/ruby_on_rails.jpg"
,
"image/jpg"
)
assert_equal
File
.
open
(
"
#{
FILES_DIR
}
/ruby_on_rails.jpg"
,
READ_PLAIN
).
read
,
uploaded_file
.
read
end
...
...
actionpack/test/dispatch/request/multipart_params_parsing_test.rb
浏览文件 @
4cfcf1ee
...
...
@@ -21,7 +21,7 @@ def read
end
end
FIXTURE_PATH
=
File
.
dirname
(
__FILE__
)
+
"/../../fixtures/multipart"
FIXTURE_PATH
=
File
.
expand_path
(
"../../fixtures/multipart"
,
__dir__
)
def
teardown
TestController
.
last_request_parameters
=
nil
...
...
actionpack/test/dispatch/request/url_encoded_params_parsing_test.rb
浏览文件 @
4cfcf1ee
...
...
@@ -107,7 +107,7 @@ def teardown
query
=
[
"customers[boston][first][name]=David"
,
"something_else=blah"
,
"logo=
#{
File
.
expand_path
(
__FILE__
)
}
"
"logo=
#{
__FILE__
}
"
].
join
(
"&"
)
expected
=
{
"customers"
=>
{
...
...
@@ -118,7 +118,7 @@ def teardown
}
},
"something_else"
=>
"blah"
,
"logo"
=>
File
.
expand_path
(
__FILE__
)
,
"logo"
=>
__FILE__
,
}
assert_parses
expected
,
query
end
...
...
actionview/Rakefile
浏览文件 @
4cfcf1ee
...
...
@@ -2,8 +2,6 @@ require "rake/testtask"
require
"fileutils"
require
"open3"
dir
=
File
.
dirname
(
__FILE__
)
desc
"Default Task"
task
default: :test
...
...
@@ -95,7 +93,7 @@ namespace :assets do
desc
"Verify compiled Action View assets"
task
:verify
do
file
=
"lib/assets/compiled/rails-ujs.js"
pathname
=
Pathname
.
new
(
"
#{
dir
}
/
#{
file
}
"
)
pathname
=
Pathname
.
new
(
"
#{
__dir__
}
/
#{
file
}
"
)
print
"[verify]
#{
file
}
exists "
if
pathname
.
exist?
...
...
@@ -113,11 +111,11 @@ namespace :assets do
fail
end
print
"[verify]
#{
dir
}
can be required as a module "
print
"[verify]
#{
__dir__
}
can be required as a module "
js
=
<<-
JS
window = { Event: class {} }
class Element {}
require('
#{
dir
}
')
require('
#{
__dir__
}
')
JS
_
,
stderr
,
status
=
Open3
.
capture3
(
"node"
,
"--print"
,
js
)
if
status
.
success?
...
...
@@ -130,7 +128,7 @@ namespace :assets do
end
task
:lines
do
load
File
.
expand_path
(
".."
,
File
.
dirname
(
__FILE__
))
+
"/tools/line_statistics"
load
File
.
join
(
File
.
expand_path
(
".."
,
__dir__
),
"/tools/line_statistics"
)
files
=
FileList
[
"lib/**/*.rb"
]
CodeTools
::
LineStatistics
.
new
(
files
).
print_loc
end
actionview/actionview.gemspec
浏览文件 @
4cfcf1ee
version
=
File
.
read
(
File
.
expand_path
(
"../
../RAILS_VERSION"
,
__FILE
__
)).
strip
version
=
File
.
read
(
File
.
expand_path
(
"../
RAILS_VERSION"
,
__dir
__
)).
strip
Gem
::
Specification
.
new
do
|
s
|
s
.
platform
=
Gem
::
Platform
::
RUBY
...
...
actionview/lib/action_view.rb
浏览文件 @
4cfcf1ee
...
...
@@ -92,5 +92,5 @@ def self.eager_load!
require
"active_support/core_ext/string/output_safety"
ActiveSupport
.
on_load
(
:i18n
)
do
I18n
.
load_path
<<
"
#{
File
.
dirname
(
__FILE__
)
}
/action_view/locale/en.yml"
I18n
.
load_path
<<
File
.
expand_path
(
"action_view/locale/en.yml"
,
__dir__
)
end
actionview/test/abstract_unit.rb
浏览文件 @
4cfcf1ee
$:
.
unshift
(
File
.
dirname
(
__FILE__
)
+
"/lib"
)
$:
.
unshift
(
File
.
dirname
(
__FILE__
)
+
"/fixtures/helpers"
)
$:
.
unshift
(
File
.
dirname
(
__FILE__
)
+
"/fixtures/alternate_helpers"
)
$:
.
unshift
File
.
expand_path
(
"lib"
,
__dir__
)
$:
.
unshift
File
.
expand_path
(
"fixtures/helpers"
,
__dir__
)
$:
.
unshift
File
.
expand_path
(
"fixtures/alternate_helpers"
,
__dir__
)
ENV
[
"TMPDIR"
]
=
File
.
join
(
File
.
dirname
(
__FILE__
),
"tmp"
)
ENV
[
"TMPDIR"
]
=
File
.
expand_path
(
"tmp"
,
__dir__
)
require
"active_support/core_ext/kernel/reporting"
...
...
@@ -47,7 +47,7 @@ def env
I18n
.
backend
.
store_translations
"pt-BR"
,
{}
ORIGINAL_LOCALES
=
I18n
.
available_locales
.
map
(
&
:to_s
).
sort
FIXTURE_LOAD_PATH
=
File
.
join
(
File
.
dirname
(
__FILE__
),
"fixtures"
)
FIXTURE_LOAD_PATH
=
File
.
expand_path
(
"fixtures"
,
__dir__
)
module
RenderERBUtils
def
view
...
...
@@ -133,7 +133,7 @@ class BasicController
def
config
@config
||=
ActiveSupport
::
InheritableOptions
.
new
(
ActionController
::
Base
.
config
).
tap
do
|
config
|
# VIEW TODO: View tests should not require a controller
public_dir
=
File
.
expand_path
(
"
../fixtures/public"
,
__FILE
__
)
public_dir
=
File
.
expand_path
(
"
fixtures/public"
,
__dir
__
)
config
.
assets_dir
=
public_dir
config
.
javascripts_dir
=
"
#{
public_dir
}
/javascripts"
config
.
stylesheets_dir
=
"
#{
public_dir
}
/stylesheets"
...
...
@@ -196,7 +196,7 @@ def with_routing(&block)
end
def
with_autoload_path
(
path
)
path
=
File
.
join
(
File
.
dirname
(
__FILE__
),
"fixtures"
,
path
)
path
=
File
.
join
(
File
.
expand_path
(
"fixtures"
,
__dir__
)
,
path
)
if
ActiveSupport
::
Dependencies
.
autoload_paths
.
include?
(
path
)
yield
else
...
...
actionview/test/actionpack/abstract/abstract_controller_test.rb
浏览文件 @
4cfcf1ee
...
...
@@ -42,7 +42,7 @@ def render(options = {})
super
end
append_view_path
File
.
expand_path
(
File
.
join
(
File
.
dirname
(
__FILE__
),
"views"
)
)
append_view_path
File
.
expand_path
(
"views"
,
__dir__
)
end
class
Me2
<
RenderingController
...
...
@@ -152,7 +152,7 @@ def setup
class
OverridingLocalPrefixes
<
AbstractController
::
Base
include
AbstractController
::
Rendering
include
ActionView
::
Rendering
append_view_path
File
.
expand_path
(
File
.
join
(
File
.
dirname
(
__FILE__
),
"views"
)
)
append_view_path
File
.
expand_path
(
"views"
,
__dir__
)
def
index
render
...
...
actionview/test/actionpack/abstract/helper_test.rb
浏览文件 @
4cfcf1ee
require
"abstract_unit"
ActionController
::
Base
.
helpers_path
=
File
.
expand_path
(
"../../
../fixtures/helpers"
,
__FILE
__
)
ActionController
::
Base
.
helpers_path
=
File
.
expand_path
(
"../../
fixtures/helpers"
,
__dir
__
)
module
AbstractController
module
Testing
...
...
@@ -51,7 +51,7 @@ class AbstractHelpersBlock < ControllerWithHelpers
class
AbstractInvalidHelpers
<
AbstractHelpers
include
ActionController
::
Helpers
path
=
File
.
expand_path
(
"../../
../fixtures/helpers_missing"
,
__FILE
__
)
path
=
File
.
expand_path
(
"../../
fixtures/helpers_missing"
,
__dir
__
)
$:
.
unshift
(
path
)
self
.
helpers_path
=
path
end
...
...
actionview/test/actionpack/controller/capture_test.rb
浏览文件 @
4cfcf1ee
...
...
@@ -2,7 +2,7 @@
require
"active_support/logger"
class
CaptureController
<
ActionController
::
Base
self
.
view_paths
=
[
File
.
dirname
(
__FILE__
)
+
"/../../fixtures/actionpack"
]
self
.
view_paths
=
[
File
.
expand_path
(
"../../fixtures/actionpack"
,
__dir__
)
]
def
self
.
controller_name
;
"test"
;
end
def
self
.
controller_path
;
"test"
;
end
...
...
actionview/test/actionpack/controller/layout_test.rb
浏览文件 @
4cfcf1ee
...
...
@@ -5,7 +5,7 @@
# method has access to the view_paths array when looking for a layout to automatically assign.
old_load_paths
=
ActionController
::
Base
.
view_paths
ActionController
::
Base
.
view_paths
=
[
File
.
dirname
(
__FILE__
)
+
"/../../fixtures/actionpack/layout_tests/"
]
ActionController
::
Base
.
view_paths
=
[
File
.
expand_path
(
"../../fixtures/actionpack/layout_tests"
,
__dir__
)
]
class
LayoutTest
<
ActionController
::
Base
def
self
.
controller_path
;
"views"
end
...
...
@@ -96,7 +96,7 @@ def render(*args)
end
class
AbsolutePathLayoutController
<
LayoutTest
layout
File
.
expand_path
(
File
.
expand_path
(
__FILE__
)
+
"/../../../fixtures/actionpack/layout_tests/layouts/layout_test"
)
layout
File
.
expand_path
(
"../../fixtures/actionpack/layout_tests/layouts/layout_test"
,
__dir__
)
end
class
HasOwnLayoutController
<
LayoutTest
...
...
@@ -117,7 +117,7 @@ class HasNilLayoutProc < LayoutTest
class
PrependsViewPathController
<
LayoutTest
def
hello
prepend_view_path
File
.
dirname
(
__FILE__
)
+
"/../../fixtures/actionpack/layout_tests/alt/"
prepend_view_path
File
.
expand_path
(
"../../fixtures/actionpack/layout_tests/alt"
,
__dir__
)
render
layout:
"alt"
end
end
...
...
actionview/test/actionpack/controller/render_test.rb
浏览文件 @
4cfcf1ee
...
...
@@ -56,7 +56,7 @@ def hello_world
end
def
hello_world_file
render
file:
File
.
expand_path
(
"../../
../fixtures/actionpack/hello"
,
__FILE
__
),
formats:
[
:html
]
render
file:
File
.
expand_path
(
"../../
fixtures/actionpack/hello"
,
__dir
__
),
formats:
[
:html
]
end
# :ported:
...
...
@@ -125,7 +125,7 @@ def hello_world_with_layout_false
# :ported:
def
render_file_with_instance_variables
@secret
=
"in the sauce"
path
=
File
.
join
(
File
.
dirname
(
__FILE__
),
"../../fixtures/test/render_file_with_ivar"
)
path
=
File
.
expand_path
(
"../../fixtures/test/render_file_with_ivar"
,
__dir__
)
render
file:
path
end
...
...
@@ -142,21 +142,21 @@ def render_file_not_using_full_path_with_dot_in_path
def
render_file_using_pathname
@secret
=
"in the sauce"
render
file:
Pathname
.
new
(
File
.
dirname
(
__FILE__
)
).
join
(
".."
,
".."
,
"fixtures"
,
"test"
,
"dot.directory"
,
"render_file_with_ivar"
)
render
file:
Pathname
.
new
(
__dir__
).
join
(
".."
,
".."
,
"fixtures"
,
"test"
,
"dot.directory"
,
"render_file_with_ivar"
)
end
def
render_file_from_template
@secret
=
"in the sauce"
@path
=
File
.
expand_path
(
File
.
join
(
File
.
dirname
(
__FILE__
),
"../../fixtures/test/render_file_with_ivar"
)
)
@path
=
File
.
expand_path
(
"../../fixtures/test/render_file_with_ivar"
,
__dir__
)
end
def
render_file_with_locals
path
=
File
.
join
(
File
.
dirname
(
__FILE__
),
"../../fixtures/test/render_file_with_locals"
)
path
=
File
.
expand_path
(
"../../fixtures/test/render_file_with_locals"
,
__dir__
)
render
file:
path
,
locals:
{
secret:
"in the sauce"
}
end
def
render_file_as_string_with_locals
path
=
File
.
expand_path
(
File
.
join
(
File
.
dirname
(
__FILE__
),
"../../fixtures/test/render_file_with_locals"
)
)
path
=
File
.
expand_path
(
"../../fixtures/test/render_file_with_locals"
,
__dir__
)
render
file:
path
,
locals:
{
secret:
"in the sauce"
}
end
...
...
actionview/test/active_record_unit.rb
浏览文件 @
4cfcf1ee
...
...
@@ -13,7 +13,7 @@ class ActiveRecordTestConnector
# Try to grab AR
unless
defined?
(
ActiveRecord
)
&&
defined?
(
FixtureSet
)
begin
PATH_TO_AR
=
"
#{
File
.
dirname
(
__FILE__
)
}
/../../activerecord/lib"
PATH_TO_AR
=
File
.
expand_path
(
"../../activerecord/lib"
,
__dir__
)
raise
LoadError
,
"
#{
PATH_TO_AR
}
doesn't exist"
unless
File
.
directory?
(
PATH_TO_AR
)
$LOAD_PATH
.
unshift
PATH_TO_AR
require
"active_record"
...
...
@@ -58,13 +58,13 @@ def setup_connection
# Load actionpack sqlite3 tables
def
load_schema
File
.
read
(
File
.
dirname
(
__FILE__
)
+
"/fixtures/db_definitions/sqlite.sql"
).
split
(
";"
).
each
do
|
sql
|
File
.
read
(
File
.
expand_path
(
"fixtures/db_definitions/sqlite.sql"
,
__dir__
)
).
split
(
";"
).
each
do
|
sql
|
ActiveRecord
::
Base
.
connection
.
execute
(
sql
)
unless
sql
.
blank?
end
end
def
require_fixture_models
Dir
.
glob
(
File
.
dirname
(
__FILE__
)
+
"/fixtures/*.rb"
).
each
{
|
f
|
require
f
}
Dir
.
glob
(
File
.
expand_path
(
"fixtures/*.rb"
,
__dir__
)
).
each
{
|
f
|
require
f
}
end
end
end
...
...
actionview/test/template/digestor_test.rb
浏览文件 @
4cfcf1ee
...
...
@@ -14,7 +14,7 @@ def initialize(template_path)
end
class
FixtureFinder
<
ActionView
::
LookupContext
FIXTURES_DIR
=
"
#{
File
.
dirname
(
__FILE__
)
}
/../fixtures/digestor"
FIXTURES_DIR
=
File
.
expand_path
(
"../fixtures/digestor"
,
__dir__
)
def
initialize
(
details
=
{})
super
(
ActionView
::
PathSet
.
new
([
"digestor"
,
"digestor/api"
]),
details
,
[])
...
...
actionview/test/template/render_test.rb
浏览文件 @
4cfcf1ee
...
...
@@ -138,7 +138,7 @@ def test_render_file_at_top_level
end
def
test_render_file_with_full_path
template_path
=
File
.
join
(
File
.
dirname
(
__FILE__
),
"../fixtures/test/hello_world"
)
template_path
=
File
.
expand_path
(
"../fixtures/test/hello_world"
,
__dir__
)
assert_equal
"Hello world!"
,
@view
.
render
(
file:
template_path
)
end
...
...
@@ -160,7 +160,7 @@ def test_render_partial_from_default
end
def
test_render_outside_path
assert
File
.
exist?
(
File
.
join
(
File
.
dirname
(
__FILE__
),
"../../test/abstract_unit.rb"
))
assert
File
.
exist?
(
File
.
expand_path
(
"../../test/abstract_unit.rb"
,
__dir__
))
assert_raises
ActionView
::
MissingTemplate
do
@view
.
render
(
template:
"../
\\
../test/abstract_unit.rb"
)
end
...
...
actionview/test/template/resolver_patterns_test.rb
浏览文件 @
4cfcf1ee
...
...
@@ -2,7 +2,7 @@
class
ResolverPatternsTest
<
ActiveSupport
::
TestCase
def
setup
path
=
File
.
expand_path
(
"../
../fixtures/"
,
__FILE
__
)
path
=
File
.
expand_path
(
"../
fixtures"
,
__dir
__
)
pattern
=
":prefix/{:formats/,}:action{.:formats,}{+:variants,}{.:handlers,}"
@resolver
=
ActionView
::
FileSystemResolver
.
new
(
path
,
pattern
)
end
...
...
actionview/test/ujs/config.ru
浏览文件 @
4cfcf1ee
$LOAD_PATH
.
unshift
File
.
expand_path
(
".."
,
__FILE__
)
$LOAD_PATH
.
unshift
__dir__
require
"server"
run
UJS
::
Server
activejob/Rakefile
浏览文件 @
4cfcf1ee
...
...
@@ -44,9 +44,8 @@ namespace :test do
namespace
:isolated
do
task
adapter
=>
"test:env:
#{
adapter
}
"
do
dir
=
File
.
dirname
(
__FILE__
)
Dir
.
glob
(
"
#{
dir
}
/test/cases/**/*_test.rb"
).
all?
do
|
file
|
sh
(
Gem
.
ruby
,
"-w"
,
"-I
#{
dir
}
/lib"
,
"-I
#{
dir
}
/test"
,
file
)
Dir
.
glob
(
"
#{
__dir__
}
/test/cases/**/*_test.rb"
).
all?
do
|
file
|
sh
(
Gem
.
ruby
,
"-w"
,
"-I
#{
__dir__
}
/lib"
,
"-I
#{
__dir__
}
/test"
,
file
)
end
||
raise
(
"Failures"
)
end
end
...
...
activejob/activejob.gemspec
浏览文件 @
4cfcf1ee
version
=
File
.
read
(
File
.
expand_path
(
"../
../RAILS_VERSION"
,
__FILE
__
)).
strip
version
=
File
.
read
(
File
.
expand_path
(
"../
RAILS_VERSION"
,
__dir
__
)).
strip
Gem
::
Specification
.
new
do
|
s
|
s
.
platform
=
Gem
::
Platform
::
RUBY
...
...
activejob/lib/rails/generators/job/job_generator.rb
浏览文件 @
4cfcf1ee
...
...
@@ -12,7 +12,7 @@ class JobGenerator < Rails::Generators::NamedBase # :nodoc:
hook_for
:test_framework
def
self
.
default_generator_root
File
.
dirname
(
__FILE__
)
__dir__
end
def
create_job_file
...
...
activejob/test/adapters/delayed_job.rb
浏览文件 @
4cfcf1ee
ActiveJob
::
Base
.
queue_adapter
=
:delayed_job
$LOAD_PATH
<<
File
.
dirname
(
__FILE__
)
+
"/../support/delayed_job"
$LOAD_PATH
<<
File
.
expand_path
(
"../support/delayed_job"
,
__dir__
)
Delayed
::
Worker
.
delay_jobs
=
false
Delayed
::
Worker
.
backend
=
:test
activejob/test/support/integration/dummy_app_template.rb
浏览文件 @
4cfcf1ee
...
...
@@ -5,7 +5,7 @@
rails_command
(
"db:migrate"
)
initializer
"activejob.rb"
,
<<-
CODE
require "
#{
File
.
expand_path
(
"
../jobs_manager.rb"
,
__FILE
__
)
}
"
require "
#{
File
.
expand_path
(
"
jobs_manager.rb"
,
__dir
__
)
}
"
JobsManager.current_manager.setup
CODE
...
...
activejob/test/support/integration/helper.rb
浏览文件 @
4cfcf1ee
...
...
@@ -7,7 +7,7 @@
require
"tmpdir"
dummy_app_path
=
Dir
.
mktmpdir
+
"/dummy"
dummy_app_template
=
File
.
expand_path
(
"
../dummy_app_template.rb"
,
__FILE
__
)
dummy_app_template
=
File
.
expand_path
(
"
dummy_app_template.rb"
,
__dir
__
)
args
=
Rails
::
Generators
::
ARGVScrubber
.
new
([
"new"
,
dummy_app_path
,
"--skip-gemfile"
,
"--skip-bundle"
,
"--skip-git"
,
"--skip-spring"
,
"-d"
,
"sqlite3"
,
"--skip-javascript"
,
"--force"
,
"--quiet"
,
"--template"
,
dummy_app_template
]).
prepare!
...
...
activemodel/Rakefile
浏览文件 @
4cfcf1ee
require
"rake/testtask"
dir
=
File
.
dirname
(
__FILE__
)
task
default: :test
task
:package
Rake
::
TestTask
.
new
do
|
t
|
t
.
libs
<<
"test"
t
.
test_files
=
Dir
.
glob
(
"
#{
dir
}
/test/cases/**/*_test.rb"
)
t
.
test_files
=
Dir
.
glob
(
"
#{
__dir__
}
/test/cases/**/*_test.rb"
)
t
.
warning
=
true
t
.
verbose
=
true
t
.
ruby_opts
=
[
"--dev"
]
if
defined?
(
JRUBY_VERSION
)
...
...
@@ -16,8 +14,8 @@ end
namespace
:test
do
task
:isolated
do
Dir
.
glob
(
"
#{
dir
}
/test/**/*_test.rb"
).
all?
do
|
file
|
sh
(
Gem
.
ruby
,
"-w"
,
"-I
#{
dir
}
/lib"
,
"-I
#{
dir
}
/test"
,
file
)
Dir
.
glob
(
"
#{
__dir__
}
/test/**/*_test.rb"
).
all?
do
|
file
|
sh
(
Gem
.
ruby
,
"-w"
,
"-I
#{
__dir__
}
/lib"
,
"-I
#{
__dir__
}
/test"
,
file
)
end
||
raise
(
"Failures"
)
end
end
activemodel/activemodel.gemspec
浏览文件 @
4cfcf1ee
version
=
File
.
read
(
File
.
expand_path
(
"../
../RAILS_VERSION"
,
__FILE
__
)).
strip
version
=
File
.
read
(
File
.
expand_path
(
"../
RAILS_VERSION"
,
__dir
__
)).
strip
Gem
::
Specification
.
new
do
|
s
|
s
.
platform
=
Gem
::
Platform
::
RUBY
...
...
activemodel/lib/active_model.rb
浏览文件 @
4cfcf1ee
...
...
@@ -68,5 +68,5 @@ def self.eager_load!
end
ActiveSupport
.
on_load
(
:i18n
)
do
I18n
.
load_path
<<
File
.
dirname
(
__FILE__
)
+
"/active_model/locale/en.yml"
I18n
.
load_path
<<
File
.
expand_path
(
"active_model/locale/en.yml"
,
__dir__
)
end
activemodel/lib/active_model/validations.rb
浏览文件 @
4cfcf1ee
...
...
@@ -435,4 +435,4 @@ def initialize(model)
end
end
Dir
[
File
.
dirname
(
__FILE__
)
+
"/validations/*.rb"
].
each
{
|
file
|
require
file
}
Dir
[
File
.
expand_path
(
"validations/*.rb"
,
__dir__
)
].
each
{
|
file
|
require
file
}
activerecord/Rakefile
浏览文件 @
4cfcf1ee
require
"rake/testtask"
require
File
.
expand_path
(
File
.
dirname
(
__FILE__
))
+
"/test/config"
require
File
.
expand_path
(
File
.
dirname
(
__FILE__
))
+
"/test/support/config"
require
File
.
expand_path
(
"test/config"
,
__dir__
)
require
File
.
expand_path
(
"test/support/config"
,
__dir__
)
def
run_without_aborting
(
*
tasks
)
errors
=
[]
...
...
@@ -134,7 +134,7 @@ task drop_postgresql_databases: "db:postgresql:drop"
task
rebuild_postgresql_databases:
"db:postgresql:rebuild"
task
:lines
do
load
File
.
expand_path
(
"..
"
,
File
.
dirname
(
__FILE__
))
+
"/tools/line_statistics"
load
File
.
expand_path
(
"..
/tools/line_statistics"
,
__dir__
)
files
=
FileList
[
"lib/active_record/**/*.rb"
]
CodeTools
::
LineStatistics
.
new
(
files
).
print_loc
end
activerecord/activerecord.gemspec
浏览文件 @
4cfcf1ee
version
=
File
.
read
(
File
.
expand_path
(
"../
../RAILS_VERSION"
,
__FILE
__
)).
strip
version
=
File
.
read
(
File
.
expand_path
(
"../
RAILS_VERSION"
,
__dir
__
)).
strip
Gem
::
Specification
.
new
do
|
s
|
s
.
platform
=
Gem
::
Platform
::
RUBY
...
...
activerecord/lib/active_record.rb
浏览文件 @
4cfcf1ee
...
...
@@ -177,5 +177,5 @@ def self.eager_load!
end
ActiveSupport
.
on_load
(
:i18n
)
do
I18n
.
load_path
<<
File
.
dirname
(
__FILE__
)
+
"/active_record/locale/en.yml"
I18n
.
load_path
<<
File
.
expand_path
(
"active_record/locale/en.yml"
,
__dir__
)
end
activerecord/lib/rails/generators/active_record.rb
浏览文件 @
4cfcf1ee
...
...
@@ -10,7 +10,7 @@ class Base < Rails::Generators::NamedBase # :nodoc:
# Set the current directory as base for the inherited generators.
def
self
.
base_root
File
.
dirname
(
__FILE__
)
__dir__
end
end
end
...
...
activerecord/test/cases/adapters/postgresql/bytea_test.rb
浏览文件 @
4cfcf1ee
...
...
@@ -96,7 +96,7 @@ def test_via_to_sql_with_complicating_connection
end
def
test_write_binary
data
=
File
.
read
(
File
.
join
(
File
.
dirname
(
__FILE__
)
,
".."
,
".."
,
".."
,
"assets"
,
"example.log"
))
data
=
File
.
read
(
File
.
join
(
__dir__
,
".."
,
".."
,
".."
,
"assets"
,
"example.log"
))
assert
(
data
.
size
>
1
)
record
=
ByteaDataType
.
create
(
payload:
data
)
assert_not
record
.
new_record?
...
...
activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb
浏览文件 @
4cfcf1ee
...
...
@@ -954,7 +954,7 @@ def test_habtm_with_reflection_using_class_name_and_fixtures
assert_not_nil
Developer
.
_reflections
[
"shared_computers"
]
# Checking the fixture for named association is important here, because it's the only way
# we've been able to reproduce this bug
assert_not_nil
File
.
read
(
File
.
expand_path
(
"../../
../fixtures/developers.yml"
,
__FILE
__
)).
index
(
"shared_computers"
)
assert_not_nil
File
.
read
(
File
.
expand_path
(
"../../
fixtures/developers.yml"
,
__dir
__
)).
index
(
"shared_computers"
)
assert_equal
developers
(
:david
).
shared_computers
.
first
,
computers
(
:laptop
)
end
...
...
activerecord/test/cases/inheritance_test.rb
浏览文件 @
4cfcf1ee
...
...
@@ -316,7 +316,7 @@ def test_new_without_storing_full_sti_class
end
def
test_new_with_autoload_paths
path
=
File
.
expand_path
(
"../
../models/autoloadable"
,
__FILE
__
)
path
=
File
.
expand_path
(
"../
models/autoloadable"
,
__dir
__
)
ActiveSupport
::
Dependencies
.
autoload_paths
<<
path
firm
=
Company
.
new
(
type:
"ExtraFirm"
)
...
...
activerecord/test/cases/reload_models_test.rb
浏览文件 @
4cfcf1ee
...
...
@@ -13,7 +13,7 @@ def test_has_one_with_reload
# development environment. Note that meanwhile the class Pet is not
# reloaded, simulating a class that is present in a plugin.
Object
.
class_eval
{
remove_const
:Owner
}
Kernel
.
load
(
File
.
expand_path
(
File
.
join
(
File
.
dirname
(
__FILE__
),
"../models/owner.rb"
)
))
Kernel
.
load
(
File
.
expand_path
(
"../models/owner.rb"
,
__dir__
))
pet
=
Pet
.
find_by_name
(
"parrot"
)
pet
.
owner
=
Owner
.
find_by_name
(
"ashley"
)
...
...
activerecord/test/cases/yaml_serialization_test.rb
浏览文件 @
4cfcf1ee
...
...
@@ -123,8 +123,8 @@ def test_yaml_encoding_keeps_mutations
def
yaml_fixture
(
file_name
)
path
=
File
.
expand_path
(
"../
../
support/yaml_compatibility_fixtures/
#{
file_name
}
.yml"
,
__
FILE
__
"../support/yaml_compatibility_fixtures/
#{
file_name
}
.yml"
,
__
dir
__
)
File
.
read
(
path
)
end
...
...
activerecord/test/config.rb
浏览文件 @
4cfcf1ee
TEST_ROOT
=
File
.
expand_path
(
File
.
dirname
(
__FILE__
))
TEST_ROOT
=
__dir__
ASSETS_ROOT
=
TEST_ROOT
+
"/assets"
FIXTURES_ROOT
=
TEST_ROOT
+
"/fixtures"
MIGRATIONS_ROOT
=
TEST_ROOT
+
"/migrations"
...
...
activesupport/activesupport.gemspec
浏览文件 @
4cfcf1ee
version
=
File
.
read
(
File
.
expand_path
(
"../
../RAILS_VERSION"
,
__FILE
__
)).
strip
version
=
File
.
read
(
File
.
expand_path
(
"../
RAILS_VERSION"
,
__dir
__
)).
strip
Gem
::
Specification
.
new
do
|
s
|
s
.
platform
=
Gem
::
Platform
::
RUBY
...
...
activesupport/bin/generate_tables
浏览文件 @
4cfcf1ee
#!/usr/bin/env ruby
begin
$:
.
unshift
(
File
.
expand_path
(
File
.
dirname
(
__FILE__
)
+
"/../lib"
))
$:
.
unshift
(
File
.
expand_path
(
"../lib"
,
__dir__
))
require
"active_support"
rescue
IOError
end
...
...
activesupport/lib/active_support/core_ext.rb
浏览文件 @
4cfcf1ee
(
Dir
[
"
#{
File
.
dirname
(
__FILE__
)
}
/core_ext/*.rb"
]
).
each
do
|
path
|
Dir
.
glob
(
File
.
expand_path
(
"core_ext/*.rb"
,
__dir__
)
).
each
do
|
path
|
require
path
end
activesupport/lib/active_support/deprecation/reporting.rb
浏览文件 @
4cfcf1ee
...
...
@@ -102,7 +102,7 @@ def _extract_callstack(callstack)
end
end
RAILS_GEM_ROOT
=
File
.
expand_path
(
"../../../..
/.."
,
__FILE__
)
+
"/"
RAILS_GEM_ROOT
=
File
.
expand_path
(
"../../../..
"
,
__dir__
)
def
ignored_callstack
(
path
)
path
.
start_with?
(
RAILS_GEM_ROOT
)
||
path
.
start_with?
(
RbConfig
::
CONFIG
[
"rubylibdir"
])
...
...
activesupport/lib/active_support/i18n.rb
浏览文件 @
4cfcf1ee
...
...
@@ -10,4 +10,4 @@
require
"active_support/lazy_load_hooks"
ActiveSupport
.
run_load_hooks
(
:i18n
)
I18n
.
load_path
<<
"
#{
File
.
dirname
(
__FILE__
)
}
/locale/en.yml"
I18n
.
load_path
<<
File
.
expand_path
(
"locale/en.yml"
,
__dir__
)
activesupport/lib/active_support/multibyte/unicode.rb
浏览文件 @
4cfcf1ee
...
...
@@ -357,7 +357,7 @@ class << self
# Returns the directory in which the data files are stored.
def
self
.
dirname
File
.
dirname
(
__FILE__
)
+
"/../values/"
File
.
expand_path
(
"../values"
,
__dir__
)
end
# Returns the filename for the data file for this version.
...
...
activesupport/test/dependencies_test.rb
浏览文件 @
4cfcf1ee
...
...
@@ -104,7 +104,7 @@ def test_warnings_should_be_enabled_on_first_load
with_loading
"dependencies"
do
old_warnings
,
ActiveSupport
::
Dependencies
.
warnings_on_first_load
=
ActiveSupport
::
Dependencies
.
warnings_on_first_load
,
true
filename
=
"check_warnings"
expanded
=
File
.
expand_path
(
"
#{
File
.
dirname
(
__FILE__
)
}
/dependencies/
#{
filename
}
"
)
expanded
=
File
.
expand_path
(
"
dependencies/
#{
filename
}
"
,
__dir__
)
$check_warnings_load_count
=
0
assert_not
ActiveSupport
::
Dependencies
.
loaded
.
include?
(
expanded
)
...
...
@@ -293,7 +293,7 @@ def test_throwing_discards_autoloaded_constants
end
def
test_doesnt_break_normal_require
path
=
File
.
expand_path
(
"
../autoloading_fixtures/load_path"
,
__FILE
__
)
path
=
File
.
expand_path
(
"
autoloading_fixtures/load_path"
,
__dir
__
)
original_path
=
$:
.
dup
$:
.
push
(
path
)
with_autoloading_fixtures
do
...
...
@@ -312,7 +312,7 @@ def test_doesnt_break_normal_require
end
def
test_doesnt_break_normal_require_nested
path
=
File
.
expand_path
(
"
../autoloading_fixtures/load_path"
,
__FILE
__
)
path
=
File
.
expand_path
(
"
autoloading_fixtures/load_path"
,
__dir
__
)
original_path
=
$:
.
dup
$:
.
push
(
path
)
...
...
@@ -332,7 +332,7 @@ def test_doesnt_break_normal_require_nested
end
def
test_require_returns_true_when_file_not_yet_required
path
=
File
.
expand_path
(
"
../autoloading_fixtures/load_path"
,
__FILE
__
)
path
=
File
.
expand_path
(
"
autoloading_fixtures/load_path"
,
__dir
__
)
original_path
=
$:
.
dup
$:
.
push
(
path
)
...
...
@@ -345,7 +345,7 @@ def test_require_returns_true_when_file_not_yet_required
end
def
test_require_returns_true_when_file_not_yet_required_even_when_no_new_constants_added
path
=
File
.
expand_path
(
"
../autoloading_fixtures/load_path"
,
__FILE
__
)
path
=
File
.
expand_path
(
"
autoloading_fixtures/load_path"
,
__dir
__
)
original_path
=
$:
.
dup
$:
.
push
(
path
)
...
...
@@ -359,7 +359,7 @@ def test_require_returns_true_when_file_not_yet_required_even_when_no_new_consta
end
def
test_require_returns_false_when_file_already_required
path
=
File
.
expand_path
(
"
../autoloading_fixtures/load_path"
,
__FILE
__
)
path
=
File
.
expand_path
(
"
autoloading_fixtures/load_path"
,
__dir
__
)
original_path
=
$:
.
dup
$:
.
push
(
path
)
...
...
@@ -379,7 +379,7 @@ def test_require_raises_load_error_when_file_not_found
end
def
test_load_returns_true_when_file_found
path
=
File
.
expand_path
(
"
../autoloading_fixtures/load_path"
,
__FILE
__
)
path
=
File
.
expand_path
(
"
autoloading_fixtures/load_path"
,
__dir
__
)
original_path
=
$:
.
dup
$:
.
push
(
path
)
...
...
@@ -438,7 +438,7 @@ def test_loadable_constants_for_path_should_handle_empty_autoloads
def
test_loadable_constants_for_path_should_handle_relative_paths
fake_root
=
"dependencies"
relative_root
=
File
.
dirname
(
__FILE__
)
+
"/dependencies"
relative_root
=
File
.
expand_path
(
"dependencies"
,
__dir__
)
[
""
,
"/"
].
each
do
|
suffix
|
with_loading
fake_root
+
suffix
do
assert_equal
[
"A::B"
],
ActiveSupport
::
Dependencies
.
loadable_constants_for_path
(
relative_root
+
"/a/b"
)
...
...
@@ -463,7 +463,7 @@ def test_loadable_constants_for_path_should_uniq_results
end
def
test_loadable_constants_with_load_path_without_trailing_slash
path
=
File
.
dirname
(
__FILE__
)
+
"/autoloading_fixtures/class_folder/inline_class.rb"
path
=
File
.
expand_path
(
"autoloading_fixtures/class_folder/inline_class.rb"
,
__dir__
)
with_loading
"autoloading_fixtures/class/"
do
assert_equal
[],
ActiveSupport
::
Dependencies
.
loadable_constants_for_path
(
path
)
end
...
...
@@ -991,7 +991,7 @@ def test_remove_constant_handles_double_colon_at_start
def
test_remove_constant_does_not_trigger_loading_autoloads
constant
=
"ShouldNotBeAutoloaded"
Object
.
class_eval
do
autoload
constant
,
File
.
expand_path
(
"
../autoloading_fixtures/should_not_be_required"
,
__FILE
__
)
autoload
constant
,
File
.
expand_path
(
"
autoloading_fixtures/should_not_be_required"
,
__dir
__
)
end
assert_nil
ActiveSupport
::
Dependencies
.
remove_constant
(
constant
),
"Kernel#autoload has been triggered by remove_constant"
...
...
activesupport/test/dependencies_test_helpers.rb
浏览文件 @
4cfcf1ee
module
DependenciesTestHelpers
def
with_loading
(
*
from
)
old_mechanism
,
ActiveSupport
::
Dependencies
.
mechanism
=
ActiveSupport
::
Dependencies
.
mechanism
,
:load
this_dir
=
File
.
dirname
(
__FILE__
)
this_dir
=
__dir__
parent_dir
=
File
.
dirname
(
this_dir
)
path_copy
=
$LOAD_PATH
.
dup
$LOAD_PATH
.
unshift
(
parent_dir
)
unless
$LOAD_PATH
.
include?
(
parent_dir
)
...
...
activesupport/test/testing/file_fixtures_test.rb
浏览文件 @
4cfcf1ee
...
...
@@ -3,7 +3,7 @@
require
"pathname"
class
FileFixturesTest
<
ActiveSupport
::
TestCase
self
.
file_fixture_path
=
File
.
expand_path
(
"../
../file_fixtures"
,
__FILE
__
)
self
.
file_fixture_path
=
File
.
expand_path
(
"../
file_fixtures"
,
__dir
__
)
test
"#file_fixture returns Pathname to file fixture"
do
path
=
file_fixture
(
"sample.txt"
)
...
...
@@ -20,7 +20,7 @@ class FileFixturesTest < ActiveSupport::TestCase
end
class
FileFixturesPathnameDirectoryTest
<
ActiveSupport
::
TestCase
self
.
file_fixture_path
=
Pathname
.
new
(
File
.
expand_path
(
"../
../file_fixtures"
,
__FILE
__
))
self
.
file_fixture_path
=
Pathname
.
new
(
File
.
expand_path
(
"../
file_fixtures"
,
__dir
__
))
test
"#file_fixture_path returns Pathname to file fixture"
do
path
=
file_fixture
(
"sample.txt"
)
...
...
activesupport/test/xml_mini/jdom_engine_test.rb
浏览文件 @
4cfcf1ee
...
...
@@ -2,7 +2,7 @@
XMLMiniEngineTest
.
run_with_platform
(
"java"
)
do
class
JDOMEngineTest
<
XMLMiniEngineTest
FILES_DIR
=
File
.
dirname
(
__FILE__
)
+
"/../fixtures/xml"
FILES_DIR
=
File
.
expand_path
(
"../fixtures/xml"
,
__dir__
)
def
test_not_allowed_to_expand_entities_to_files
attack_xml
=
<<-
EOT
...
...
guides/bug_report_templates/action_controller_gem.rb
浏览文件 @
4cfcf1ee
...
...
@@ -15,7 +15,7 @@
require
"action_controller/railtie"
class
TestApp
<
Rails
::
Application
config
.
root
=
File
.
dirname
(
__FILE__
)
config
.
root
=
__dir__
config
.
session_store
:cookie_store
,
key:
"cookie_store_key"
secrets
.
secret_token
=
"secret_token"
secrets
.
secret_key_base
=
"secret_key_base"
...
...
guides/bug_report_templates/action_controller_master.rb
浏览文件 @
4cfcf1ee
...
...
@@ -14,7 +14,7 @@
require
"action_controller/railtie"
class
TestApp
<
Rails
::
Application
config
.
root
=
File
.
dirname
(
__FILE__
)
config
.
root
=
__dir__
secrets
.
secret_token
=
"secret_token"
secrets
.
secret_key_base
=
"secret_key_base"
...
...
guides/rails_guides/helpers.rb
浏览文件 @
4cfcf1ee
...
...
@@ -15,7 +15,7 @@ def guide(name, url, options = {}, &block)
end
def
documents_by_section
@documents_by_section
||=
YAML
.
load_file
(
File
.
expand_path
(
"../
../source/
#{
@language
?
@language
+
'/'
:
''
}
documents.yaml"
,
__FILE
__
))
@documents_by_section
||=
YAML
.
load_file
(
File
.
expand_path
(
"../
source/
#{
@language
?
@language
+
'/'
:
''
}
documents.yaml"
,
__dir
__
))
end
def
documents_flat
...
...
guides/source/generators.md
浏览文件 @
4cfcf1ee
...
...
@@ -96,7 +96,7 @@ This is the generator just created:
```
ruby
class
InitializerGenerator
<
Rails
::
Generators
::
NamedBase
source_root
File
.
expand_path
(
"
../templates"
,
__FILE
__
)
source_root
File
.
expand_path
(
"
templates"
,
__dir
__
)
end
```
...
...
@@ -122,7 +122,7 @@ And now let's change the generator to copy this template when invoked:
```
ruby
class
InitializerGenerator
<
Rails
::
Generators
::
NamedBase
source_root
File
.
expand_path
(
"
../templates"
,
__FILE
__
)
source_root
File
.
expand_path
(
"
templates"
,
__dir
__
)
def
copy_initializer_file
copy_file
"initializer.rb"
,
"config/initializers/
#{
file_name
}
.rb"
...
...
guides/source/rails_application_templates.md
浏览文件 @
4cfcf1ee
...
...
@@ -277,6 +277,6 @@ relative paths to your template's location.
```
ruby
def
source_paths
[
File
.
expand_path
(
File
.
dirname
(
__FILE__
))
]
[
__dir__
]
end
```
guides/source/security.md
浏览文件 @
4cfcf1ee
...
...
@@ -356,7 +356,7 @@ send_file('/var/www/uploads/' + params[:filename])
Simply pass a file name like "../../../etc/passwd" to download the server's login information. A simple solution against this, is to _check that the requested file is in the expected directory_:
```
ruby
basename
=
File
.
expand_path
(
File
.
join
(
File
.
dirname
(
__FILE__
),
'../../files'
)
)
basename
=
File
.
expand_path
(
'../../files'
,
__dir__
)
filename
=
File
.
expand_path
(
File
.
join
(
basename
,
@file
.
public_filename
))
raise
if
basename
!=
File
.
expand_path
(
File
.
join
(
File
.
dirname
(
filename
),
'../../../'
))
...
...
rails.gemspec
浏览文件 @
4cfcf1ee
version
=
File
.
read
(
File
.
expand_path
(
"
../RAILS_VERSION"
,
__FILE
__
)).
strip
version
=
File
.
read
(
File
.
expand_path
(
"
RAILS_VERSION"
,
__dir
__
)).
strip
Gem
::
Specification
.
new
do
|
s
|
s
.
platform
=
Gem
::
Platform
::
RUBY
...
...
railties/Rakefile
浏览文件 @
4cfcf1ee
...
...
@@ -16,10 +16,10 @@ namespace :test do
dash_i
=
[
"test"
,
"lib"
,
"
#{
File
.
dirname
(
__FILE__
)
}
/../activesupport/lib"
,
"
#{
File
.
dirname
(
__FILE__
)
}
/../actionpack/lib"
,
"
#{
File
.
dirname
(
__FILE__
)
}
/../actionview/lib"
,
"
#{
File
.
dirname
(
__FILE__
)
}
/../activemodel/lib"
"
#{
__dir__
}
/../activesupport/lib"
,
"
#{
__dir__
}
/../actionpack/lib"
,
"
#{
__dir__
}
/../actionview/lib"
,
"
#{
__dir__
}
/../activemodel/lib"
]
ruby
"-w"
,
"-I
#{
dash_i
.
join
':'
}
"
,
file
end
...
...
@@ -27,7 +27,7 @@ namespace :test do
end
Rake
::
TestTask
.
new
(
"test:regular"
)
do
|
t
|
t
.
libs
<<
"test"
<<
"
#{
File
.
dirname
(
__FILE__
)
}
/../activesupport/lib"
t
.
libs
<<
"test"
<<
"
#{
__dir__
}
/../activesupport/lib"
t
.
pattern
=
"test/**/*_test.rb"
t
.
warning
=
false
t
.
verbose
=
true
...
...
railties/exe/rails
浏览文件 @
4cfcf1ee
#!/usr/bin/env ruby
git_path
=
File
.
expand_path
(
"../../.
./.git"
,
__FILE
__
)
git_path
=
File
.
expand_path
(
"../../.
git"
,
__dir
__
)
if
File
.
exist?
(
git_path
)
railties_path
=
File
.
expand_path
(
"../
../lib"
,
__FILE
__
)
railties_path
=
File
.
expand_path
(
"../
lib"
,
__dir
__
)
$:
.
unshift
(
railties_path
)
end
require
"rails/cli"
railties/lib/rails/application_controller.rb
浏览文件 @
4cfcf1ee
class
Rails::ApplicationController
<
ActionController
::
Base
# :nodoc:
self
.
view_paths
=
File
.
expand_path
(
"
../templates"
,
__FILE
__
)
self
.
view_paths
=
File
.
expand_path
(
"
templates"
,
__dir
__
)
layout
"application"
private
...
...
railties/lib/rails/command/actions.rb
浏览文件 @
4cfcf1ee
...
...
@@ -5,7 +5,7 @@ module Actions
# This allows us to run `rails server` from other directories, but still get
# the main config.ru and properly set the tmp directory.
def
set_application_directory!
Dir
.
chdir
(
File
.
expand_path
(
"../..
/
"
,
APP_PATH
))
unless
File
.
exist?
(
File
.
expand_path
(
"config.ru"
))
Dir
.
chdir
(
File
.
expand_path
(
"../.."
,
APP_PATH
))
unless
File
.
exist?
(
File
.
expand_path
(
"config.ru"
))
end
def
require_application_and_environment!
...
...
railties/lib/rails/engine.rb
浏览文件 @
4cfcf1ee
...
...
@@ -40,7 +40,7 @@ module Rails
#
# class MyEngine < Rails::Engine
# # Add a load path for this specific Engine
# config.autoload_paths << File.expand_path("
../lib/some/path", __FILE
__)
# config.autoload_paths << File.expand_path("
lib/some/path", __dir
__)
#
# initializer "my_engine.add_middleware" do |app|
# app.middleware.use MyEngine::Middleware
...
...
railties/lib/rails/generators.rb
浏览文件 @
4cfcf1ee
activesupport_path
=
File
.
expand_path
(
"../../../
../activesupport/lib"
,
__FILE
__
)
activesupport_path
=
File
.
expand_path
(
"../../../
activesupport/lib"
,
__dir
__
)
$:
.
unshift
(
activesupport_path
)
if
File
.
directory?
(
activesupport_path
)
&&
!
$:
.
include?
(
activesupport_path
)
require
"thor/group"
...
...
railties/lib/rails/generators/base.rb
浏览文件 @
4cfcf1ee
...
...
@@ -215,7 +215,7 @@ def self.default_source_root
# Returns the base root for a common set of generators. This is used to dynamically
# guess the default source root.
def
self
.
base_root
File
.
dirname
(
__FILE__
)
__dir__
end
# Cache source root and add lib/generators/base/generator/templates to
...
...
railties/lib/rails/generators/css/assets/assets_generator.rb
浏览文件 @
4cfcf1ee
...
...
@@ -3,7 +3,7 @@
module
Css
# :nodoc:
module
Generators
# :nodoc:
class
AssetsGenerator
<
Rails
::
Generators
::
NamedBase
# :nodoc:
source_root
File
.
expand_path
(
"
../templates"
,
__FILE
__
)
source_root
File
.
expand_path
(
"
templates"
,
__dir
__
)
def
copy_stylesheet
copy_file
"stylesheet.css"
,
File
.
join
(
"app/assets/stylesheets"
,
class_path
,
"
#{
file_name
}
.css"
)
...
...
railties/lib/rails/generators/js/assets/assets_generator.rb
浏览文件 @
4cfcf1ee
...
...
@@ -3,7 +3,7 @@
module
Js
# :nodoc:
module
Generators
# :nodoc:
class
AssetsGenerator
<
Rails
::
Generators
::
NamedBase
# :nodoc:
source_root
File
.
expand_path
(
"
../templates"
,
__FILE
__
)
source_root
File
.
expand_path
(
"
templates"
,
__dir
__
)
def
copy_javascript
copy_file
"javascript.js"
,
File
.
join
(
"app/assets/javascripts"
,
class_path
,
"
#{
file_name
}
.js"
)
...
...
railties/lib/rails/generators/rails/app/app_generator.rb
浏览文件 @
4cfcf1ee
...
...
@@ -201,7 +201,7 @@ def vendor
module
Generators
# We need to store the RAILS_DEV_PATH in a constant, otherwise the path
# can change in Ruby 1.8.7 when we FileUtils.cd.
RAILS_DEV_PATH
=
File
.
expand_path
(
"../../../../../.."
,
File
.
dirname
(
__FILE__
)
)
RAILS_DEV_PATH
=
File
.
expand_path
(
"../../../../../.."
,
__dir__
)
RESERVED_NAMES
=
%w[application destroy plugin runner test]
class
AppGenerator
<
AppBase
# :nodoc:
...
...
railties/lib/rails/generators/rails/app/templates/bin/bundle
浏览文件 @
4cfcf1ee
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../
../Gemfile', __FILE
__)
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../
Gemfile', __dir
__)
load Gem.bin_path('bundler', 'bundle')
railties/lib/rails/generators/rails/app/templates/bin/setup.tt
浏览文件 @
4cfcf1ee
...
...
@@ -3,7 +3,7 @@ require 'fileutils'
include FileUtils
# path to your application root.
APP_ROOT = Pathname.new File.expand_path('..
/../', __FILE
__)
APP_ROOT = Pathname.new File.expand_path('..
', __dir
__)
def system!(*args)
system(*args) || abort("\n== Command #{args} failed ==")
...
...
railties/lib/rails/generators/rails/app/templates/bin/update.tt
浏览文件 @
4cfcf1ee
...
...
@@ -3,7 +3,7 @@ require 'fileutils'
include FileUtils
# path to your application root.
APP_ROOT = Pathname.new File.expand_path('..
/../', __FILE
__)
APP_ROOT = Pathname.new File.expand_path('..
', __dir
__)
def system!(*args)
system(*args) || abort("\n== Command #{args} failed ==")
...
...
railties/lib/rails/generators/rails/app/templates/test/test_helper.rb
浏览文件 @
4cfcf1ee
require
File
.
expand_path
(
'../
../config/environment'
,
__FILE
__
)
require
File
.
expand_path
(
'../
config/environment'
,
__dir
__
)
require
'rails/test_help'
class
ActiveSupport::TestCase
...
...
railties/lib/rails/generators/rails/generator/templates/%file_name%_generator.rb.tt
浏览文件 @
4cfcf1ee
class <%= class_name %>Generator < Rails::Generators::NamedBase
source_root File.expand_path('
../templates', __FILE
__)
source_root File.expand_path('
templates', __dir
__)
end
railties/lib/rails/generators/rails/plugin/templates/%name%.gemspec
浏览文件 @
4cfcf1ee
$:
.
push
File
.
expand_path
(
"
../lib"
,
__FILE
__
)
$:
.
push
File
.
expand_path
(
"
lib"
,
__dir
__
)
# Maintain your gem's version:
require
"<%= namespaced_name %>/version"
...
...
railties/lib/rails/generators/rails/plugin/templates/Rakefile
浏览文件 @
4cfcf1ee
...
...
@@ -15,7 +15,7 @@ RDoc::Task.new(:rdoc) do |rdoc|
end
<
% if
engine?
&&
!
options
[
:skip_active_record
]
&&
with_dummy_app?
-
%>
APP_RAKEFILE = File.expand_path("
../<%= dummy_path -%>
/Rakefile", __FILE
__)
APP_RAKEFILE = File.expand_path("
<%= dummy_path -%>
/Rakefile", __dir
__)
load 'rails/
tasks
/
engine
.
rake
'
<% end %>
...
...
railties/lib/rails/generators/rails/plugin/templates/bin/rails.tt
浏览文件 @
4cfcf1ee
# This command will automatically be run when you run "rails" with Rails gems
# installed from the root of your application.
ENGINE_ROOT = File.expand_path('..
/..', __FILE
__)
ENGINE_PATH = File.expand_path('../
../lib/<%= namespaced_name -%>/engine', __FILE
__)
APP_PATH = File.expand_path('../
../<%= dummy_path -%>/config/application', __FILE
__)
ENGINE_ROOT = File.expand_path('..
', __dir
__)
ENGINE_PATH = File.expand_path('../
lib/<%= namespaced_name -%>/engine', __dir
__)
APP_PATH = File.expand_path('../
<%= dummy_path -%>/config/application', __dir
__)
# Set up gems listed in the Gemfile.
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../
../Gemfile', __FILE
__)
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../
Gemfile', __dir
__)
require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
require 'rails/all'
...
...
railties/lib/rails/generators/rails/plugin/templates/bin/test.tt
浏览文件 @
4cfcf1ee
此差异已折叠。
点击以展开。
railties/lib/rails/generators/rails/plugin/templates/test/test_helper.rb
浏览文件 @
4cfcf1ee
此差异已折叠。
点击以展开。
railties/lib/rails/generators/test_case.rb
浏览文件 @
4cfcf1ee
此差异已折叠。
点击以展开。
railties/lib/rails/generators/testing/behaviour.rb
浏览文件 @
4cfcf1ee
此差异已折叠。
点击以展开。
railties/lib/rails/tasks/framework.rake
浏览文件 @
4cfcf1ee
此差异已折叠。
点击以展开。
railties/railties.gemspec
浏览文件 @
4cfcf1ee
此差异已折叠。
点击以展开。
railties/test/abstract_unit.rb
浏览文件 @
4cfcf1ee
此差异已折叠。
点击以展开。
railties/test/application/test_runner_test.rb
浏览文件 @
4cfcf1ee
此差异已折叠。
点击以展开。
railties/test/code_statistics_calculator_test.rb
浏览文件 @
4cfcf1ee
此差异已折叠。
点击以展开。
railties/test/code_statistics_test.rb
浏览文件 @
4cfcf1ee
此差异已折叠。
点击以展开。
railties/test/fixtures/lib/generators/usage_template/usage_template_generator.rb
浏览文件 @
4cfcf1ee
此差异已折叠。
点击以展开。
railties/test/generators/generators_test_helper.rb
浏览文件 @
4cfcf1ee
此差异已折叠。
点击以展开。
railties/test/generators/plugin_generator_test.rb
浏览文件 @
4cfcf1ee
此差异已折叠。
点击以展开。
railties/test/generators_test.rb
浏览文件 @
4cfcf1ee
此差异已折叠。
点击以展开。
railties/test/isolation/abstract_unit.rb
浏览文件 @
4cfcf1ee
此差异已折叠。
点击以展开。
railties/test/rails_info_test.rb
浏览文件 @
4cfcf1ee
此差异已折叠。
点击以展开。
tasks/release.rb
浏览文件 @
4cfcf1ee
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录