Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
71f7e75d
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,发现更多精彩内容 >>
提交
71f7e75d
编写于
10月 15, 2009
作者:
J
Jeremy Kemper
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'master' into orchestra
上级
2d7abe24
ef70ad55
变更
42
隐藏空白更改
内联
并排
Showing
42 changed file
with
137 addition
and
90 deletion
+137
-90
actionmailer/test/abstract_unit.rb
actionmailer/test/abstract_unit.rb
+1
-1
actionpack/Gemfile
actionpack/Gemfile
+1
-1
actionpack/lib/action_view/base.rb
actionpack/lib/action_view/base.rb
+10
-1
actionpack/test/abstract_unit.rb
actionpack/test/abstract_unit.rb
+2
-2
actionpack/test/controller/new_base/content_negotiation_test.rb
...pack/test/controller/new_base/content_negotiation_test.rb
+1
-1
actionpack/test/controller/new_base/metal_test.rb
actionpack/test/controller/new_base/metal_test.rb
+2
-2
actionpack/test/controller/rescue_test.rb
actionpack/test/controller/rescue_test.rb
+1
-1
actionpack/test/dispatch/test_request_test.rb
actionpack/test/dispatch/test_request_test.rb
+1
-1
railties/lib/rails/commands/about.rb
railties/lib/rails/commands/about.rb
+2
-1
railties/lib/rails/commands/destroy.rb
railties/lib/rails/commands/destroy.rb
+1
-1
railties/lib/rails/commands/generate.rb
railties/lib/rails/commands/generate.rb
+1
-1
railties/lib/rails/commands/performance/benchmarker.rb
railties/lib/rails/commands/performance/benchmarker.rb
+1
-1
railties/lib/rails/commands/performance/profiler.rb
railties/lib/rails/commands/performance/profiler.rb
+1
-1
railties/lib/rails/commands/runner.rb
railties/lib/rails/commands/runner.rb
+1
-1
railties/lib/rails/commands/update.rb
railties/lib/rails/commands/update.rb
+0
-1
railties/lib/rails/generators/actions.rb
railties/lib/rails/generators/actions.rb
+1
-1
railties/lib/rails/generators/rails/app/app_generator.rb
railties/lib/rails/generators/rails/app/app_generator.rb
+1
-0
railties/lib/rails/generators/rails/app/templates/Rakefile
railties/lib/rails/generators/rails/app/templates/Rakefile
+1
-1
railties/lib/rails/generators/rails/app/templates/config.ru
railties/lib/rails/generators/rails/app/templates/config.ru
+1
-1
railties/lib/rails/generators/rails/app/templates/config/application.rb
...ails/generators/rails/app/templates/config/application.rb
+48
-0
railties/lib/rails/generators/rails/app/templates/config/environment.rb
...ails/generators/rails/app/templates/config/environment.rb
+4
-48
railties/lib/rails/generators/rails/app/templates/script/about.tt
.../lib/rails/generators/rails/app/templates/script/about.tt
+1
-1
railties/lib/rails/generators/rails/app/templates/script/console.tt
...ib/rails/generators/rails/app/templates/script/console.tt
+1
-1
railties/lib/rails/generators/rails/app/templates/script/dbconsole.tt
.../rails/generators/rails/app/templates/script/dbconsole.tt
+1
-1
railties/lib/rails/generators/rails/app/templates/script/destroy.tt
...ib/rails/generators/rails/app/templates/script/destroy.tt
+1
-1
railties/lib/rails/generators/rails/app/templates/script/generate.tt
...b/rails/generators/rails/app/templates/script/generate.tt
+1
-1
railties/lib/rails/generators/rails/app/templates/script/performance/benchmarker.tt
...ors/rails/app/templates/script/performance/benchmarker.tt
+1
-1
railties/lib/rails/generators/rails/app/templates/script/performance/profiler.tt
...rators/rails/app/templates/script/performance/profiler.tt
+1
-1
railties/lib/rails/generators/rails/app/templates/script/plugin.tt
...lib/rails/generators/rails/app/templates/script/plugin.tt
+1
-1
railties/lib/rails/generators/rails/app/templates/script/runner.tt
...lib/rails/generators/rails/app/templates/script/runner.tt
+1
-1
railties/lib/rails/generators/rails/app/templates/script/server.tt
...lib/rails/generators/rails/app/templates/script/server.tt
+1
-1
railties/lib/rails/initializer.rb
railties/lib/rails/initializer.rb
+0
-1
railties/test/abstract_unit.rb
railties/test/abstract_unit.rb
+1
-0
railties/test/application/generators_test.rb
railties/test/application/generators_test.rb
+4
-0
railties/test/application/initializer_test.rb
railties/test/application/initializer_test.rb
+15
-0
railties/test/application/plugins_test.rb
railties/test/application/plugins_test.rb
+12
-3
railties/test/generators/actions_test.rb
railties/test/generators/actions_test.rb
+5
-5
railties/test/generators/app_generator_test.rb
railties/test/generators/app_generator_test.rb
+1
-1
railties/test/initializer/check_ruby_version_test.rb
railties/test/initializer/check_ruby_version_test.rb
+2
-0
railties/test/initializer/initialize_i18n_test.rb
railties/test/initializer/initialize_i18n_test.rb
+2
-0
railties/test/initializer/path_test.rb
railties/test/initializer/path_test.rb
+1
-0
railties/test/isolation/abstract_unit.rb
railties/test/isolation/abstract_unit.rb
+2
-2
未找到文件。
actionmailer/test/abstract_unit.rb
浏览文件 @
71f7e75d
...
...
@@ -20,7 +20,7 @@
ActionView
::
Template
.
register_template_handler
:haml
,
lambda
{
|
template
|
"Look its HAML!"
.
inspect
}
ActionView
::
Template
.
register_template_handler
:bak
,
lambda
{
|
template
|
"Lame backup"
.
inspect
}
ActionView
::
Base
.
config
=
{
:assets_dir
=>
'/nowhere'
}
ActionView
::
Base
::
DEFAULT_CONFIG
=
{
:assets_dir
=>
'/nowhere'
}
$:
.
unshift
"
#{
File
.
dirname
(
__FILE__
)
}
/fixtures/helpers"
...
...
actionpack/Gemfile
浏览文件 @
71f7e75d
...
...
@@ -2,7 +2,7 @@ rails_root = Pathname.new(File.dirname(__FILE__)).join("..")
Gem
.
sources
.
each
{
|
uri
|
source
uri
}
gem
"rack"
,
"
~> 1.0
.0"
gem
"rack"
,
"
1.0.1"
,
:git
=>
"git://github.com/rack/rack.git"
,
:branch
=>
"rack-1
.0"
gem
"rack-test"
,
"~> 0.5.0"
gem
"activesupport"
,
"3.0.pre"
,
:vendored_at
=>
rails_root
.
join
(
"activesupport"
)
gem
"activemodel"
,
"3.0.pre"
,
:vendored_at
=>
rails_root
.
join
(
"activemodel"
)
...
...
actionpack/lib/action_view/base.rb
浏览文件 @
71f7e75d
...
...
@@ -167,7 +167,16 @@ class Base
module
Subclasses
end
include
Helpers
,
Rendering
,
Partials
,
::
ERB
::
Util
,
ActiveSupport
::
Configurable
include
Helpers
,
Rendering
,
Partials
,
::
ERB
::
Util
def
config
self
.
config
=
DEFAULT_CONFIG
unless
@config
@config
end
def
config
=
(
config
)
@config
=
ActiveSupport
::
OrderedOptions
.
new
.
merge
(
config
)
end
extend
ActiveSupport
::
Memoizable
...
...
actionpack/test/abstract_unit.rb
浏览文件 @
71f7e75d
...
...
@@ -176,8 +176,8 @@ class ::ApplicationController < ActionController::Base
end
module
ActionController
class
<<
Routing
def
possible_controllers
module
Routing
def
self
.
possible_controllers
@@possible_controllers
||=
[]
end
end
...
...
actionpack/test/controller/new_base/content_negotiation_test.rb
浏览文件 @
71f7e75d
...
...
@@ -5,7 +5,7 @@ module ContentNegotiation
# This has no layout and it works
class
BasicController
<
ActionController
::
Base
self
.
view_paths
=
[
ActionView
::
FixtureResolver
.
new
(
"content_negotiation/basic/hello.html.erb"
=>
"Hello world <%= request.formats %>!"
"content_negotiation/basic/hello.html.erb"
=>
"Hello world <%= request.formats
.first.to_s
%>!"
)]
end
...
...
actionpack/test/controller/new_base/metal_test.rb
浏览文件 @
71f7e75d
...
...
@@ -20,8 +20,8 @@ def call(env)
class
TestMiddleware
<
ActiveSupport
::
TestCase
def
setup
@app
=
Rack
::
Builder
.
new
do
use
MetalMiddleware
run
Endpoint
.
new
use
Metal
Test
::
Metal
Middleware
run
MetalTest
::
Endpoint
.
new
end
.
to_app
end
...
...
actionpack/test/controller/rescue_test.rb
浏览文件 @
71f7e75d
...
...
@@ -327,7 +327,7 @@ def show_errors(exception)
test
'rescue routing exceptions'
do
@app
=
ActionDispatch
::
Rescue
.
new
(
ActionController
::
Routing
::
Routes
)
do
rescue_from
ActionController
::
RoutingError
,
lambda
{
|
env
|
[
200
,
{
"Content-Type"
=>
"text/html"
},
"Gotcha!"
]
}
rescue_from
ActionController
::
RoutingError
,
lambda
{
|
env
|
[
200
,
{
"Content-Type"
=>
"text/html"
},
[
"Gotcha!"
]
]
}
end
get
'/b00m'
...
...
actionpack/test/dispatch/test_request_test.rb
浏览文件 @
71f7e75d
...
...
@@ -18,7 +18,7 @@ class TestRequestTest < ActiveSupport::TestCase
assert_equal
"0.0.0.0"
,
env
.
delete
(
"REMOTE_ADDR"
)
assert_equal
"Rails Testing"
,
env
.
delete
(
"HTTP_USER_AGENT"
)
assert_equal
[
0
,
1
],
env
.
delete
(
"rack.version"
)
assert_equal
[
1
,
0
],
env
.
delete
(
"rack.version"
)
assert_equal
""
,
env
.
delete
(
"rack.input"
).
string
assert_kind_of
StringIO
,
env
.
delete
(
"rack.errors"
)
assert_equal
true
,
env
.
delete
(
"rack.multithread"
)
...
...
railties/lib/rails/commands/about.rb
浏览文件 @
71f7e75d
require
"
#{
RAILS_ROOT
}
/config/environment"
require
"
#{
RAILS_ROOT
}
/config/application"
Rails
.
application
.
new
require
'rails/info'
puts
Rails
::
Info
railties/lib/rails/commands/destroy.rb
浏览文件 @
71f7e75d
require
File
.
expand_path
(
File
.
join
(
File
.
dirname
(
__FILE__
),
'..'
,
'generators'
))
require
"
#{
RAILS_ROOT
}
/config/
environment
"
require
"
#{
RAILS_ROOT
}
/config/
application
"
if
ARGV
.
size
==
0
Rails
::
Generators
.
help
...
...
railties/lib/rails/commands/generate.rb
浏览文件 @
71f7e75d
require
File
.
expand_path
(
File
.
join
(
File
.
dirname
(
__FILE__
),
'..'
,
'generators'
))
require
"
#{
RAILS_ROOT
}
/config/environment"
Rails
.
application
.
new
if
ARGV
.
size
==
0
Rails
::
Generators
.
help
...
...
railties/lib/rails/commands/performance/benchmarker.rb
浏览文件 @
71f7e75d
...
...
@@ -10,9 +10,9 @@
N
=
1
end
require
RAILS_ROOT
+
'/config/environment'
require
'benchmark'
include
Benchmark
Rails
.
application
.
new
# Don't include compilation in the benchmark
ARGV
.
each
{
|
expression
|
eval
(
expression
)
}
...
...
railties/lib/rails/commands/performance/profiler.rb
浏览文件 @
71f7e75d
...
...
@@ -5,7 +5,7 @@
# Keep the expensive require out of the profile.
$stderr
.
puts
'Loading Rails...'
require
RAILS_ROOT
+
'/config/environment'
Rails
.
application
.
new
# Initialize the application
# Define a method to profile.
if
ARGV
[
1
]
and
ARGV
[
1
].
to_i
>
1
...
...
railties/lib/rails/commands/runner.rb
浏览文件 @
71f7e75d
...
...
@@ -36,7 +36,7 @@
ENV
[
"RAILS_ENV"
]
=
options
[
:environment
]
RAILS_ENV
.
replace
(
options
[
:environment
])
if
defined?
(
RAILS_ENV
)
require
RAILS_ROOT
+
'/config/environment'
Rails
.
application
.
new
begin
if
code_or_file
.
nil?
...
...
railties/lib/rails/commands/update.rb
浏览文件 @
71f7e75d
require
File
.
expand_path
(
File
.
join
(
File
.
dirname
(
__FILE__
),
'..'
,
'generators'
))
require
"
#{
RAILS_ROOT
}
/config/environment"
if
ARGV
.
size
==
0
Rails
::
Generators
.
help
...
...
railties/lib/rails/generators/actions.rb
浏览文件 @
71f7e75d
...
...
@@ -71,7 +71,7 @@ def environment(data=nil, options={}, &block)
in_root
do
if
options
[
:env
].
nil?
inject_into_file
'config/
environment
.rb'
,
"
\n
#{
data
}
"
,
:after
=>
sentinel
,
:verbose
=>
false
inject_into_file
'config/
application
.rb'
,
"
\n
#{
data
}
"
,
:after
=>
sentinel
,
:verbose
=>
false
else
Array
.
wrap
(
options
[
:env
]).
each
do
|
env
|
append_file
"config/environments/
#{
env
}
.rb"
,
"
\n
#{
data
}
"
,
:verbose
=>
false
...
...
railties/lib/rails/generators/rails/app/app_generator.rb
浏览文件 @
71f7e75d
...
...
@@ -66,6 +66,7 @@ def create_config_files
inside
"config"
do
copy_file
"routes.rb"
template
"application.rb"
template
"environment.rb"
directory
"environments"
...
...
railties/lib/rails/generators/rails/app/templates/Rakefile
浏览文件 @
71f7e75d
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
require
(
File
.
join
(
File
.
dirname
(
__FILE__
),
'config'
,
'boo
t'
))
require
File
.
expand_path
(
File
.
join
(
File
.
dirname
(
__FILE__
),
'config'
,
'environmen
t'
))
require
'rake'
require
'rake/testtask'
...
...
railties/lib/rails/generators/rails/app/templates/config.ru
浏览文件 @
71f7e75d
# Require your environment file to bootstrap Rails
require
::
File
.
dirname
(
__FILE__
)
+
'/config/environment'
require
File
.
expand_path
(
'../config/application'
,
__FILE__
)
# Dispatch the request
run
Rails
.
application
.
new
railties/lib/rails/generators/rails/app/templates/config/application.rb
0 → 100644
浏览文件 @
71f7e75d
# Bootstrap the Rails environment, frameworks, and default configuration
require
File
.
expand_path
(
File
.
join
(
File
.
dirname
(
__FILE__
),
'boot'
))
Rails
::
Initializer
.
run
do
|
config
|
# Settings in config/environments/* take precedence over those specified here.
# Application configuration should go into files in config/initializers
# -- all .rb files in that directory are automatically loaded.
# Add additional load paths for your own custom dirs
# config.load_paths += %W( #{RAILS_ROOT}/extras )
# Specify gems that this application depends on and have them installed with rake gems:install
# config.gem "bj"
# config.gem "hpricot", :version => '0.6', :source => "http://code.whytheluckystiff.net"
# config.gem "sqlite3-ruby", :lib => "sqlite3"
# config.gem "aws-s3", :lib => "aws/s3"
# Only load the plugins named here, in the order given (default is alphabetical).
# :all can be used as a placeholder for all plugins not explicitly named
# config.plugins = [ :exception_notification, :ssl_requirement, :all ]
# Skip frameworks you're not going to use. To use Rails without a database,
# you must remove the Active Record framework.
<
% if
options
[
:skip_activerecord
]
-
%>
config.frameworks -= [ :active_record ]
<% else -%>
# config.frameworks -= [ :active_record, :active_resource, :action_mailer ]
# Activate observers that should always be running
# config.active_record.observers = :cacher, :garbage_collector, :forum_observer
<
% end
-
%>
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
# Run "rake -D time" for a list of tasks for finding time zone names.
config.time_zone = 'UTC'
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}')]
# config.i18n.default_locale = :de
# Configure generators values. Many other options are available, be sure to
# check the documentation.
# config.generators do |g|
# g.orm :active_record
# g.template_engine :erb
# g.test_framework :test_unit, :fixture =>
true
# end
end
\ No newline at end of file
railties/lib/rails/generators/rails/app/templates/config/environment.rb
浏览文件 @
71f7e75d
...
...
@@ -3,51 +3,7 @@
# Specifies gem version of Rails to use when vendor/rails is not present
<
%= '# ' if options[:freeze] %>RAILS_GEM_VERSION =
'<%= Rails::VERSION::STRING %>'
unless
defined?
RAILS_GEM_VERSION
# Bootstrap the Rails environment, frameworks, and default configuration
require
File
.
join
(
File
.
dirname
(
__FILE__
),
'boot'
)
Rails
::
Initializer
.
run
do
|
config
|
# Settings in config/environments/* take precedence over those specified here.
# Application configuration should go into files in config/initializers
# -- all .rb files in that directory are automatically loaded.
# Add additional load paths for your own custom dirs
# config.load_paths += %W( #{RAILS_ROOT}/extras )
# Specify gems that this application depends on and have them installed with rake gems:install
# config.gem "bj"
# config.gem "hpricot", :version => '0.6', :source => "http://code.whytheluckystiff.net"
# config.gem "sqlite3-ruby", :lib => "sqlite3"
# config.gem "aws-s3", :lib => "aws/s3"
# Only load the plugins named here, in the order given (default is alphabetical).
# :all can be used as a placeholder for all plugins not explicitly named
# config.plugins = [ :exception_notification, :ssl_requirement, :all ]
# Skip frameworks you're not going to use. To use Rails without a database,
# you must remove the Active Record framework.
<
% if
options
[
:skip_activerecord
]
-
%>
config.frameworks -= [ :active_record ]
<% else -%>
# config.frameworks -= [ :active_record, :active_resource, :action_mailer ]
# Activate observers that should always be running
# config.active_record.observers = :cacher, :garbage_collector, :forum_observer
<
% end
-
%>
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
# Run "rake -D time" for a list of tasks for finding time zone names.
config.time_zone = 'UTC'
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}')]
# config.i18n.default_locale = :de
# Configure generators values. Many other options are available, be sure to
# check the documentation.
# config.generators do |g|
# g.orm :active_record
# g.template_engine :erb
# g.test_framework :test_unit, :fixture =>
true
# end
end
# Load the rails application
require
File
.
expand_path
(
File
.
join
(
File
.
dirname
(
__FILE__
),
'application'
))
# Initialize the rails application
Rails
.
application
.
new
railties/lib/rails/generators/rails/app/templates/script/about.tt
浏览文件 @
71f7e75d
<%= shebang %>
require File.expand_path('../../config/
boot
', __FILE__)
require File.expand_path('../../config/
application
', __FILE__)
$LOAD_PATH.unshift "#{RAILTIES_PATH}/builtin/rails_info"
require 'rails/commands/about'
railties/lib/rails/generators/rails/app/templates/script/console.tt
浏览文件 @
71f7e75d
<%= shebang %>
require File.expand_path('../../config/
boot
', __FILE__)
require File.expand_path('../../config/
application
', __FILE__)
require 'rails/commands/console'
railties/lib/rails/generators/rails/app/templates/script/dbconsole.tt
浏览文件 @
71f7e75d
<%= shebang %>
require File.expand_path('../../config/
boot
', __FILE__)
require File.expand_path('../../config/
application
', __FILE__)
require 'rails/commands/dbconsole'
railties/lib/rails/generators/rails/app/templates/script/destroy.tt
浏览文件 @
71f7e75d
<%= shebang %>
require File.expand_path('../../config/
boot
', __FILE__)
require File.expand_path('../../config/
application
', __FILE__)
require 'rails/commands/destroy'
railties/lib/rails/generators/rails/app/templates/script/generate.tt
浏览文件 @
71f7e75d
<%= shebang %>
require File.expand_path('../../config/
boot
', __FILE__)
require File.expand_path('../../config/
application
', __FILE__)
require 'rails/commands/generate'
railties/lib/rails/generators/rails/app/templates/script/performance/benchmarker.tt
浏览文件 @
71f7e75d
<%= shebang %>
require File.expand_path('../../../config/
boot
', __FILE__)
require File.expand_path('../../../config/
application
', __FILE__)
require 'rails/commands/performance/benchmarker'
railties/lib/rails/generators/rails/app/templates/script/performance/profiler.tt
浏览文件 @
71f7e75d
<%= shebang %>
require File.expand_path('../../../config/
boot
', __FILE__)
require File.expand_path('../../../config/
application
', __FILE__)
require 'rails/commands/performance/profiler'
railties/lib/rails/generators/rails/app/templates/script/plugin.tt
浏览文件 @
71f7e75d
<%= shebang %>
require File.expand_path('../../config/
boot
', __FILE__)
require File.expand_path('../../config/
application
', __FILE__)
require 'rails/commands/plugin'
railties/lib/rails/generators/rails/app/templates/script/runner.tt
浏览文件 @
71f7e75d
<%= shebang %>
require File.expand_path('../../config/
boot
', __FILE__)
require File.expand_path('../../config/
application
', __FILE__)
require 'rails/commands/runner'
railties/lib/rails/generators/rails/app/templates/script/server.tt
浏览文件 @
71f7e75d
<%= shebang %>
require File.expand_path('../../config/
boot
', __FILE__)
require File.expand_path('../../config/
application
', __FILE__)
require 'rails/commands/server'
railties/lib/rails/initializer.rb
浏览文件 @
71f7e75d
...
...
@@ -21,7 +21,6 @@ def self.run(initializer = nil, config = nil)
else
Rails
.
application
=
Class
.
new
(
Application
)
yield
Rails
.
application
.
config
if
block_given?
Rails
.
application
.
new
end
end
end
...
...
railties/test/abstract_unit.rb
浏览文件 @
71f7e75d
...
...
@@ -16,6 +16,7 @@
require
'test/unit'
require
'active_support'
require
'active_support/core_ext/logger'
require
'active_support/test_case'
require
'action_controller'
...
...
railties/test/application/generators_test.rb
浏览文件 @
71f7e75d
...
...
@@ -41,6 +41,8 @@ def setup
c
.
generators
.
orm
:datamapper
c
.
generators
.
test_framework
:rspec
end
# Initialize the application
Rails
.
application
.
new
assert_equal
:rspec
,
Rails
::
Generators
.
options
[
:rails
][
:test_framework
]
assert_equal
"-w"
,
Rails
::
Generators
.
aliases
[
:rails
][
:test_framework
]
...
...
@@ -50,6 +52,8 @@ def setup
Rails
::
Initializer
.
run
do
|
c
|
c
.
generators
.
colorize_logging
=
false
end
# Initialize the application
Rails
.
application
.
new
assert_equal
Thor
::
Base
.
shell
,
Thor
::
Shell
::
Basic
end
...
...
railties/test/application/initializer_test.rb
浏览文件 @
71f7e75d
...
...
@@ -52,6 +52,8 @@ module Zoo::ReptileHouse ; end
config
.
eager_load_paths
=
"
#{
app_path
}
/lib"
end
Rails
.
application
.
new
assert
Zoo
end
...
...
@@ -59,6 +61,7 @@ module Zoo::ReptileHouse ; end
app_file
"config/environments/development.rb"
,
"$initialize_test_set_from_env = 'success'"
assert_nil
$initialize_test_set_from_env
Rails
::
Initializer
.
run
{
}
Rails
.
application
.
new
assert_equal
"success"
,
$initialize_test_set_from_env
end
...
...
@@ -67,6 +70,7 @@ module Zoo::ReptileHouse ; end
Rails
::
Initializer
.
run
do
|
config
|
config
.
frameworks
=
[]
end
Rails
.
application
.
new
end
end
...
...
@@ -74,6 +78,7 @@ module Zoo::ReptileHouse ; end
Rails
::
Initializer
.
run
do
|
config
|
config
.
frameworks
=
[
:action_controller
]
end
Rails
.
application
.
new
assert
$:
.
include?
(
"
#{
framework_path
}
/actionpack/lib"
)
end
...
...
@@ -82,6 +87,7 @@ module Zoo::ReptileHouse ; end
Rails
::
Initializer
.
run
do
|
config
|
config
.
frameworks
=
[
:action_view
]
end
Rails
.
application
.
new
assert
$:
.
include?
(
"
#{
framework_path
}
/actionpack/lib"
)
end
...
...
@@ -91,6 +97,7 @@ module Zoo::ReptileHouse ; end
config
.
after_initialize
{
$test_after_initialize_block1
=
"success"
}
config
.
after_initialize
{
$test_after_initialize_block2
=
"congratulations"
}
end
Rails
.
application
.
new
assert_equal
"success"
,
$test_after_initialize_block1
assert_equal
"congratulations"
,
$test_after_initialize_block2
...
...
@@ -102,6 +109,7 @@ module Zoo::ReptileHouse ; end
config
.
after_initialize
# don't pass a block, this is what we're testing!
config
.
after_initialize
{
$test_after_initialize_block2
=
"congratulations"
}
end
Rails
.
application
.
new
assert_equal
"success"
,
$test_after_initialize_block1
assert_equal
"congratulations"
,
$test_after_initialize_block2
...
...
@@ -112,6 +120,8 @@ module Zoo::ReptileHouse ; end
Rails
::
Initializer
.
run
do
|
config
|
config
.
i18n
.
default_locale
=
:de
end
Rails
.
application
.
new
assert_equal
:de
,
I18n
.
default_locale
end
...
...
@@ -143,6 +153,7 @@ module Zoo::ReptileHouse ; end
Rails
::
Initializer
.
run
do
|
config
|
config
.
action_controller
.
session_store
=
:cookie_store
end
Rails
.
application
.
new
assert
!
Rails
.
application
.
config
.
middleware
.
include?
(
ActiveRecord
::
SessionStore
)
end
...
...
@@ -158,6 +169,7 @@ module Zoo::ReptileHouse ; end
Rails
::
Initializer
.
run
do
|
c
|
c
.
action_controller
.
session_store
=
:active_record_store
end
Rails
.
application
.
new
expects
=
[
ActiveRecord
::
ConnectionAdapters
::
ConnectionManagement
,
ActiveRecord
::
QueryCache
,
ActiveRecord
::
SessionStore
]
middleware
=
Rails
.
application
.
config
.
middleware
.
map
{
|
m
|
m
.
klass
}
...
...
@@ -169,6 +181,7 @@ module Zoo::ReptileHouse ; end
c
.
frameworks
-=
[
:action_controller
]
c
.
action_controller
.
session_store
=
:active_record_store
end
Rails
.
application
.
new
assert
!
Rails
.
application
.
config
.
middleware
.
include?
(
ActiveRecord
::
SessionStore
)
end
...
...
@@ -178,6 +191,8 @@ module Zoo::ReptileHouse ; end
Rails
::
Initializer
.
run
do
|
c
|
c
.
frameworks
-=
[
:action_view
]
end
Rails
.
application
.
new
assert_equal
nil
,
ActionMailer
::
Base
.
template_root
assert_equal
[],
ActionController
::
Base
.
view_paths
end
...
...
railties/test/application/plugins_test.rb
浏览文件 @
71f7e75d
...
...
@@ -18,6 +18,7 @@ def setup
test
"all plugins are loaded when registered plugin list is untouched"
do
Rails
::
Initializer
.
run
{
}
Rails
.
application
.
new
assert_plugins
[
:a
,
:acts_as_chunky_bacon
,
:engine
,
:gemlike
,
:plugin_with_no_lib_dir
,
:stubby
],
Rails
.
application
.
config
.
loaded_plugins
,
@failure_tip
...
...
@@ -31,6 +32,7 @@ def setup
test
"only the specified plugins are located in the order listed"
do
plugin_names
=
[
:plugin_with_no_lib_dir
,
:acts_as_chunky_bacon
]
Rails
::
Initializer
.
run
{
|
c
|
c
.
plugins
=
plugin_names
}
Rails
.
application
.
new
assert_plugins
plugin_names
,
Rails
.
application
.
config
.
loaded_plugins
end
...
...
@@ -38,6 +40,7 @@ def setup
Rails
::
Initializer
.
run
do
|
config
|
config
.
plugins
=
[
:stubby
,
:all
,
:acts_as_chunky_bacon
]
end
Rails
.
application
.
new
assert_plugins
[
:stubby
,
:a
,
:engine
,
:gemlike
,
:plugin_with_no_lib_dir
,
:acts_as_chunky_bacon
],
Rails
.
application
.
config
.
loaded_plugins
,
@failure_tip
end
...
...
@@ -46,6 +49,7 @@ def setup
Rails
::
Initializer
.
run
do
|
config
|
config
.
plugins
=
[
'stubby'
,
'acts_as_chunky_bacon'
,
:a
,
:plugin_with_no_lib_dir
]
end
Rails
.
application
.
new
assert_plugins
plugin_names
,
Rails
.
application
.
config
.
loaded_plugins
,
@failure_tip
end
...
...
@@ -54,6 +58,7 @@ def setup
Rails
::
Initializer
.
run
do
|
config
|
config
.
plugins
=
[
:stubby
,
:acts_as_chunky_bacon
,
:all
]
end
Rails
.
application
.
new
assert_plugins
[
:stubby
,
:acts_as_chunky_bacon
,
:a
,
:engine
,
:gemlike
,
:plugin_with_no_lib_dir
],
Rails
.
application
.
config
.
loaded_plugins
,
@failure_tip
end
...
...
@@ -62,16 +67,19 @@ def setup
Rails
::
Initializer
.
run
do
|
config
|
config
.
plugins
=
[
:stubby
,
:acts_as_chunky_bacon
]
end
Rails
.
application
.
new
assert
$LOAD_PATH
.
include?
(
"
#{
app_path
}
/vendor/plugins/default/stubby/lib"
)
assert
$LOAD_PATH
.
include?
(
"
#{
app_path
}
/vendor/plugins/default/acts/acts_as_chunky_bacon/lib"
)
end
test
"registering a plugin name that does not exist raises a load error"
do
Rails
::
Initializer
.
run
do
|
config
|
config
.
plugins
=
[
:stubby
,
:acts_as_a_non_existant_plugin
]
end
assert_raise
(
LoadError
)
do
Rails
::
Initializer
.
run
do
|
config
|
config
.
plugins
=
[
:stubby
,
:acts_as_a_non_existant_plugin
]
end
Rails
.
application
.
new
end
end
...
...
@@ -83,6 +91,7 @@ def setup
Rails
::
Initializer
.
run
do
|
config
|
config
.
plugins
=
[
:stubby
,
:acts_as_chunky_bacon
,
:non_existant_plugin1
,
:non_existant_plugin2
]
end
Rails
.
application
.
new
flunk
"Expected a LoadError but did not get one"
rescue
LoadError
=>
e
assert_plugins
valid_plugins
,
Rails
.
application
.
config
.
loaded_plugins
,
@failure_tip
...
...
railties/test/generators/actions_test.rb
浏览文件 @
71f7e75d
...
...
@@ -57,7 +57,7 @@ def test_plugin_with_no_options_should_skip_method
def
test_gem_should_put_gem_dependency_in_enviroment
run_generator
action
:gem
,
'will-paginate'
assert_file
'config/
environment
.rb'
,
/config\.gem 'will\-paginate'/
assert_file
'config/
application
.rb'
,
/config\.gem 'will\-paginate'/
end
def
test_gem_with_options_should_include_options_in_gem_dependency_in_environment
...
...
@@ -65,7 +65,7 @@ def test_gem_with_options_should_include_options_in_gem_dependency_in_environmen
action
:gem
,
'mislav-will-paginate'
,
:lib
=>
'will-paginate'
,
:source
=>
'http://gems.github.com'
regexp
=
/
#{
Regexp
.
escape
(
"config.gem 'mislav-will-paginate', :lib => 'will-paginate', :source => 'http://gems.github.com'"
)
}
/
assert_file
'config/
environment
.rb'
,
regexp
assert_file
'config/
application
.rb'
,
regexp
end
def
test_gem_with_env_string_should_put_gem_dependency_in_specified_environment
...
...
@@ -84,14 +84,14 @@ def test_gem_with_env_array_should_put_gem_dependency_in_specified_environments
def
test_gem_with_lib_option_set_to_false_should_put_gem_dependency_in_enviroment_correctly
run_generator
action
:gem
,
'mislav-will-paginate'
,
:lib
=>
false
assert_file
'config/
environment
.rb'
,
/config\.gem 'mislav\-will\-paginate'\, :lib => false/
assert_file
'config/
application
.rb'
,
/config\.gem 'mislav\-will\-paginate'\, :lib => false/
end
def
test_environment_should_include_data_in_environment_initializer_block
run_generator
load_paths
=
'config.load_paths += %w["#{RAILS_ROOT}/app/extras"]'
action
:environment
,
load_paths
assert_file
'config/
environment
.rb'
,
/
#{
Regexp
.
escape
(
load_paths
)
}
/
assert_file
'config/
application
.rb'
,
/
#{
Regexp
.
escape
(
load_paths
)
}
/
end
def
test_environment_with_block_should_include_block_contents_in_environment_initializer_block
...
...
@@ -102,7 +102,7 @@ def test_environment_with_block_should_include_block_contents_in_environment_ini
'# This will be added'
end
assert_file
'config/
environment
.rb'
do
|
content
|
assert_file
'config/
application
.rb'
do
|
content
|
assert_match
/# This will be added/
,
content
assert_no_match
/# This wont be added/
,
content
end
...
...
railties/test/generators/app_generator_test.rb
浏览文件 @
71f7e75d
...
...
@@ -65,7 +65,7 @@ def test_config_database_is_not_added_if_skip_activerecord_is_given
def
test_activerecord_is_removed_from_frameworks_if_skip_activerecord_is_given
run_generator
[
"--skip-activerecord"
]
assert_file
"config/
environment
.rb"
,
/config\.frameworks \-= \[ :active_record \]/
assert_file
"config/
application
.rb"
,
/config\.frameworks \-= \[ :active_record \]/
end
def
test_prototype_and_test_unit_are_added_by_default
...
...
railties/test/initializer/check_ruby_version_test.rb
浏览文件 @
71f7e75d
...
...
@@ -42,6 +42,7 @@ def assert_rails_boots(version)
set_ruby_version
(
version
)
assert_nothing_raised
"It appears that rails does not boot"
do
Rails
::
Initializer
.
run
{
|
c
|
c
.
frameworks
=
[]
}
Rails
.
application
.
new
end
end
...
...
@@ -50,6 +51,7 @@ def assert_rails_does_not_boot(version)
$stderr
=
File
.
open
(
"/dev/null"
,
"w"
)
assert_raises
(
SystemExit
)
do
Rails
::
Initializer
.
run
{
|
c
|
c
.
frameworks
=
[]
}
Rails
.
application
.
new
end
end
end
...
...
railties/test/initializer/initialize_i18n_test.rb
浏览文件 @
71f7e75d
...
...
@@ -14,6 +14,7 @@ def setup
Rails
::
Initializer
.
run
do
|
c
|
c
.
i18n
.
load_path
<<
"my/other/locale.yml"
end
Rails
.
application
.
new
#{RAILS_FRAMEWORK_ROOT}/railties/test/fixtures/plugins/engines/engine/config/locales/en.yml
assert_equal
%W(
...
...
@@ -35,6 +36,7 @@ def setup
Rails
::
Initializer
.
run
do
|
c
|
c
.
i18n
.
load_path
<<
"my/other/locale.yml"
end
Rails
.
application
.
new
#{RAILS_FRAMEWORK_ROOT}/railties/test/fixtures/plugins/engines/engine/config/locales/en.yml
assert_equal
%W(
...
...
railties/test/initializer/path_test.rb
浏览文件 @
71f7e75d
...
...
@@ -12,6 +12,7 @@ def setup
ActionController
::
Base
.
session_store
=
nil
end
end
Rails
.
application
.
new
@paths
=
Rails
.
application
.
config
.
paths
end
...
...
railties/test/isolation/abstract_unit.rb
浏览文件 @
71f7e75d
...
...
@@ -94,9 +94,9 @@ def build_app(options = {})
end
def
add_to_config
(
str
)
environment
=
File
.
read
(
"
#{
app_path
}
/config/
environment
.rb"
)
environment
=
File
.
read
(
"
#{
app_path
}
/config/
application
.rb"
)
if
environment
=~
/(\n\s*end\s*)\Z/
File
.
open
(
"
#{
app_path
}
/config/
environment
.rb"
,
'w'
)
do
|
f
|
File
.
open
(
"
#{
app_path
}
/config/
application
.rb"
,
'w'
)
do
|
f
|
f
.
puts
$`
+
"
\n
#{
str
}
\n
"
+
$1
end
end
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录