Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
2b2f41fd
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,发现更多精彩内容 >>
提交
2b2f41fd
编写于
6月 04, 2015
作者:
V
Victor Costan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix crash when loading fixture with belongs_to association defined in abstract base class.
上级
7220ffcf
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
31 addition
and
1 deletion
+31
-1
activerecord/lib/active_record/fixtures.rb
activerecord/lib/active_record/fixtures.rb
+1
-1
activerecord/test/cases/fixtures_test.rb
activerecord/test/cases/fixtures_test.rb
+10
-0
activerecord/test/fixtures/doubloons.yml
activerecord/test/fixtures/doubloons.yml
+3
-0
activerecord/test/models/doubloon.rb
activerecord/test/models/doubloon.rb
+12
-0
activerecord/test/schema/schema.rb
activerecord/test/schema/schema.rb
+5
-0
未找到文件。
activerecord/lib/active_record/fixtures.rb
浏览文件 @
2b2f41fd
...
...
@@ -669,7 +669,7 @@ def table_rows
row
[
association
.
foreign_type
]
=
$1
end
fk_type
=
association
.
active_record
.
type_for_attribute
(
fk_name
).
type
fk_type
=
reflection_class
.
type_for_attribute
(
fk_name
).
type
row
[
fk_name
]
=
ActiveRecord
::
FixtureSet
.
identify
(
value
,
fk_type
)
end
when
:has_many
...
...
activerecord/test/cases/fixtures_test.rb
浏览文件 @
2b2f41fd
...
...
@@ -16,6 +16,7 @@
require
'models/matey'
require
'models/parrot'
require
'models/pirate'
require
'models/doubloon'
require
'models/post'
require
'models/randomly_named_c1'
require
'models/reply'
...
...
@@ -903,3 +904,12 @@ class FixturesWithDefaultScopeTest < ActiveRecord::TestCase
assert_equal
"special"
,
bulbs
(
:special
).
name
end
end
class
FixturesWithAbstractBelongsTo
<
ActiveRecord
::
TestCase
fixtures
:pirates
,
:doubloons
test
"creates fixtures with belongs_to associations defined in abstract base classes"
do
assert_not_nil
doubloons
(
:blackbeards_doubloon
)
assert_equal
pirates
(
:blackbeard
),
doubloons
(
:blackbeards_doubloon
).
pirate
end
end
activerecord/test/fixtures/doubloons.yml
0 → 100644
浏览文件 @
2b2f41fd
blackbeards_doubloon
:
pirate
:
blackbeard
weight
:
2
activerecord/test/models/doubloon.rb
0 → 100644
浏览文件 @
2b2f41fd
class
AbstractDoubloon
<
ActiveRecord
::
Base
# This has functionality that might be shared by multiple classes.
self
.
abstract_class
=
true
belongs_to
:pirate
end
class
Doubloon
<
AbstractDoubloon
# This uses an abstract class that defines attributes and associations.
self
.
table_name
=
'doubloons'
end
activerecord/test/schema/schema.rb
浏览文件 @
2b2f41fd
...
...
@@ -266,6 +266,11 @@ def except(adapter_names_to_exclude)
t
.
string
:alias
end
create_table
:doubloons
,
force:
true
do
|
t
|
t
.
integer
:pirate_id
t
.
integer
:weight
end
create_table
:edges
,
force:
true
,
id:
false
do
|
t
|
t
.
column
:source_id
,
:integer
,
null:
false
t
.
column
:sink_id
,
:integer
,
null:
false
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录