Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
62c6ac2f
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,发现更多精彩内容 >>
提交
62c6ac2f
编写于
5月 18, 2012
作者:
J
Jon Leighton
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
quarantine more deprecated stuff
上级
ee16feae
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
36 addition
and
36 deletion
+36
-36
activerecord/test/cases/base_test.rb
activerecord/test/cases/base_test.rb
+0
-18
activerecord/test/cases/deprecated_dynamic_methods_test.rb
activerecord/test/cases/deprecated_dynamic_methods_test.rb
+36
-0
activerecord/test/cases/finder_test.rb
activerecord/test/cases/finder_test.rb
+0
-9
activerecord/test/cases/relations_test.rb
activerecord/test/cases/relations_test.rb
+0
-9
未找到文件。
activerecord/test/cases/base_test.rb
浏览文件 @
62c6ac2f
...
...
@@ -168,24 +168,6 @@ def test_table_exists
assert
Topic
.
table_exists?
end
def
test_finder_block
t
=
Topic
.
first
found
=
nil
Topic
.
find_by_id
(
t
.
id
)
{
|
f
|
found
=
f
}
assert_equal
t
,
found
end
def
test_finder_block_nothing_found
bad_id
=
Topic
.
maximum
(
:id
)
+
1
assert_nil
Topic
.
find_by_id
(
bad_id
)
{
|
f
|
raise
}
end
def
test_find_returns_block_value
t
=
Topic
.
first
x
=
Topic
.
find_by_id
(
t
.
id
)
{
|
f
|
"hi mom!"
}
assert_equal
"hi mom!"
,
x
end
def
test_preserving_date_objects
if
current_adapter?
(
:SybaseAdapter
)
# Sybase ctlib does not (yet?) support the date type; use datetime instead.
...
...
activerecord/test/cases/deprecated_dynamic_methods_test.rb
浏览文件 @
62c6ac2f
...
...
@@ -525,6 +525,42 @@ def test_dynamic_find_or_create_by_attributes_bang
assert_equal
authors
(
:david
),
authors
.
find_or_create_by_name!
(
:name
=>
'David'
)
end
def
test_finder_block
t
=
Topic
.
first
found
=
nil
Topic
.
find_by_id
(
t
.
id
)
{
|
f
|
found
=
f
}
assert_equal
t
,
found
end
def
test_finder_block_nothing_found
bad_id
=
Topic
.
maximum
(
:id
)
+
1
assert_nil
Topic
.
find_by_id
(
bad_id
)
{
|
f
|
raise
}
end
def
test_find_returns_block_value
t
=
Topic
.
first
x
=
Topic
.
find_by_id
(
t
.
id
)
{
|
f
|
"hi mom!"
}
assert_equal
"hi mom!"
,
x
end
def
test_dynamic_finder_with_invalid_params
assert_raise
(
ArgumentError
)
{
Topic
.
find_by_title
'No Title'
,
:join
=>
"It should be `joins'"
}
end
def
test_find_by_one_attribute_with_order_option
assert_equal
accounts
(
:signals37
),
Account
.
find_by_credit_limit
(
50
,
:order
=>
'id'
)
assert_equal
accounts
(
:rails_core_account
),
Account
.
find_by_credit_limit
(
50
,
:order
=>
'id DESC'
)
end
def
test_dynamic_find_by_attributes_should_yield_found_object
david
=
authors
(
:david
)
yielded_value
=
nil
Author
.
find_by_name
(
david
.
name
)
do
|
author
|
yielded_value
=
author
end
assert_equal
david
,
yielded_value
end
end
class
DynamicScopeTest
<
ActiveRecord
::
TestCase
...
...
activerecord/test/cases/finder_test.rb
浏览文件 @
62c6ac2f
...
...
@@ -589,11 +589,6 @@ def test_find_by_one_attribute_bang
assert_raise
(
ActiveRecord
::
RecordNotFound
)
{
Topic
.
find_by_title!
(
"The First Topic!"
)
}
end
def
test_find_by_one_attribute_with_order_option
assert_equal
accounts
(
:signals37
),
Account
.
find_by_credit_limit
(
50
,
:order
=>
'id'
)
assert_equal
accounts
(
:rails_core_account
),
Account
.
find_by_credit_limit
(
50
,
:order
=>
'id DESC'
)
end
def
test_find_by_one_attribute_with_conditions
assert_equal
accounts
(
:rails_core_account
),
Account
.
where
(
'firm_id = ?'
,
6
).
find_by_credit_limit
(
50
)
end
...
...
@@ -678,10 +673,6 @@ def test_find_with_bad_sql
assert_raise
(
ActiveRecord
::
StatementInvalid
)
{
Topic
.
find_by_sql
"select 1 from badtable"
}
end
def
test_dynamic_finder_with_invalid_params
assert_raise
(
ArgumentError
)
{
Topic
.
find_by_title
'No Title'
,
:join
=>
"It should be `joins'"
}
end
def
test_find_all_with_join
developers_on_project_one
=
Developer
.
scoped
(
:joins
=>
'LEFT JOIN developers_projects ON developers.id = developers_projects.developer_id'
,
...
...
activerecord/test/cases/relations_test.rb
浏览文件 @
62c6ac2f
...
...
@@ -443,15 +443,6 @@ def test_loading_with_one_association_with_non_preload
assert_equal
Post
.
find
(
1
).
last_comment
,
post
.
last_comment
end
def
test_dynamic_find_by_attributes_should_yield_found_object
david
=
authors
(
:david
)
yielded_value
=
nil
Author
.
find_by_name
(
david
.
name
)
do
|
author
|
yielded_value
=
author
end
assert_equal
david
,
yielded_value
end
def
test_dynamic_find_by_attributes
david
=
authors
(
:david
)
author
=
Author
.
preload
(
:taggings
).
find_by_id
(
david
.
id
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录