Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
9abc94c4
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,发现更多精彩内容 >>
提交
9abc94c4
编写于
3月 16, 2011
作者:
J
Jon Leighton
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
oracle, y u defy me
上级
37d93ea1
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
15 addition
and
13 deletion
+15
-13
activerecord/test/cases/associations/join_model_test.rb
activerecord/test/cases/associations/join_model_test.rb
+1
-1
activerecord/test/cases/reflection_test.rb
activerecord/test/cases/reflection_test.rb
+5
-5
activerecord/test/models/author.rb
activerecord/test/models/author.rb
+4
-2
activerecord/test/models/post.rb
activerecord/test/models/post.rb
+4
-4
activerecord/test/models/tagging.rb
activerecord/test/models/tagging.rb
+1
-1
未找到文件。
activerecord/test/cases/associations/join_model_test.rb
浏览文件 @
9abc94c4
...
...
@@ -305,7 +305,7 @@ def test_has_many_through_with_custom_primary_key_on_belongs_to_source
end
def
test_has_many_through_with_custom_primary_key_on_has_many_source
assert_equal
[
authors
(
:david
),
authors
(
:bob
)],
posts
(
:thinking
).
authors_using_custom_pk
.
order
(
:id
)
assert_equal
[
authors
(
:david
),
authors
(
:bob
)],
posts
(
:thinking
).
authors_using_custom_pk
.
order
(
'authors.id'
)
end
def
test_both_scoped_and_explicit_joins_should_be_respected
...
...
activerecord/test/cases/reflection_test.rb
浏览文件 @
9abc94c4
...
...
@@ -215,16 +215,16 @@ def test_chain
def
test_conditions
expected
=
[
[
"tags.name = 'Blue'"
],
[
"taggings.comment = 'first'"
,
{
"taggable_type"
=>
"Post"
}],
[
"posts.title LIKE 'misc post%'"
]
[
{
:tags
=>
{
:name
=>
'Blue'
}
}
],
[
{
:taggings
=>
{
:comment
=>
'first'
}
},
{
"taggable_type"
=>
"Post"
}],
[
{
:posts
=>
{
:title
=>
[
'misc post by bob'
,
'misc post by mary'
]
}
}
]
]
actual
=
Author
.
reflect_on_association
(
:misc_post_first_blue_tags
).
conditions
assert_equal
expected
,
actual
expected
=
[
[
"tags.name = 'Blue'"
,
"taggings.comment = 'first'"
,
"posts.title LIKE 'misc post%'"
],
[{
"taggable_type"
=>
"Post"
}],
[
{
:tags
=>
{
:name
=>
'Blue'
}
},
{
:taggings
=>
{
:comment
=>
'first'
}
},
{
:posts
=>
{
:title
=>
[
'misc post by bob'
,
'misc post by mary'
]
}
}
],
[{
"taggable_type"
=>
"Post"
}],
[]
]
actual
=
Author
.
reflect_on_association
(
:misc_post_first_blue_tags_2
).
conditions
...
...
activerecord/test/models/author.rb
浏览文件 @
9abc94c4
...
...
@@ -131,10 +131,12 @@ def testing_proxy_target
has_many
:post_categories
,
:through
=>
:posts
,
:source
=>
:categories
has_many
:category_post_comments
,
:through
=>
:categories
,
:source
=>
:post_comments
has_many
:misc_posts
,
:class_name
=>
'Post'
,
:conditions
=>
"posts.title LIKE 'misc post%'"
has_many
:misc_posts
,
:class_name
=>
'Post'
,
:conditions
=>
{
:posts
=>
{
:title
=>
[
'misc post by bob'
,
'misc post by mary'
]
}
}
has_many
:misc_post_first_blue_tags
,
:through
=>
:misc_posts
,
:source
=>
:first_blue_tags
has_many
:misc_post_first_blue_tags_2
,
:through
=>
:posts
,
:source
=>
:first_blue_tags_2
,
:conditions
=>
"posts.title LIKE 'misc post%'"
has_many
:misc_post_first_blue_tags_2
,
:through
=>
:posts
,
:source
=>
:first_blue_tags_2
,
:conditions
=>
{
:posts
=>
{
:title
=>
[
'misc post by bob'
,
'misc post by mary'
]
}
}
scope
:relation_include_posts
,
includes
(
:posts
)
scope
:relation_include_tags
,
includes
(
:tags
)
...
...
activerecord/test/models/post.rb
浏览文件 @
9abc94c4
...
...
@@ -73,16 +73,16 @@ def add_joins_and_select
has_many
:tags_with_destroy
,
:through
=>
:taggings
,
:source
=>
:tag
,
:dependent
=>
:destroy
has_many
:tags_with_nullify
,
:through
=>
:taggings
,
:source
=>
:tag
,
:dependent
=>
:nullify
has_many
:misc_tags
,
:through
=>
:taggings
,
:source
=>
:tag
,
:conditions
=>
"tags.name = 'Misc'"
has_many
:misc_tags
,
:through
=>
:taggings
,
:source
=>
:tag
,
:conditions
=>
{
:tags
=>
{
:name
=>
'Misc'
}
}
has_many
:funky_tags
,
:through
=>
:taggings
,
:source
=>
:tag
has_many
:super_tags
,
:through
=>
:taggings
has_many
:tags_with_primary_key
,
:through
=>
:taggings
,
:source
=>
:tag_with_primary_key
has_one
:tagging
,
:as
=>
:taggable
has_many
:first_taggings
,
:as
=>
:taggable
,
:class_name
=>
'Tagging'
,
:conditions
=>
"taggings.comment = 'first'"
has_many
:first_blue_tags
,
:through
=>
:first_taggings
,
:source
=>
:tag
,
:conditions
=>
"tags.name = 'Blue'"
has_many
:first_taggings
,
:as
=>
:taggable
,
:class_name
=>
'Tagging'
,
:conditions
=>
{
:taggings
=>
{
:comment
=>
'first'
}
}
has_many
:first_blue_tags
,
:through
=>
:first_taggings
,
:source
=>
:tag
,
:conditions
=>
{
:tags
=>
{
:name
=>
'Blue'
}
}
has_many
:first_blue_tags_2
,
:through
=>
:taggings
,
:source
=>
:blue_tag
,
:conditions
=>
"taggings.comment = 'first'"
has_many
:first_blue_tags_2
,
:through
=>
:taggings
,
:source
=>
:blue_tag
,
:conditions
=>
{
:taggings
=>
{
:comment
=>
'first'
}
}
has_many
:invalid_taggings
,
:as
=>
:taggable
,
:class_name
=>
"Tagging"
,
:conditions
=>
'taggings.id < 0'
has_many
:invalid_tags
,
:through
=>
:invalid_taggings
,
:source
=>
:tag
...
...
activerecord/test/models/tagging.rb
浏览文件 @
9abc94c4
...
...
@@ -6,7 +6,7 @@ class Tagging < ActiveRecord::Base
belongs_to
:tag
,
:include
=>
:tagging
belongs_to
:super_tag
,
:class_name
=>
'Tag'
,
:foreign_key
=>
'super_tag_id'
belongs_to
:invalid_tag
,
:class_name
=>
'Tag'
,
:foreign_key
=>
'tag_id'
belongs_to
:blue_tag
,
:class_name
=>
'Tag'
,
:foreign_key
=>
:tag_id
,
:conditions
=>
"tags.name = 'Blue'"
belongs_to
:blue_tag
,
:class_name
=>
'Tag'
,
:foreign_key
=>
:tag_id
,
:conditions
=>
{
:tags
=>
{
:name
=>
'Blue'
}
}
belongs_to
:tag_with_primary_key
,
:class_name
=>
'Tag'
,
:foreign_key
=>
:tag_id
,
:primary_key
=>
:custom_primary_key
belongs_to
:interpolated_tag
,
:class_name
=>
'Tag'
,
:foreign_key
=>
:tag_id
,
:conditions
=>
proc
{
"1 =
#{
1
}
"
}
belongs_to
:taggable
,
:polymorphic
=>
true
,
:counter_cache
=>
true
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录