Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
638bd19c
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,体验更适合开发者的 AI 搜索 >>
提交
638bd19c
编写于
9月 22, 2008
作者:
M
Michael Koziarski
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'patches' into multibyte
上级
5795c509
5f86451a
变更
14
展开全部
隐藏空白更改
内联
并排
Showing
14 changed file
with
439 addition
and
163 deletion
+439
-163
actionmailer/lib/action_mailer/version.rb
actionmailer/lib/action_mailer/version.rb
+1
-1
actionpack/lib/action_pack/version.rb
actionpack/lib/action_pack/version.rb
+1
-1
actionpack/lib/action_view/helpers/asset_tag_helper.rb
actionpack/lib/action_view/helpers/asset_tag_helper.rb
+316
-148
actionpack/test/template/asset_tag_helper_test.rb
actionpack/test/template/asset_tag_helper_test.rb
+60
-4
activerecord/CHANGELOG
activerecord/CHANGELOG
+2
-0
activerecord/lib/active_record/associations.rb
activerecord/lib/active_record/associations.rb
+2
-2
activerecord/lib/active_record/associations/association_collection.rb
.../lib/active_record/associations/association_collection.rb
+4
-3
activerecord/lib/active_record/base.rb
activerecord/lib/active_record/base.rb
+10
-0
activerecord/lib/active_record/version.rb
activerecord/lib/active_record/version.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/associations/has_many_associations_test.rb
...ord/test/cases/associations/has_many_associations_test.rb
+13
-0
activerecord/test/cases/base_test.rb
activerecord/test/cases/base_test.rb
+26
-0
activesupport/lib/active_support/version.rb
activesupport/lib/active_support/version.rb
+1
-1
railties/lib/rails/version.rb
railties/lib/rails/version.rb
+1
-1
未找到文件。
actionmailer/lib/action_mailer/version.rb
浏览文件 @
638bd19c
module
ActionMailer
module
VERSION
#:nodoc:
MAJOR
=
2
MINOR
=
1
MINOR
=
2
TINY
=
0
STRING
=
[
MAJOR
,
MINOR
,
TINY
].
join
(
'.'
)
...
...
actionpack/lib/action_pack/version.rb
浏览文件 @
638bd19c
module
ActionPack
#:nodoc:
module
VERSION
#:nodoc:
MAJOR
=
2
MINOR
=
1
MINOR
=
2
TINY
=
0
STRING
=
[
MAJOR
,
MINOR
,
TINY
].
join
(
'.'
)
...
...
actionpack/lib/action_view/helpers/asset_tag_helper.rb
浏览文件 @
638bd19c
此差异已折叠。
点击以展开。
actionpack/test/template/asset_tag_helper_test.rb
浏览文件 @
638bd19c
...
...
@@ -38,7 +38,8 @@ def host_with_port() 'localhost' end
@controller
.
request
=
@request
ActionView
::
Helpers
::
AssetTagHelper
::
reset_javascript_include_default
COMPUTED_PUBLIC_PATHS
.
clear
AssetTag
::
Cache
.
clear
AssetCollection
::
Cache
.
clear
end
def
teardown
...
...
@@ -155,12 +156,12 @@ def test_path_to_javascript_alias_for_javascript_path
PathToJavascriptToTag
.
each
{
|
method
,
tag
|
assert_dom_equal
(
tag
,
eval
(
method
))
}
end
def
test_javascript_include_tag
def
test_javascript_include_tag
_with_blank_asset_id
ENV
[
"RAILS_ASSET_ID"
]
=
""
JavascriptIncludeToTag
.
each
{
|
method
,
tag
|
assert_dom_equal
(
tag
,
eval
(
method
))
}
end
COMPUTED_PUBLIC_PATHS
.
clear
def
test_javascript_include_tag_with_given_asset_id
ENV
[
"RAILS_ASSET_ID"
]
=
"1"
assert_dom_equal
(
%(<script src="/javascripts/prototype.js?1" type="text/javascript"></script>\n<script src="/javascripts/effects.js?1" type="text/javascript"></script>\n<script src="/javascripts/dragdrop.js?1" type="text/javascript"></script>\n<script src="/javascripts/controls.js?1" type="text/javascript"></script>\n<script src="/javascripts/application.js?1" type="text/javascript"></script>)
,
javascript_include_tag
(
:defaults
))
end
...
...
@@ -169,6 +170,11 @@ def test_register_javascript_include_default
ENV
[
"RAILS_ASSET_ID"
]
=
""
ActionView
::
Helpers
::
AssetTagHelper
::
register_javascript_include_default
'slider'
assert_dom_equal
%(<script src="/javascripts/prototype.js" type="text/javascript"></script>\n<script src="/javascripts/effects.js" type="text/javascript"></script>\n<script src="/javascripts/dragdrop.js" type="text/javascript"></script>\n<script src="/javascripts/controls.js" type="text/javascript"></script>\n<script src="/javascripts/slider.js" type="text/javascript"></script>\n<script src="/javascripts/application.js" type="text/javascript"></script>)
,
javascript_include_tag
(
:defaults
)
end
def
test_register_javascript_include_default_mixed_defaults
ENV
[
"RAILS_ASSET_ID"
]
=
""
ActionView
::
Helpers
::
AssetTagHelper
::
register_javascript_include_default
'slider'
ActionView
::
Helpers
::
AssetTagHelper
::
register_javascript_include_default
'lib1'
,
'/elsewhere/blub/lib2'
assert_dom_equal
%(<script src="/javascripts/prototype.js" type="text/javascript"></script>\n<script src="/javascripts/effects.js" type="text/javascript"></script>\n<script src="/javascripts/dragdrop.js" type="text/javascript"></script>\n<script src="/javascripts/controls.js" type="text/javascript"></script>\n<script src="/javascripts/slider.js" type="text/javascript"></script>\n<script src="/javascripts/lib1.js" type="text/javascript"></script>\n<script src="/elsewhere/blub/lib2.js" type="text/javascript"></script>\n<script src="/javascripts/application.js" type="text/javascript"></script>)
,
javascript_include_tag
(
:defaults
)
end
...
...
@@ -386,6 +392,31 @@ def test_caching_javascript_include_tag_with_all_puts_defaults_at_the_start_of_t
FileUtils
.
rm_f
(
File
.
join
(
ActionView
::
Helpers
::
AssetTagHelper
::
JAVASCRIPTS_DIR
,
'combined.js'
))
end
def
test_caching_javascript_include_tag_with_relative_url_root
ENV
[
"RAILS_ASSET_ID"
]
=
""
ActionController
::
Base
.
relative_url_root
=
"/collaboration/hieraki"
ActionController
::
Base
.
perform_caching
=
true
assert_dom_equal
(
%(<script src="/collaboration/hieraki/javascripts/all.js" type="text/javascript"></script>)
,
javascript_include_tag
(
:all
,
:cache
=>
true
)
)
assert
File
.
exist?
(
File
.
join
(
ActionView
::
Helpers
::
AssetTagHelper
::
JAVASCRIPTS_DIR
,
'all.js'
))
assert_dom_equal
(
%(<script src="/collaboration/hieraki/javascripts/money.js" type="text/javascript"></script>)
,
javascript_include_tag
(
:all
,
:cache
=>
"money"
)
)
assert
File
.
exist?
(
File
.
join
(
ActionView
::
Helpers
::
AssetTagHelper
::
JAVASCRIPTS_DIR
,
'money.js'
))
ensure
ActionController
::
Base
.
relative_url_root
=
nil
FileUtils
.
rm_f
(
File
.
join
(
ActionView
::
Helpers
::
AssetTagHelper
::
JAVASCRIPTS_DIR
,
'all.js'
))
FileUtils
.
rm_f
(
File
.
join
(
ActionView
::
Helpers
::
AssetTagHelper
::
JAVASCRIPTS_DIR
,
'money.js'
))
end
def
test_caching_javascript_include_tag_when_caching_off
ENV
[
"RAILS_ASSET_ID"
]
=
""
ActionController
::
Base
.
perform_caching
=
false
...
...
@@ -456,6 +487,31 @@ def test_caching_stylesheet_link_tag_when_caching_on_with_proc_asset_host
FileUtils
.
rm_f
(
File
.
join
(
ActionView
::
Helpers
::
AssetTagHelper
::
STYLESHEETS_DIR
,
'styles.css'
))
end
def
test_caching_stylesheet_link_tag_with_relative_url_root
ENV
[
"RAILS_ASSET_ID"
]
=
""
ActionController
::
Base
.
relative_url_root
=
"/collaboration/hieraki"
ActionController
::
Base
.
perform_caching
=
true
assert_dom_equal
(
%(<link href="/collaboration/hieraki/stylesheets/all.css" media="screen" rel="stylesheet" type="text/css" />)
,
stylesheet_link_tag
(
:all
,
:cache
=>
true
)
)
expected
=
Dir
[
"
#{
ActionView
::
Helpers
::
AssetTagHelper
::
STYLESHEETS_DIR
}
/*.css"
].
map
{
|
p
|
File
.
mtime
(
p
)
}.
max
assert_equal
expected
,
File
.
mtime
(
File
.
join
(
ActionView
::
Helpers
::
AssetTagHelper
::
STYLESHEETS_DIR
,
'all.css'
))
assert_dom_equal
(
%(<link href="/collaboration/hieraki/stylesheets/money.css" media="screen" rel="stylesheet" type="text/css" />)
,
stylesheet_link_tag
(
:all
,
:cache
=>
"money"
)
)
assert
File
.
exist?
(
File
.
join
(
ActionView
::
Helpers
::
AssetTagHelper
::
STYLESHEETS_DIR
,
'money.css'
))
ensure
ActionController
::
Base
.
relative_url_root
=
nil
FileUtils
.
rm_f
(
File
.
join
(
ActionView
::
Helpers
::
AssetTagHelper
::
STYLESHEETS_DIR
,
'all.css'
))
FileUtils
.
rm_f
(
File
.
join
(
ActionView
::
Helpers
::
AssetTagHelper
::
STYLESHEETS_DIR
,
'money.css'
))
end
def
test_caching_stylesheet_include_tag_when_caching_off
ENV
[
"RAILS_ASSET_ID"
]
=
""
ActionController
::
Base
.
perform_caching
=
false
...
...
activerecord/CHANGELOG
浏览文件 @
638bd19c
*Edge*
* Add Model#delete instance method, similar to Model.delete class method. #1086 [Hongli Lai]
* MySQL: cope with quirky default values for not-null text columns. #1043 [Frederick Cheung]
* Multiparameter attributes skip time zone conversion for time-only columns [#1030 state:resolved] [Geoff Buesing]
...
...
activerecord/lib/active_record/associations.rb
浏览文件 @
638bd19c
...
...
@@ -1470,7 +1470,7 @@ def configure_dependency_for_has_one(reflection)
method_name
=
"has_one_dependent_delete_for_
#{
reflection
.
name
}
"
.
to_sym
define_method
(
method_name
)
do
association
=
send
(
reflection
.
name
)
association
.
class
.
delete
(
association
.
id
)
unless
association
.
nil?
association
.
delete
unless
association
.
nil?
end
before_destroy
method_name
when
:nullify
...
...
@@ -1500,7 +1500,7 @@ def configure_dependency_for_belongs_to(reflection)
method_name
=
"belongs_to_dependent_delete_for_
#{
reflection
.
name
}
"
.
to_sym
define_method
(
method_name
)
do
association
=
send
(
reflection
.
name
)
association
.
class
.
delete
(
association
.
id
)
unless
association
.
nil?
association
.
delete
unless
association
.
nil?
end
before_destroy
method_name
else
...
...
activerecord/lib/active_record/associations/association_collection.rb
浏览文件 @
638bd19c
...
...
@@ -63,7 +63,7 @@ def find(*args)
# Fetches the first one using SQL if possible.
def
first
(
*
args
)
if
fetch_first_or_last_using_find?
args
if
fetch_first_or_last_using_find?
(
args
)
find
(
:first
,
*
args
)
else
load_target
unless
loaded?
...
...
@@ -73,7 +73,7 @@ def first(*args)
# Fetches the last one using SQL if possible.
def
last
(
*
args
)
if
fetch_first_or_last_using_find?
args
if
fetch_first_or_last_using_find?
(
args
)
find
(
:last
,
*
args
)
else
load_target
unless
loaded?
...
...
@@ -420,7 +420,8 @@ def ensure_owner_is_not_new
end
def
fetch_first_or_last_using_find?
(
args
)
args
.
first
.
kind_of?
(
Hash
)
||
!
(
loaded?
||
@owner
.
new_record?
||
@reflection
.
options
[
:finder_sql
]
||
!
@target
.
blank?
||
args
.
first
.
kind_of?
(
Integer
))
args
.
first
.
kind_of?
(
Hash
)
||
!
(
loaded?
||
@owner
.
new_record?
||
@reflection
.
options
[
:finder_sql
]
||
@target
.
any?
{
|
record
|
record
.
new_record?
}
||
args
.
first
.
kind_of?
(
Integer
))
end
end
end
...
...
activerecord/lib/active_record/base.rb
浏览文件 @
638bd19c
...
...
@@ -2304,6 +2304,16 @@ def save!
create_or_update
||
raise
(
RecordNotSaved
)
end
# Deletes the record in the database and freezes this instance to reflect that no changes should
# be made (since they can't be persisted).
#
# Unlike #destroy, this method doesn't run any +before_delete+ and +after_delete+
# callbacks, nor will it enforce any association +:dependent+ rules.
def
delete
self
.
class
.
delete
(
id
)
unless
new_record?
freeze
end
# Deletes the record in the database and freezes this instance to reflect that no changes should
# be made (since they can't be persisted).
def
destroy
...
...
activerecord/lib/active_record/version.rb
浏览文件 @
638bd19c
module
ActiveRecord
module
VERSION
#:nodoc:
MAJOR
=
2
MINOR
=
1
MINOR
=
2
TINY
=
0
STRING
=
[
MAJOR
,
MINOR
,
TINY
].
join
(
'.'
)
...
...
activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb
浏览文件 @
638bd19c
...
...
@@ -253,7 +253,7 @@ def test_create
assert
!
devel
.
projects
.
loaded?
assert_equal
devel
.
projects
.
last
,
proj
assert
devel
.
projects
.
loaded?
assert
!
devel
.
projects
.
loaded?
assert
!
proj
.
new_record?
assert_equal
Developer
.
find
(
1
).
projects
.
sort_by
(
&
:id
).
last
,
proj
# prove join table is updated
...
...
activerecord/test/cases/associations/has_many_associations_test.rb
浏览文件 @
638bd19c
...
...
@@ -1009,6 +1009,19 @@ def test_calling_first_or_last_on_existing_record_with_build_should_load_associa
assert
firm
.
clients
.
loaded?
end
def
test_calling_first_or_last_on_existing_record_with_create_should_not_load_association
firm
=
companies
(
:first_firm
)
firm
.
clients
.
create
(
:name
=>
'Foo'
)
assert
!
firm
.
clients
.
loaded?
assert_queries
2
do
firm
.
clients
.
first
firm
.
clients
.
last
end
assert
!
firm
.
clients
.
loaded?
end
def
test_calling_first_or_last_on_new_record_should_not_run_queries
firm
=
Firm
.
new
...
...
activerecord/test/cases/base_test.rb
浏览文件 @
638bd19c
...
...
@@ -472,6 +472,18 @@ def test_custom_mutator
assert
topic
.
instance_variable_get
(
"@custom_approved"
)
end
def
test_delete
topic
=
Topic
.
find
(
1
)
assert_equal
topic
,
topic
.
delete
,
'topic.delete did not return self'
assert
topic
.
frozen?
,
'topic not frozen after delete'
assert_raise
(
ActiveRecord
::
RecordNotFound
)
{
Topic
.
find
(
topic
.
id
)
}
end
def
test_delete_doesnt_run_callbacks
Topic
.
find
(
1
).
delete
assert_not_nil
Topic
.
find
(
2
)
end
def
test_destroy
topic
=
Topic
.
find
(
1
)
assert_equal
topic
,
topic
.
destroy
,
'topic.destroy did not return self'
...
...
@@ -820,6 +832,20 @@ def test_hashing
assert_equal
[
Topic
.
find
(
1
)
],
[
Topic
.
find
(
2
).
topic
]
&
[
Topic
.
find
(
1
)
]
end
def
test_delete_new_record
client
=
Client
.
new
client
.
delete
assert
client
.
frozen?
end
def
test_delete_record_with_associations
client
=
Client
.
find
(
3
)
client
.
delete
assert
client
.
frozen?
assert_kind_of
Firm
,
client
.
firm
assert_raises
(
ActiveSupport
::
FrozenObjectError
)
{
client
.
name
=
"something else"
}
end
def
test_destroy_new_record
client
=
Client
.
new
client
.
destroy
...
...
activesupport/lib/active_support/version.rb
浏览文件 @
638bd19c
module
ActiveSupport
module
VERSION
#:nodoc:
MAJOR
=
2
MINOR
=
1
MINOR
=
2
TINY
=
0
STRING
=
[
MAJOR
,
MINOR
,
TINY
].
join
(
'.'
)
...
...
railties/lib/rails/version.rb
浏览文件 @
638bd19c
module
Rails
module
VERSION
#:nodoc:
MAJOR
=
2
MINOR
=
1
MINOR
=
2
TINY
=
0
STRING
=
[
MAJOR
,
MINOR
,
TINY
].
join
(
'.'
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录