Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
d40e3ea9
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,发现更多精彩内容 >>
提交
d40e3ea9
编写于
3月 23, 2009
作者:
R
Raimonds Simanovskis
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Oracle saves empty string as NULL
上级
71c32d3c
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
36 addition
and
10 deletion
+36
-10
activerecord/test/cases/autosave_association_test.rb
activerecord/test/cases/autosave_association_test.rb
+36
-10
未找到文件。
activerecord/test/cases/autosave_association_test.rb
浏览文件 @
d40e3ea9
...
...
@@ -154,7 +154,8 @@ def test_should_save_parent_but_not_invalid_child
end
def
test_save_fails_for_invalid_belongs_to
assert
log
=
AuditLog
.
create
(
:developer_id
=>
0
,
:message
=>
""
)
# Oracle saves empty string as NULL therefore :message changed to one space
assert
log
=
AuditLog
.
create
(
:developer_id
=>
0
,
:message
=>
" "
)
log
.
developer
=
Developer
.
new
assert
!
log
.
developer
.
valid?
...
...
@@ -164,7 +165,8 @@ def test_save_fails_for_invalid_belongs_to
end
def
test_save_succeeds_for_invalid_belongs_to_with_validate_false
assert
log
=
AuditLog
.
create
(
:developer_id
=>
0
,
:message
=>
""
)
# Oracle saves empty string as NULL therefore :message changed to one space
assert
log
=
AuditLog
.
create
(
:developer_id
=>
0
,
:message
=>
" "
)
log
.
unvalidated_developer
=
Developer
.
new
assert
!
log
.
unvalidated_developer
.
valid?
...
...
@@ -666,7 +668,12 @@ def test_should_still_allow_to_bypass_validations_on_the_associated_model
@pirate
.
catchphrase
=
''
@pirate
.
ship
.
name
=
''
@pirate
.
save
(
false
)
assert_equal
[
''
,
''
],
[
@pirate
.
reload
.
catchphrase
,
@pirate
.
ship
.
name
]
# Oracle saves empty string as NULL
if
current_adapter?
(
:OracleAdapter
)
assert_equal
[
nil
,
nil
],
[
@pirate
.
reload
.
catchphrase
,
@pirate
.
ship
.
name
]
else
assert_equal
[
''
,
''
],
[
@pirate
.
reload
.
catchphrase
,
@pirate
.
ship
.
name
]
end
end
def
test_should_allow_to_bypass_validations_on_associated_models_at_any_depth
...
...
@@ -678,7 +685,12 @@ def test_should_allow_to_bypass_validations_on_associated_models_at_any_depth
@pirate
.
save
(
false
)
values
=
[
@pirate
.
reload
.
catchphrase
,
@pirate
.
ship
.
name
,
*
@pirate
.
ship
.
parts
.
map
(
&
:name
)]
assert_equal
[
''
,
''
,
''
,
''
],
values
# Oracle saves empty string as NULL
if
current_adapter?
(
:OracleAdapter
)
assert_equal
[
nil
,
nil
,
nil
,
nil
],
values
else
assert_equal
[
''
,
''
,
''
,
''
],
values
end
end
def
test_should_still_raise_an_ActiveRecordRecord_Invalid_exception_if_we_want_that
...
...
@@ -756,7 +768,12 @@ def test_should_still_allow_to_bypass_validations_on_the_associated_model
@ship
.
pirate
.
catchphrase
=
''
@ship
.
name
=
''
@ship
.
save
(
false
)
assert_equal
[
''
,
''
],
[
@ship
.
reload
.
name
,
@ship
.
pirate
.
catchphrase
]
# Oracle saves empty string as NULL
if
current_adapter?
(
:OracleAdapter
)
assert_equal
[
nil
,
nil
],
[
@ship
.
reload
.
name
,
@ship
.
pirate
.
catchphrase
]
else
assert_equal
[
''
,
''
],
[
@ship
.
reload
.
name
,
@ship
.
pirate
.
catchphrase
]
end
end
def
test_should_still_raise_an_ActiveRecordRecord_Invalid_exception_if_we_want_that
...
...
@@ -837,11 +854,20 @@ def test_should_allow_to_bypass_validations_on_the_associated_models_on_update
@pirate
.
send
(
@association_name
).
each
{
|
child
|
child
.
name
=
''
}
assert
@pirate
.
save
(
false
)
assert_equal
[
''
,
''
,
''
],
[
@pirate
.
reload
.
catchphrase
,
@pirate
.
send
(
@association_name
).
first
.
name
,
@pirate
.
send
(
@association_name
).
last
.
name
]
# Oracle saves empty string as NULL
if
current_adapter?
(
:OracleAdapter
)
assert_equal
[
nil
,
nil
,
nil
],
[
@pirate
.
reload
.
catchphrase
,
@pirate
.
send
(
@association_name
).
first
.
name
,
@pirate
.
send
(
@association_name
).
last
.
name
]
else
assert_equal
[
''
,
''
,
''
],
[
@pirate
.
reload
.
catchphrase
,
@pirate
.
send
(
@association_name
).
first
.
name
,
@pirate
.
send
(
@association_name
).
last
.
name
]
end
end
def
test_should_validation_the_associated_models_on_create
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录