Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
f6709523
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,发现更多精彩内容 >>
提交
f6709523
编写于
9月 07, 2011
作者:
S
Santiago Pastorino
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #2904 from guilleiguaran/refactor-assets-tests
Refactor assets tests to use add_to_config
上级
16f1ce41
1db58367
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
14 addition
and
13 deletion
+14
-13
railties/test/application/assets_test.rb
railties/test/application/assets_test.rb
+14
-13
未找到文件。
railties/test/application/assets_test.rb
浏览文件 @
f6709523
...
@@ -37,7 +37,7 @@ def app
...
@@ -37,7 +37,7 @@ def app
test
"assets do not require compressors until it is used"
do
test
"assets do not require compressors until it is used"
do
app_file
"app/assets/javascripts/demo.js.erb"
,
"<%= :alert %>();"
app_file
"app/assets/javascripts/demo.js.erb"
,
"<%= :alert %>();"
a
pp_file
"config/initializers/compile.rb"
,
"Rails.application.
config.assets.compile = true"
a
dd_to_config
"
config.assets.compile = true"
ENV
[
"RAILS_ENV"
]
=
"production"
ENV
[
"RAILS_ENV"
]
=
"production"
require
"
#{
app_path
}
/config/environment"
require
"
#{
app_path
}
/config/environment"
...
@@ -65,8 +65,9 @@ def app
...
@@ -65,8 +65,9 @@ def app
end
end
test
"asset pipeline should use a Sprockets::Index when config.assets.digest is true"
do
test
"asset pipeline should use a Sprockets::Index when config.assets.digest is true"
do
app_file
"config/initializers/digest.rb"
,
"Rails.application.config.assets.digest = true"
add_to_config
"config.assets.digest = true"
app_file
"config/initializers/caching.rb"
,
"Rails.application.config.action_controller.perform_caching = false"
add_to_config
"config.action_controller.perform_caching = false"
ENV
[
"RAILS_ENV"
]
=
"production"
ENV
[
"RAILS_ENV"
]
=
"production"
require
"
#{
app_path
}
/config/environment"
require
"
#{
app_path
}
/config/environment"
...
@@ -77,7 +78,7 @@ def app
...
@@ -77,7 +78,7 @@ def app
app_file
"app/assets/stylesheets/application.css.erb"
,
"<%= asset_path('rails.png') %>"
app_file
"app/assets/stylesheets/application.css.erb"
,
"<%= asset_path('rails.png') %>"
app_file
"app/assets/javascripts/application.js"
,
"alert();"
app_file
"app/assets/javascripts/application.js"
,
"alert();"
# digest is default in false, we must enable it for test environment
# digest is default in false, we must enable it for test environment
a
pp_file
"config/initializers/compile.rb"
,
"Rails.application.
config.assets.digest = true"
a
dd_to_config
"
config.assets.digest = true"
capture
(
:stdout
)
do
capture
(
:stdout
)
do
Dir
.
chdir
(
app_path
){
`bundle exec rake assets:precompile`
}
Dir
.
chdir
(
app_path
){
`bundle exec rake assets:precompile`
}
...
@@ -93,10 +94,10 @@ def app
...
@@ -93,10 +94,10 @@ def app
test
"precompile creates a manifest file in a custom path with all the assets listed"
do
test
"precompile creates a manifest file in a custom path with all the assets listed"
do
app_file
"app/assets/stylesheets/application.css.erb"
,
"<%= asset_path('rails.png') %>"
app_file
"app/assets/stylesheets/application.css.erb"
,
"<%= asset_path('rails.png') %>"
app_file
"app/assets/javascripts/application.js"
,
"alert();"
app_file
"app/assets/javascripts/application.js"
,
"alert();"
FileUtils
.
mkdir
"
#{
app_path
}
/shared"
app_file
"config/initializers/manifest.rb"
,
"Rails.application.config.assets.manifest = '
#{
app_path
}
/shared'"
# digest is default in false, we must enable it for test environment
# digest is default in false, we must enable it for test environment
app_file
"config/initializers/compile.rb"
,
"Rails.application.config.assets.digest = true"
add_to_config
"config.assets.digest = true"
add_to_config
"config.assets.manifest = '
#{
app_path
}
/shared'"
FileUtils
.
mkdir
"
#{
app_path
}
/shared"
capture
(
:stdout
)
do
capture
(
:stdout
)
do
Dir
.
chdir
(
app_path
){
`bundle exec rake assets:precompile`
}
Dir
.
chdir
(
app_path
){
`bundle exec rake assets:precompile`
}
...
@@ -112,9 +113,9 @@ def app
...
@@ -112,9 +113,9 @@ def app
test
"the manifest file should be saved by default in the same assets folder"
do
test
"the manifest file should be saved by default in the same assets folder"
do
app_file
"app/assets/javascripts/application.js"
,
"alert();"
app_file
"app/assets/javascripts/application.js"
,
"alert();"
app_file
"config/initializers/manifest.rb"
,
"Rails.application.config.assets.prefix = '/x'"
# digest is default in false, we must enable it for test environment
# digest is default in false, we must enable it for test environment
app_file
"config/initializers/compile.rb"
,
"Rails.application.config.assets.digest = true"
add_to_config
"config.assets.digest = true"
add_to_config
"config.assets.prefix = '/x'"
capture
(
:stdout
)
do
capture
(
:stdout
)
do
Dir
.
chdir
(
app_path
){
`bundle exec rake assets:precompile`
}
Dir
.
chdir
(
app_path
){
`bundle exec rake assets:precompile`
}
...
@@ -128,7 +129,7 @@ def app
...
@@ -128,7 +129,7 @@ def app
test
"precompile does not append asset digests when config.assets.digest is false"
do
test
"precompile does not append asset digests when config.assets.digest is false"
do
app_file
"app/assets/stylesheets/application.css.erb"
,
"<%= asset_path('rails.png') %>"
app_file
"app/assets/stylesheets/application.css.erb"
,
"<%= asset_path('rails.png') %>"
app_file
"app/assets/javascripts/application.js"
,
"alert();"
app_file
"app/assets/javascripts/application.js"
,
"alert();"
a
pp_file
"config/initializers/compile.rb"
,
"Rails.application.
config.assets.digest = false"
a
dd_to_config
"
config.assets.digest = false"
capture
(
:stdout
)
do
capture
(
:stdout
)
do
Dir
.
chdir
(
app_path
){
`bundle exec rake assets:precompile`
}
Dir
.
chdir
(
app_path
){
`bundle exec rake assets:precompile`
}
...
@@ -191,7 +192,7 @@ class ::PostsController < ActionController::Base ; end
...
@@ -191,7 +192,7 @@ class ::PostsController < ActionController::Base ; end
test
"assets raise AssetNotPrecompiledError when manifest file is present and requested file isn't precompiled if digest is disabled"
do
test
"assets raise AssetNotPrecompiledError when manifest file is present and requested file isn't precompiled if digest is disabled"
do
app_file
"app/views/posts/index.html.erb"
,
"<%= javascript_include_tag 'app' %>"
app_file
"app/views/posts/index.html.erb"
,
"<%= javascript_include_tag 'app' %>"
a
pp_file
"config/initializers/compile.rb"
,
"Rails.application.
config.assets.compile = false"
a
dd_to_config
"
config.assets.compile = false"
app_file
"config/routes.rb"
,
<<-
RUBY
app_file
"config/routes.rb"
,
<<-
RUBY
AppTemplate::Application.routes.draw do
AppTemplate::Application.routes.draw do
...
@@ -218,7 +219,7 @@ class ::PostsController < ActionController::Base ; end
...
@@ -218,7 +219,7 @@ class ::PostsController < ActionController::Base ; end
test
"precompile appends the md5 hash to files referenced with asset_path and run in the provided RAILS_ENV"
do
test
"precompile appends the md5 hash to files referenced with asset_path and run in the provided RAILS_ENV"
do
app_file
"app/assets/stylesheets/application.css.erb"
,
"<%= asset_path('rails.png') %>"
app_file
"app/assets/stylesheets/application.css.erb"
,
"<%= asset_path('rails.png') %>"
# digest is default in false, we must enable it for test environment
# digest is default in false, we must enable it for test environment
a
pp_file
"config/initializers/compile.rb"
,
"Rails.application.
config.assets.digest = true"
a
dd_to_config
"
config.assets.digest = true"
# capture(:stdout) do
# capture(:stdout) do
Dir
.
chdir
(
app_path
){
`bundle exec rake assets:precompile RAILS_ENV=test`
}
Dir
.
chdir
(
app_path
){
`bundle exec rake assets:precompile RAILS_ENV=test`
}
...
@@ -229,7 +230,7 @@ class ::PostsController < ActionController::Base ; end
...
@@ -229,7 +230,7 @@ class ::PostsController < ActionController::Base ; end
test
"precompile appends the md5 hash to files referenced with asset_path and run in production as default even using RAILS_GROUPS=assets"
do
test
"precompile appends the md5 hash to files referenced with asset_path and run in production as default even using RAILS_GROUPS=assets"
do
app_file
"app/assets/stylesheets/application.css.erb"
,
"<%= asset_path('rails.png') %>"
app_file
"app/assets/stylesheets/application.css.erb"
,
"<%= asset_path('rails.png') %>"
a
pp_file
"config/initializers/compile.rb"
,
"Rails.application.
config.assets.compile = true"
a
dd_to_config
"
config.assets.compile = true"
ENV
[
"RAILS_ENV"
]
=
nil
ENV
[
"RAILS_ENV"
]
=
nil
capture
(
:stdout
)
do
capture
(
:stdout
)
do
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录